##// END OF EJS Templates
Added tests for the new get_ipython_dir and get_security_dir ...
Brian Granger -
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,32 b''
1 # encoding: utf-8
2
3 """Tests for genutils.py"""
4
5 __docformat__ = "restructuredtext en"
6
7 #-----------------------------------------------------------------------------
8 # Copyright (C) 2008 The IPython Development Team
9 #
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
12 #-----------------------------------------------------------------------------
13
14 #-----------------------------------------------------------------------------
15 # Imports
16 #-----------------------------------------------------------------------------
17
18 from IPython import genutils
19
20
21 def test_get_home_dir():
22 """Make sure we can get the home directory."""
23 home_dir = genutils.get_home_dir()
24
25 def test_get_ipython_dir():
26 """Make sure we can get the ipython directory."""
27 ipdir = genutils.get_ipython_dir()
28
29 def test_get_security_dir():
30 """Make sure we can get the ipython/security directory."""
31 sdir = genutils.get_security_dir()
32 No newline at end of file
@@ -1,278 +1,279 b''
1 1 # encoding: utf-8
2 2
3 3 """
4 4 This module defines the things that are used in setup.py for building IPython
5 5
6 6 This includes:
7 7
8 8 * The basic arguments to setup
9 9 * Functions for finding things like packages, package data, etc.
10 10 * A function for checking dependencies.
11 11 """
12 12
13 13 __docformat__ = "restructuredtext en"
14 14
15 15 #-------------------------------------------------------------------------------
16 16 # Copyright (C) 2008 The IPython Development Team
17 17 #
18 18 # Distributed under the terms of the BSD License. The full license is in
19 19 # the file COPYING, distributed as part of this software.
20 20 #-------------------------------------------------------------------------------
21 21
22 22 #-------------------------------------------------------------------------------
23 23 # Imports
24 24 #-------------------------------------------------------------------------------
25 25
26 26 import os, sys
27 27
28 28 from glob import glob
29 29
30 30 from setupext import install_data_ext
31 31
32 32 #-------------------------------------------------------------------------------
33 33 # Useful globals and utility functions
34 34 #-------------------------------------------------------------------------------
35 35
36 36 # A few handy globals
37 37 isfile = os.path.isfile
38 38 pjoin = os.path.join
39 39
40 40 def oscmd(s):
41 41 print ">", s
42 42 os.system(s)
43 43
44 44 # A little utility we'll need below, since glob() does NOT allow you to do
45 45 # exclusion on multiple endings!
46 46 def file_doesnt_endwith(test,endings):
47 47 """Return true if test is a file and its name does NOT end with any
48 48 of the strings listed in endings."""
49 49 if not isfile(test):
50 50 return False
51 51 for e in endings:
52 52 if test.endswith(e):
53 53 return False
54 54 return True
55 55
56 56 #---------------------------------------------------------------------------
57 57 # Basic project information
58 58 #---------------------------------------------------------------------------
59 59
60 60 # Release.py contains version, authors, license, url, keywords, etc.
61 61 execfile(pjoin('IPython','Release.py'))
62 62
63 63 # Create a dict with the basic information
64 64 # This dict is eventually passed to setup after additional keys are added.
65 65 setup_args = dict(
66 66 name = name,
67 67 version = version,
68 68 description = description,
69 69 long_description = long_description,
70 70 author = author,
71 71 author_email = author_email,
72 72 url = url,
73 73 download_url = download_url,
74 74 license = license,
75 75 platforms = platforms,
76 76 keywords = keywords,
77 77 cmdclass = {'install_data': install_data_ext},
78 78 )
79 79
80 80
81 81 #---------------------------------------------------------------------------
82 82 # Find packages
83 83 #---------------------------------------------------------------------------
84 84
85 85 def add_package(packages,pname,config=False,tests=False,scripts=False,
86 86 others=None):
87 87 """
88 88 Add a package to the list of packages, including certain subpackages.
89 89 """
90 90 packages.append('.'.join(['IPython',pname]))
91 91 if config:
92 92 packages.append('.'.join(['IPython',pname,'config']))
93 93 if tests:
94 94 packages.append('.'.join(['IPython',pname,'tests']))
95 95 if scripts:
96 96 packages.append('.'.join(['IPython',pname,'scripts']))
97 97 if others is not None:
98 98 for o in others:
99 99 packages.append('.'.join(['IPython',pname,o]))
100 100
101 101 def find_packages():
102 102 """
103 103 Find all of IPython's packages.
104 104 """
105 105 packages = ['IPython']
106 106 add_package(packages, 'config', tests=True)
107 107 add_package(packages , 'Extensions')
108 108 add_package(packages, 'external')
109 109 add_package(packages, 'gui')
110 110 add_package(packages, 'gui.wx')
111 111 add_package(packages, 'frontend', tests=True)
112 112 add_package(packages, 'frontend._process')
113 113 add_package(packages, 'frontend.wx')
114 114 add_package(packages, 'frontend.cocoa', tests=True)
115 115 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
116 116 add_package(packages, 'kernel.core', config=True, tests=True)
117 117 add_package(packages, 'testing', tests=True)
118 add_package(packages, 'tests')
118 119 add_package(packages, 'testing.plugin', tests=False)
119 120 add_package(packages, 'tools', tests=True)
120 121 add_package(packages, 'UserConfig')
121 122 return packages
122 123
123 124 #---------------------------------------------------------------------------
124 125 # Find package data
125 126 #---------------------------------------------------------------------------
126 127
127 128 def find_package_data():
128 129 """
129 130 Find IPython's package_data.
130 131 """
131 132 # This is not enough for these things to appear in an sdist.
132 133 # We need to muck with the MANIFEST to get this to work
133 134 package_data = {
134 135 'IPython.UserConfig' : ['*'],
135 136 'IPython.tools.tests' : ['*.txt'],
136 137 'IPython.testing' : ['*.txt']
137 138 }
138 139 return package_data
139 140
140 141
141 142 #---------------------------------------------------------------------------
142 143 # Find data files
143 144 #---------------------------------------------------------------------------
144 145
145 146 def make_dir_struct(tag,base,out_base):
146 147 """Make the directory structure of all files below a starting dir.
147 148
148 149 This is just a convenience routine to help build a nested directory
149 150 hierarchy because distutils is too stupid to do this by itself.
150 151
151 152 XXX - this needs a proper docstring!
152 153 """
153 154
154 155 # we'll use these a lot below
155 156 lbase = len(base)
156 157 pathsep = os.path.sep
157 158 lpathsep = len(pathsep)
158 159
159 160 out = []
160 161 for (dirpath,dirnames,filenames) in os.walk(base):
161 162 # we need to strip out the dirpath from the base to map it to the
162 163 # output (installation) path. This requires possibly stripping the
163 164 # path separator, because otherwise pjoin will not work correctly
164 165 # (pjoin('foo/','/bar') returns '/bar').
165 166
166 167 dp_eff = dirpath[lbase:]
167 168 if dp_eff.startswith(pathsep):
168 169 dp_eff = dp_eff[lpathsep:]
169 170 # The output path must be anchored at the out_base marker
170 171 out_path = pjoin(out_base,dp_eff)
171 172 # Now we can generate the final filenames. Since os.walk only produces
172 173 # filenames, we must join back with the dirpath to get full valid file
173 174 # paths:
174 175 pfiles = [pjoin(dirpath,f) for f in filenames]
175 176 # Finally, generate the entry we need, which is a triple of (tag,output
176 177 # path, files) for use as a data_files parameter in install_data.
177 178 out.append((tag,out_path,pfiles))
178 179
179 180 return out
180 181
181 182
182 183 def find_data_files():
183 184 """
184 185 Find IPython's data_files.
185 186
186 187 Most of these are docs.
187 188 """
188 189
189 190 docdirbase = 'share/doc/ipython'
190 191 manpagebase = 'share/man/man1'
191 192
192 193 # Simple file lists can be made by hand
193 194 manpages = filter(isfile, glob('docs/man/*.1.gz'))
194 195 igridhelpfiles = filter(isfile, glob('IPython/Extensions/igrid_help.*'))
195 196
196 197 # For nested structures, use the utility above
197 198 example_files = make_dir_struct('data','docs/examples',
198 199 pjoin(docdirbase,'examples'))
199 200 manual_files = make_dir_struct('data','docs/dist',pjoin(docdirbase,'manual'))
200 201
201 202 # And assemble the entire output list
202 203 data_files = [ ('data',manpagebase, manpages),
203 204 ('data',pjoin(docdirbase,'extensions'),igridhelpfiles),
204 205 ] + manual_files + example_files
205 206
206 207 ## import pprint # dbg
207 208 ## print '*'*80
208 209 ## print 'data files'
209 210 ## pprint.pprint(data_files)
210 211 ## print '*'*80
211 212
212 213 return data_files
213 214
214 215 #---------------------------------------------------------------------------
215 216 # Find scripts
216 217 #---------------------------------------------------------------------------
217 218
218 219 def find_scripts():
219 220 """
220 221 Find IPython's scripts.
221 222 """
222 223 scripts = ['IPython/kernel/scripts/ipengine',
223 224 'IPython/kernel/scripts/ipcontroller',
224 225 'IPython/kernel/scripts/ipcluster',
225 226 'scripts/ipython',
226 227 'scripts/ipythonx',
227 228 'scripts/ipython-wx',
228 229 'scripts/pycolor',
229 230 'scripts/irunner',
230 231 'scripts/iptest',
231 232 ]
232 233
233 234 # Script to be run by the windows binary installer after the default setup
234 235 # routine, to add shortcuts and similar windows-only things. Windows
235 236 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
236 237 # doesn't find them.
237 238 if 'bdist_wininst' in sys.argv:
238 239 if len(sys.argv) > 2 and ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
239 240 print >> sys.stderr,"ERROR: bdist_wininst must be run alone. Exiting."
240 241 sys.exit(1)
241 242 scripts.append('scripts/ipython_win_post_install.py')
242 243
243 244 return scripts
244 245
245 246 #---------------------------------------------------------------------------
246 247 # Verify all dependencies
247 248 #---------------------------------------------------------------------------
248 249
249 250 def check_for_dependencies():
250 251 """Check for IPython's dependencies.
251 252
252 253 This function should NOT be called if running under setuptools!
253 254 """
254 255 from setupext.setupext import (
255 256 print_line, print_raw, print_status, print_message,
256 257 check_for_zopeinterface, check_for_twisted,
257 258 check_for_foolscap, check_for_pyopenssl,
258 259 check_for_sphinx, check_for_pygments,
259 260 check_for_nose, check_for_pexpect
260 261 )
261 262 print_line()
262 263 print_raw("BUILDING IPYTHON")
263 264 print_status('python', sys.version)
264 265 print_status('platform', sys.platform)
265 266 if sys.platform == 'win32':
266 267 print_status('Windows version', sys.getwindowsversion())
267 268
268 269 print_raw("")
269 270 print_raw("OPTIONAL DEPENDENCIES")
270 271
271 272 check_for_zopeinterface()
272 273 check_for_twisted()
273 274 check_for_foolscap()
274 275 check_for_pyopenssl()
275 276 check_for_sphinx()
276 277 check_for_pygments()
277 278 check_for_nose()
278 279 check_for_pexpect()
General Comments 0
You need to be logged in to leave comments. Login now