##// END OF EJS Templates
Unbundle of all external modules....
Thomas Spura -
Show More
@@ -0,0 +1,4 b''
1 try:
2 from Itpl import *
3 except ImportError:
4 from _Itpl import *
@@ -0,0 +1,12 b''
1 try:
2 import argparse
3 # Workaround an argparse bug, FIXED in argparse 1.1.0
4 if 'RawTextHelpFormatterArgumentDefaultsHelpFormatter' in argparse.__all__:
5 import itertools
6 argparse.__all__ = list(itertools.chain( [i for i in argparse.__all__
7 if i != 'RawTextHelpFormatterArgumentDefaultsHelpFormatter'],
8 ['RawTextHelpFormatter', 'ArgumentDefaultsHelpFormatter']))
9 argparse.__all__.append('SUPPRESS')
10 from argparse import *
11 except ImportError:
12 from _argparse import *
@@ -0,0 +1,4 b''
1 try:
2 from configobj import *
3 except ImportError:
4 from _configobj import *
@@ -0,0 +1,8 b''
1 try:
2 from decorator import *
3 from decorator import getinfo, new_wrapper
4 # the following funcion is deprecated so using the python own one
5 from functools import update_wrapper
6 except ImportError:
7 from _decorator import *
8 from _decorator import getinfo, update_wrapper, new_wrapper
@@ -0,0 +1,4 b''
1 try:
2 from numpy.testing.decorators import *
3 except ImportError:
4 from _decorators.py import *
@@ -0,0 +1,4 b''
1 try:
2 from guid import *
3 except ImportError:
4 from _guid import *
@@ -0,0 +1,4 b''
1 try:
2 from mglob import *
3 except ImportError:
4 from _mglob import *
@@ -0,0 +1,4 b''
1 try:
2 from path import *
3 except ImportError:
4 from _path import *
@@ -0,0 +1,4 b''
1 try:
2 from pretty import *
3 except ImportError:
4 from _pretty import *
@@ -0,0 +1,4 b''
1 try:
2 from pyparsing import *
3 except ImportError:
4 from _pyparsing import *
@@ -0,0 +1,4 b''
1 try:
2 from simplegeneric import *
3 except ImportError:
4 from _simplegeneric import *
@@ -0,0 +1,8 b''
1 try:
2 import validate
3 if '__docformat__' in validate.__all__ and validate.__version__.split('.') >= ['1', '0', '1']:
4 # __docformat__ was removed in 1.0.1 but
5 validate.__all__ = [i for i in validate.__all__ if i != '__docformat__']
6 from validate import *
7 except ImportError:
8 from _validate import *
1 NO CONTENT: file renamed from IPython/external/Itpl.py to IPython/external/Itpl/_Itpl.py
NO CONTENT: file renamed from IPython/external/Itpl.py to IPython/external/Itpl/_Itpl.py
1 NO CONTENT: file renamed from IPython/external/argparse.py to IPython/external/argparse/_argparse.py
NO CONTENT: file renamed from IPython/external/argparse.py to IPython/external/argparse/_argparse.py
1 NO CONTENT: file renamed from IPython/external/configobj.py to IPython/external/configobj/_configobj.py
NO CONTENT: file renamed from IPython/external/configobj.py to IPython/external/configobj/_configobj.py
1 NO CONTENT: file renamed from IPython/external/decorator.py to IPython/external/decorator/_decorator.py
NO CONTENT: file renamed from IPython/external/decorator.py to IPython/external/decorator/_decorator.py
1 NO CONTENT: file renamed from IPython/external/decorators.py to IPython/external/decorators/_decorators.py
NO CONTENT: file renamed from IPython/external/decorators.py to IPython/external/decorators/_decorators.py
1 NO CONTENT: file renamed from IPython/external/_numpy_testing_utils.py to IPython/external/decorators/_numpy_testing_utils.py
NO CONTENT: file renamed from IPython/external/_numpy_testing_utils.py to IPython/external/decorators/_numpy_testing_utils.py
1 NO CONTENT: file renamed from IPython/external/guid.py to IPython/external/guid/_guid.py
NO CONTENT: file renamed from IPython/external/guid.py to IPython/external/guid/_guid.py
1 NO CONTENT: file renamed from IPython/external/mglob.py to IPython/external/mglob/_mglob.py
NO CONTENT: file renamed from IPython/external/mglob.py to IPython/external/mglob/_mglob.py
1 NO CONTENT: file renamed from IPython/external/path.py to IPython/external/path/_path.py
NO CONTENT: file renamed from IPython/external/path.py to IPython/external/path/_path.py
1 NO CONTENT: file renamed from IPython/external/pretty.py to IPython/external/pretty/_pretty.py
NO CONTENT: file renamed from IPython/external/pretty.py to IPython/external/pretty/_pretty.py
1 NO CONTENT: file renamed from IPython/external/pyparsing.py to IPython/external/pyparsing/_pyparsing.py
NO CONTENT: file renamed from IPython/external/pyparsing.py to IPython/external/pyparsing/_pyparsing.py
1 NO CONTENT: file renamed from IPython/external/simplegeneric.py to IPython/external/simplegeneric/_simplegeneric.py
NO CONTENT: file renamed from IPython/external/simplegeneric.py to IPython/external/simplegeneric/_simplegeneric.py
1 NO CONTENT: file renamed from IPython/external/validate.py to IPython/external/validate/_validate.py
NO CONTENT: file renamed from IPython/external/validate.py to IPython/external/validate/_validate.py
@@ -1,369 +1,381 b''
1 # encoding: utf-8
1 # encoding: utf-8
2 """
2 """
3 This module defines the things that are used in setup.py for building IPython
3 This module defines the things that are used in setup.py for building IPython
4
4
5 This includes:
5 This includes:
6
6
7 * The basic arguments to setup
7 * The basic arguments to setup
8 * Functions for finding things like packages, package data, etc.
8 * Functions for finding things like packages, package data, etc.
9 * A function for checking dependencies.
9 * A function for checking dependencies.
10 """
10 """
11 from __future__ import print_function
11 from __future__ import print_function
12
12
13 #-------------------------------------------------------------------------------
13 #-------------------------------------------------------------------------------
14 # Copyright (C) 2008 The IPython Development Team
14 # Copyright (C) 2008 The IPython Development Team
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #-------------------------------------------------------------------------------
18 #-------------------------------------------------------------------------------
19
19
20 #-------------------------------------------------------------------------------
20 #-------------------------------------------------------------------------------
21 # Imports
21 # Imports
22 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
23 import os
23 import os
24 import sys
24 import sys
25
25
26 from ConfigParser import ConfigParser
26 from ConfigParser import ConfigParser
27 from distutils.command.build_py import build_py
27 from distutils.command.build_py import build_py
28 from glob import glob
28 from glob import glob
29
29
30 from setupext import install_data_ext
30 from setupext import install_data_ext
31
31
32 #-------------------------------------------------------------------------------
32 #-------------------------------------------------------------------------------
33 # Useful globals and utility functions
33 # Useful globals and utility functions
34 #-------------------------------------------------------------------------------
34 #-------------------------------------------------------------------------------
35
35
36 # A few handy globals
36 # A few handy globals
37 isfile = os.path.isfile
37 isfile = os.path.isfile
38 pjoin = os.path.join
38 pjoin = os.path.join
39
39
40 def oscmd(s):
40 def oscmd(s):
41 print(">", s)
41 print(">", s)
42 os.system(s)
42 os.system(s)
43
43
44 # A little utility we'll need below, since glob() does NOT allow you to do
44 # A little utility we'll need below, since glob() does NOT allow you to do
45 # exclusion on multiple endings!
45 # exclusion on multiple endings!
46 def file_doesnt_endwith(test,endings):
46 def file_doesnt_endwith(test,endings):
47 """Return true if test is a file and its name does NOT end with any
47 """Return true if test is a file and its name does NOT end with any
48 of the strings listed in endings."""
48 of the strings listed in endings."""
49 if not isfile(test):
49 if not isfile(test):
50 return False
50 return False
51 for e in endings:
51 for e in endings:
52 if test.endswith(e):
52 if test.endswith(e):
53 return False
53 return False
54 return True
54 return True
55
55
56 #---------------------------------------------------------------------------
56 #---------------------------------------------------------------------------
57 # Basic project information
57 # Basic project information
58 #---------------------------------------------------------------------------
58 #---------------------------------------------------------------------------
59
59
60 # release.py contains version, authors, license, url, keywords, etc.
60 # release.py contains version, authors, license, url, keywords, etc.
61 execfile(pjoin('IPython','core','release.py'))
61 execfile(pjoin('IPython','core','release.py'))
62
62
63 # Create a dict with the basic information
63 # Create a dict with the basic information
64 # This dict is eventually passed to setup after additional keys are added.
64 # This dict is eventually passed to setup after additional keys are added.
65 setup_args = dict(
65 setup_args = dict(
66 name = name,
66 name = name,
67 version = version,
67 version = version,
68 description = description,
68 description = description,
69 long_description = long_description,
69 long_description = long_description,
70 author = author,
70 author = author,
71 author_email = author_email,
71 author_email = author_email,
72 url = url,
72 url = url,
73 download_url = download_url,
73 download_url = download_url,
74 license = license,
74 license = license,
75 platforms = platforms,
75 platforms = platforms,
76 keywords = keywords,
76 keywords = keywords,
77 cmdclass = {'install_data': install_data_ext},
77 cmdclass = {'install_data': install_data_ext},
78 )
78 )
79
79
80
80
81 #---------------------------------------------------------------------------
81 #---------------------------------------------------------------------------
82 # Find packages
82 # Find packages
83 #---------------------------------------------------------------------------
83 #---------------------------------------------------------------------------
84
84
85 def add_package(packages,pname,config=False,tests=False,scripts=False,
85 def add_package(packages,pname,config=False,tests=False,scripts=False,
86 others=None):
86 others=None):
87 """
87 """
88 Add a package to the list of packages, including certain subpackages.
88 Add a package to the list of packages, including certain subpackages.
89 """
89 """
90 packages.append('.'.join(['IPython',pname]))
90 packages.append('.'.join(['IPython',pname]))
91 if config:
91 if config:
92 packages.append('.'.join(['IPython',pname,'config']))
92 packages.append('.'.join(['IPython',pname,'config']))
93 if tests:
93 if tests:
94 packages.append('.'.join(['IPython',pname,'tests']))
94 packages.append('.'.join(['IPython',pname,'tests']))
95 if scripts:
95 if scripts:
96 packages.append('.'.join(['IPython',pname,'scripts']))
96 packages.append('.'.join(['IPython',pname,'scripts']))
97 if others is not None:
97 if others is not None:
98 for o in others:
98 for o in others:
99 packages.append('.'.join(['IPython',pname,o]))
99 packages.append('.'.join(['IPython',pname,o]))
100
100
101 def find_packages():
101 def find_packages():
102 """
102 """
103 Find all of IPython's packages.
103 Find all of IPython's packages.
104 """
104 """
105 packages = ['IPython']
105 packages = ['IPython']
106 add_package(packages, 'config', tests=True, others=['default','profile'])
106 add_package(packages, 'config', tests=True, others=['default','profile'])
107 add_package(packages, 'core', tests=True)
107 add_package(packages, 'core', tests=True)
108 add_package(packages, 'deathrow', tests=True)
108 add_package(packages, 'deathrow', tests=True)
109 add_package(packages, 'extensions')
109 add_package(packages, 'extensions')
110 add_package(packages, 'external')
110 add_package(packages, 'external')
111 add_package(packages, 'external.argparse')
112 add_package(packages, 'external.configobj')
113 add_package(packages, 'external.decorator')
114 add_package(packages, 'external.decorators')
115 add_package(packages, 'external.guid')
116 add_package(packages, 'external.Itpl')
117 add_package(packages, 'external.mglob')
118 add_package(packages, 'external.path')
119 add_package(packages, 'external.pretty')
120 add_package(packages, 'external.pyparsing')
121 add_package(packages, 'external.simplegeneric')
122 add_package(packages, 'external.validate')
111 add_package(packages, 'frontend')
123 add_package(packages, 'frontend')
112 add_package(packages, 'frontend.qt')
124 add_package(packages, 'frontend.qt')
113 add_package(packages, 'frontend.qt.console', tests=True)
125 add_package(packages, 'frontend.qt.console', tests=True)
114 add_package(packages, 'frontend.terminal', tests=True)
126 add_package(packages, 'frontend.terminal', tests=True)
115 add_package(packages, 'kernel', config=False, tests=True, scripts=True)
127 add_package(packages, 'kernel', config=False, tests=True, scripts=True)
116 add_package(packages, 'kernel.core', config=False, tests=True)
128 add_package(packages, 'kernel.core', config=False, tests=True)
117 add_package(packages, 'lib', tests=True)
129 add_package(packages, 'lib', tests=True)
118 add_package(packages, 'quarantine', tests=True)
130 add_package(packages, 'quarantine', tests=True)
119 add_package(packages, 'scripts')
131 add_package(packages, 'scripts')
120 add_package(packages, 'testing', tests=True)
132 add_package(packages, 'testing', tests=True)
121 add_package(packages, 'testing.plugin', tests=False)
133 add_package(packages, 'testing.plugin', tests=False)
122 add_package(packages, 'utils', tests=True)
134 add_package(packages, 'utils', tests=True)
123 add_package(packages, 'zmq')
135 add_package(packages, 'zmq')
124 add_package(packages, 'zmq.pylab')
136 add_package(packages, 'zmq.pylab')
125 return packages
137 return packages
126
138
127 #---------------------------------------------------------------------------
139 #---------------------------------------------------------------------------
128 # Find package data
140 # Find package data
129 #---------------------------------------------------------------------------
141 #---------------------------------------------------------------------------
130
142
131 def find_package_data():
143 def find_package_data():
132 """
144 """
133 Find IPython's package_data.
145 Find IPython's package_data.
134 """
146 """
135 # This is not enough for these things to appear in an sdist.
147 # This is not enough for these things to appear in an sdist.
136 # We need to muck with the MANIFEST to get this to work
148 # We need to muck with the MANIFEST to get this to work
137 package_data = {
149 package_data = {
138 'IPython.config.userconfig' : ['*'],
150 'IPython.config.userconfig' : ['*'],
139 'IPython.testing' : ['*.txt']
151 'IPython.testing' : ['*.txt']
140 }
152 }
141 return package_data
153 return package_data
142
154
143
155
144 #---------------------------------------------------------------------------
156 #---------------------------------------------------------------------------
145 # Find data files
157 # Find data files
146 #---------------------------------------------------------------------------
158 #---------------------------------------------------------------------------
147
159
148 def make_dir_struct(tag,base,out_base):
160 def make_dir_struct(tag,base,out_base):
149 """Make the directory structure of all files below a starting dir.
161 """Make the directory structure of all files below a starting dir.
150
162
151 This is just a convenience routine to help build a nested directory
163 This is just a convenience routine to help build a nested directory
152 hierarchy because distutils is too stupid to do this by itself.
164 hierarchy because distutils is too stupid to do this by itself.
153
165
154 XXX - this needs a proper docstring!
166 XXX - this needs a proper docstring!
155 """
167 """
156
168
157 # we'll use these a lot below
169 # we'll use these a lot below
158 lbase = len(base)
170 lbase = len(base)
159 pathsep = os.path.sep
171 pathsep = os.path.sep
160 lpathsep = len(pathsep)
172 lpathsep = len(pathsep)
161
173
162 out = []
174 out = []
163 for (dirpath,dirnames,filenames) in os.walk(base):
175 for (dirpath,dirnames,filenames) in os.walk(base):
164 # we need to strip out the dirpath from the base to map it to the
176 # we need to strip out the dirpath from the base to map it to the
165 # output (installation) path. This requires possibly stripping the
177 # output (installation) path. This requires possibly stripping the
166 # path separator, because otherwise pjoin will not work correctly
178 # path separator, because otherwise pjoin will not work correctly
167 # (pjoin('foo/','/bar') returns '/bar').
179 # (pjoin('foo/','/bar') returns '/bar').
168
180
169 dp_eff = dirpath[lbase:]
181 dp_eff = dirpath[lbase:]
170 if dp_eff.startswith(pathsep):
182 if dp_eff.startswith(pathsep):
171 dp_eff = dp_eff[lpathsep:]
183 dp_eff = dp_eff[lpathsep:]
172 # The output path must be anchored at the out_base marker
184 # The output path must be anchored at the out_base marker
173 out_path = pjoin(out_base,dp_eff)
185 out_path = pjoin(out_base,dp_eff)
174 # Now we can generate the final filenames. Since os.walk only produces
186 # Now we can generate the final filenames. Since os.walk only produces
175 # filenames, we must join back with the dirpath to get full valid file
187 # filenames, we must join back with the dirpath to get full valid file
176 # paths:
188 # paths:
177 pfiles = [pjoin(dirpath,f) for f in filenames]
189 pfiles = [pjoin(dirpath,f) for f in filenames]
178 # Finally, generate the entry we need, which is a pari of (output
190 # Finally, generate the entry we need, which is a pari of (output
179 # path, files) for use as a data_files parameter in install_data.
191 # path, files) for use as a data_files parameter in install_data.
180 out.append((out_path, pfiles))
192 out.append((out_path, pfiles))
181
193
182 return out
194 return out
183
195
184
196
185 def find_data_files():
197 def find_data_files():
186 """
198 """
187 Find IPython's data_files.
199 Find IPython's data_files.
188
200
189 Most of these are docs.
201 Most of these are docs.
190 """
202 """
191
203
192 docdirbase = pjoin('share', 'doc', 'ipython')
204 docdirbase = pjoin('share', 'doc', 'ipython')
193 manpagebase = pjoin('share', 'man', 'man1')
205 manpagebase = pjoin('share', 'man', 'man1')
194
206
195 # Simple file lists can be made by hand
207 # Simple file lists can be made by hand
196 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
208 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
197 igridhelpfiles = filter(isfile,
209 igridhelpfiles = filter(isfile,
198 glob(pjoin('IPython','extensions','igrid_help.*')))
210 glob(pjoin('IPython','extensions','igrid_help.*')))
199
211
200 # For nested structures, use the utility above
212 # For nested structures, use the utility above
201 example_files = make_dir_struct(
213 example_files = make_dir_struct(
202 'data',
214 'data',
203 pjoin('docs','examples'),
215 pjoin('docs','examples'),
204 pjoin(docdirbase,'examples')
216 pjoin(docdirbase,'examples')
205 )
217 )
206 manual_files = make_dir_struct(
218 manual_files = make_dir_struct(
207 'data',
219 'data',
208 pjoin('docs','dist'),
220 pjoin('docs','dist'),
209 pjoin(docdirbase,'manual')
221 pjoin(docdirbase,'manual')
210 )
222 )
211
223
212 # And assemble the entire output list
224 # And assemble the entire output list
213 data_files = [ (manpagebase, manpages),
225 data_files = [ (manpagebase, manpages),
214 (pjoin(docdirbase, 'extensions'), igridhelpfiles),
226 (pjoin(docdirbase, 'extensions'), igridhelpfiles),
215 ] + manual_files + example_files
227 ] + manual_files + example_files
216
228
217 return data_files
229 return data_files
218
230
219
231
220 def make_man_update_target(manpage):
232 def make_man_update_target(manpage):
221 """Return a target_update-compliant tuple for the given manpage.
233 """Return a target_update-compliant tuple for the given manpage.
222
234
223 Parameters
235 Parameters
224 ----------
236 ----------
225 manpage : string
237 manpage : string
226 Name of the manpage, must include the section number (trailing number).
238 Name of the manpage, must include the section number (trailing number).
227
239
228 Example
240 Example
229 -------
241 -------
230
242
231 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
243 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
232 ('docs/man/ipython.1.gz',
244 ('docs/man/ipython.1.gz',
233 ['docs/man/ipython.1'],
245 ['docs/man/ipython.1'],
234 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
246 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
235 """
247 """
236 man_dir = pjoin('docs', 'man')
248 man_dir = pjoin('docs', 'man')
237 manpage_gz = manpage + '.gz'
249 manpage_gz = manpage + '.gz'
238 manpath = pjoin(man_dir, manpage)
250 manpath = pjoin(man_dir, manpage)
239 manpath_gz = pjoin(man_dir, manpage_gz)
251 manpath_gz = pjoin(man_dir, manpage_gz)
240 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
252 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
241 locals() )
253 locals() )
242 return (manpath_gz, [manpath], gz_cmd)
254 return (manpath_gz, [manpath], gz_cmd)
243
255
244 #---------------------------------------------------------------------------
256 #---------------------------------------------------------------------------
245 # Find scripts
257 # Find scripts
246 #---------------------------------------------------------------------------
258 #---------------------------------------------------------------------------
247
259
248 def find_scripts():
260 def find_scripts():
249 """
261 """
250 Find IPython's scripts.
262 Find IPython's scripts.
251 """
263 """
252 kernel_scripts = pjoin('IPython','kernel','scripts')
264 kernel_scripts = pjoin('IPython','kernel','scripts')
253 main_scripts = pjoin('IPython','scripts')
265 main_scripts = pjoin('IPython','scripts')
254 scripts = [pjoin(kernel_scripts, 'ipengine'),
266 scripts = [pjoin(kernel_scripts, 'ipengine'),
255 pjoin(kernel_scripts, 'ipcontroller'),
267 pjoin(kernel_scripts, 'ipcontroller'),
256 pjoin(kernel_scripts, 'ipcluster'),
268 pjoin(kernel_scripts, 'ipcluster'),
257 pjoin(main_scripts, 'ipython'),
269 pjoin(main_scripts, 'ipython'),
258 pjoin(main_scripts, 'ipython-qtconsole'),
270 pjoin(main_scripts, 'ipython-qtconsole'),
259 pjoin(main_scripts, 'pycolor'),
271 pjoin(main_scripts, 'pycolor'),
260 pjoin(main_scripts, 'irunner'),
272 pjoin(main_scripts, 'irunner'),
261 pjoin(main_scripts, 'iptest')
273 pjoin(main_scripts, 'iptest')
262 ]
274 ]
263
275
264 # Script to be run by the windows binary installer after the default setup
276 # Script to be run by the windows binary installer after the default setup
265 # routine, to add shortcuts and similar windows-only things. Windows
277 # routine, to add shortcuts and similar windows-only things. Windows
266 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
278 # post-install scripts MUST reside in the scripts/ dir, otherwise distutils
267 # doesn't find them.
279 # doesn't find them.
268 if 'bdist_wininst' in sys.argv:
280 if 'bdist_wininst' in sys.argv:
269 if len(sys.argv) > 2 and \
281 if len(sys.argv) > 2 and \
270 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
282 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
271 print("ERROR: bdist_wininst must be run alone. Exiting.",
283 print("ERROR: bdist_wininst must be run alone. Exiting.",
272 file=sys.stderr)
284 file=sys.stderr)
273 sys.exit(1)
285 sys.exit(1)
274 scripts.append(pjoin('scripts','ipython_win_post_install.py'))
286 scripts.append(pjoin('scripts','ipython_win_post_install.py'))
275
287
276 return scripts
288 return scripts
277
289
278 #---------------------------------------------------------------------------
290 #---------------------------------------------------------------------------
279 # Verify all dependencies
291 # Verify all dependencies
280 #---------------------------------------------------------------------------
292 #---------------------------------------------------------------------------
281
293
282 def check_for_dependencies():
294 def check_for_dependencies():
283 """Check for IPython's dependencies.
295 """Check for IPython's dependencies.
284
296
285 This function should NOT be called if running under setuptools!
297 This function should NOT be called if running under setuptools!
286 """
298 """
287 from setupext.setupext import (
299 from setupext.setupext import (
288 print_line, print_raw, print_status,
300 print_line, print_raw, print_status,
289 check_for_zopeinterface, check_for_twisted,
301 check_for_zopeinterface, check_for_twisted,
290 check_for_foolscap, check_for_pyopenssl,
302 check_for_foolscap, check_for_pyopenssl,
291 check_for_sphinx, check_for_pygments,
303 check_for_sphinx, check_for_pygments,
292 check_for_nose, check_for_pexpect
304 check_for_nose, check_for_pexpect
293 )
305 )
294 print_line()
306 print_line()
295 print_raw("BUILDING IPYTHON")
307 print_raw("BUILDING IPYTHON")
296 print_status('python', sys.version)
308 print_status('python', sys.version)
297 print_status('platform', sys.platform)
309 print_status('platform', sys.platform)
298 if sys.platform == 'win32':
310 if sys.platform == 'win32':
299 print_status('Windows version', sys.getwindowsversion())
311 print_status('Windows version', sys.getwindowsversion())
300
312
301 print_raw("")
313 print_raw("")
302 print_raw("OPTIONAL DEPENDENCIES")
314 print_raw("OPTIONAL DEPENDENCIES")
303
315
304 check_for_zopeinterface()
316 check_for_zopeinterface()
305 check_for_twisted()
317 check_for_twisted()
306 check_for_foolscap()
318 check_for_foolscap()
307 check_for_pyopenssl()
319 check_for_pyopenssl()
308 check_for_sphinx()
320 check_for_sphinx()
309 check_for_pygments()
321 check_for_pygments()
310 check_for_nose()
322 check_for_nose()
311 check_for_pexpect()
323 check_for_pexpect()
312
324
313
325
314 def record_commit_info(pkg_dir, build_cmd=build_py):
326 def record_commit_info(pkg_dir, build_cmd=build_py):
315 """ Return extended build command class for recording commit
327 """ Return extended build command class for recording commit
316
328
317 The extended command tries to run git to find the current commit, getting
329 The extended command tries to run git to find the current commit, getting
318 the empty string if it fails. It then writes the commit hash into a file
330 the empty string if it fails. It then writes the commit hash into a file
319 in the `pkg_dir` path, named ``.git_commit_info.ini``.
331 in the `pkg_dir` path, named ``.git_commit_info.ini``.
320
332
321 In due course this information can be used by the package after it is
333 In due course this information can be used by the package after it is
322 installed, to tell you what commit it was installed from if known.
334 installed, to tell you what commit it was installed from if known.
323
335
324 To make use of this system, you need a package with a .git_commit_info.ini
336 To make use of this system, you need a package with a .git_commit_info.ini
325 file - e.g. ``myproject/.git_commit_info.ini`` - that might well look like
337 file - e.g. ``myproject/.git_commit_info.ini`` - that might well look like
326 this::
338 this::
327
339
328 # This is an ini file that may contain information about the code state
340 # This is an ini file that may contain information about the code state
329 [commit hash]
341 [commit hash]
330 # The line below may contain a valid hash if it has been substituted
342 # The line below may contain a valid hash if it has been substituted
331 # during 'git archive'
343 # during 'git archive'
332 archive_subst_hash=$Format:%h$
344 archive_subst_hash=$Format:%h$
333 # This line may be modified by the install process
345 # This line may be modified by the install process
334 install_hash=
346 install_hash=
335
347
336 The .git_commit_info file above is also designed to be used with git
348 The .git_commit_info file above is also designed to be used with git
337 substitution - so you probably also want a ``.gitattributes`` file in the
349 substitution - so you probably also want a ``.gitattributes`` file in the
338 root directory of your working tree that contains something like this::
350 root directory of your working tree that contains something like this::
339
351
340 myproject/.git_commit_info.ini export-subst
352 myproject/.git_commit_info.ini export-subst
341
353
342 That will cause the ``.git_commit_info.ini`` file to get filled in by ``git
354 That will cause the ``.git_commit_info.ini`` file to get filled in by ``git
343 archive`` - useful in case someone makes such an archive - for example with
355 archive`` - useful in case someone makes such an archive - for example with
344 via the github 'download source' button.
356 via the github 'download source' button.
345
357
346 Although all the above will work as is, you might consider having something
358 Although all the above will work as is, you might consider having something
347 like a ``get_info()`` function in your package to display the commit
359 like a ``get_info()`` function in your package to display the commit
348 information at the terminal. See the ``pkg_info.py`` module in the nipy
360 information at the terminal. See the ``pkg_info.py`` module in the nipy
349 package for an example.
361 package for an example.
350 """
362 """
351 class MyBuildPy(build_cmd):
363 class MyBuildPy(build_cmd):
352 ''' Subclass to write commit data into installation tree '''
364 ''' Subclass to write commit data into installation tree '''
353 def run(self):
365 def run(self):
354 build_py.run(self)
366 build_py.run(self)
355 import subprocess
367 import subprocess
356 proc = subprocess.Popen('git rev-parse --short HEAD',
368 proc = subprocess.Popen('git rev-parse --short HEAD',
357 stdout=subprocess.PIPE,
369 stdout=subprocess.PIPE,
358 stderr=subprocess.PIPE,
370 stderr=subprocess.PIPE,
359 shell=True)
371 shell=True)
360 repo_commit, _ = proc.communicate()
372 repo_commit, _ = proc.communicate()
361 # We write the installation commit even if it's empty
373 # We write the installation commit even if it's empty
362 cfg_parser = ConfigParser()
374 cfg_parser = ConfigParser()
363 cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini'))
375 cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini'))
364 cfg_parser.set('commit hash', 'install_hash', repo_commit)
376 cfg_parser.set('commit hash', 'install_hash', repo_commit)
365 out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini')
377 out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini')
366 out_file = open(out_pth, 'wt')
378 out_file = open(out_pth, 'wt')
367 cfg_parser.write(out_file)
379 cfg_parser.write(out_file)
368 out_file.close()
380 out_file.close()
369 return MyBuildPy
381 return MyBuildPy
General Comments 0
You need to be logged in to leave comments. Login now