##// END OF EJS Templates
Emergency fix for py3 breakage introduced in 576f6f (merge of #1538)...
Fernando Perez -
Show More
@@ -1,2 +1,2 b''
1 # GENERATED BY setup.py
1 # GENERATED BY setup.py
2 commit = ''
2 commit = ""
@@ -1,396 +1,404 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 io
23 import io
24 import os
24 import os
25 import sys
25 import sys
26
26
27 try:
27 try:
28 from configparser import ConfigParser
28 from configparser import ConfigParser
29 except:
29 except:
30 from ConfigParser import ConfigParser
30 from ConfigParser import ConfigParser
31 from distutils.command.build_py import build_py
31 from distutils.command.build_py import build_py
32 from glob import glob
32 from glob import glob
33
33
34 from setupext import install_data_ext
34 from setupext import install_data_ext
35
35
36 #-------------------------------------------------------------------------------
36 #-------------------------------------------------------------------------------
37 # Useful globals and utility functions
37 # Useful globals and utility functions
38 #-------------------------------------------------------------------------------
38 #-------------------------------------------------------------------------------
39
39
40 # A few handy globals
40 # A few handy globals
41 isfile = os.path.isfile
41 isfile = os.path.isfile
42 pjoin = os.path.join
42 pjoin = os.path.join
43
43
44 def oscmd(s):
44 def oscmd(s):
45 print(">", s)
45 print(">", s)
46 os.system(s)
46 os.system(s)
47
47
48 # Py3 compatibility hacks, without assuming IPython itself is installed with
49 # the full py3compat machinery.
50
48 try:
51 try:
49 execfile
52 execfile
50 except NameError:
53 except NameError:
51 def execfile(fname, globs, locs=None):
54 def execfile(fname, globs, locs=None):
52 locs = locs or globs
55 locs = locs or globs
53 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
56 exec(compile(open(fname).read(), fname, "exec"), globs, locs)
54
57
58 try:
59 unicode
60 except NameError:
61 unicode = str
62
55 # A little utility we'll need below, since glob() does NOT allow you to do
63 # A little utility we'll need below, since glob() does NOT allow you to do
56 # exclusion on multiple endings!
64 # exclusion on multiple endings!
57 def file_doesnt_endwith(test,endings):
65 def file_doesnt_endwith(test,endings):
58 """Return true if test is a file and its name does NOT end with any
66 """Return true if test is a file and its name does NOT end with any
59 of the strings listed in endings."""
67 of the strings listed in endings."""
60 if not isfile(test):
68 if not isfile(test):
61 return False
69 return False
62 for e in endings:
70 for e in endings:
63 if test.endswith(e):
71 if test.endswith(e):
64 return False
72 return False
65 return True
73 return True
66
74
67 #---------------------------------------------------------------------------
75 #---------------------------------------------------------------------------
68 # Basic project information
76 # Basic project information
69 #---------------------------------------------------------------------------
77 #---------------------------------------------------------------------------
70
78
71 # release.py contains version, authors, license, url, keywords, etc.
79 # release.py contains version, authors, license, url, keywords, etc.
72 execfile(pjoin('IPython','core','release.py'), globals())
80 execfile(pjoin('IPython','core','release.py'), globals())
73
81
74 # Create a dict with the basic information
82 # Create a dict with the basic information
75 # This dict is eventually passed to setup after additional keys are added.
83 # This dict is eventually passed to setup after additional keys are added.
76 setup_args = dict(
84 setup_args = dict(
77 name = name,
85 name = name,
78 version = version,
86 version = version,
79 description = description,
87 description = description,
80 long_description = long_description,
88 long_description = long_description,
81 author = author,
89 author = author,
82 author_email = author_email,
90 author_email = author_email,
83 url = url,
91 url = url,
84 download_url = download_url,
92 download_url = download_url,
85 license = license,
93 license = license,
86 platforms = platforms,
94 platforms = platforms,
87 keywords = keywords,
95 keywords = keywords,
88 classifiers = classifiers,
96 classifiers = classifiers,
89 cmdclass = {'install_data': install_data_ext},
97 cmdclass = {'install_data': install_data_ext},
90 )
98 )
91
99
92
100
93 #---------------------------------------------------------------------------
101 #---------------------------------------------------------------------------
94 # Find packages
102 # Find packages
95 #---------------------------------------------------------------------------
103 #---------------------------------------------------------------------------
96
104
97 def find_packages():
105 def find_packages():
98 """
106 """
99 Find all of IPython's packages.
107 Find all of IPython's packages.
100 """
108 """
101 excludes = ['deathrow']
109 excludes = ['deathrow']
102 packages = []
110 packages = []
103 for dir,subdirs,files in os.walk('IPython'):
111 for dir,subdirs,files in os.walk('IPython'):
104 package = dir.replace(os.path.sep, '.')
112 package = dir.replace(os.path.sep, '.')
105 if any([ package.startswith('IPython.'+exc) for exc in excludes ]):
113 if any([ package.startswith('IPython.'+exc) for exc in excludes ]):
106 # package is to be excluded (e.g. deathrow)
114 # package is to be excluded (e.g. deathrow)
107 continue
115 continue
108 if '__init__.py' not in files:
116 if '__init__.py' not in files:
109 # not a package
117 # not a package
110 continue
118 continue
111 packages.append(package)
119 packages.append(package)
112 return packages
120 return packages
113
121
114 #---------------------------------------------------------------------------
122 #---------------------------------------------------------------------------
115 # Find package data
123 # Find package data
116 #---------------------------------------------------------------------------
124 #---------------------------------------------------------------------------
117
125
118 def find_package_data():
126 def find_package_data():
119 """
127 """
120 Find IPython's package_data.
128 Find IPython's package_data.
121 """
129 """
122 # This is not enough for these things to appear in an sdist.
130 # This is not enough for these things to appear in an sdist.
123 # We need to muck with the MANIFEST to get this to work
131 # We need to muck with the MANIFEST to get this to work
124
132
125 # exclude static things that we don't ship (e.g. mathjax)
133 # exclude static things that we don't ship (e.g. mathjax)
126 excludes = ['mathjax']
134 excludes = ['mathjax']
127
135
128 # add 'static/' prefix to exclusions, and tuplify for use in startswith
136 # add 'static/' prefix to exclusions, and tuplify for use in startswith
129 excludes = tuple([os.path.join('static', ex) for ex in excludes])
137 excludes = tuple([os.path.join('static', ex) for ex in excludes])
130
138
131 # walk notebook resources:
139 # walk notebook resources:
132 cwd = os.getcwd()
140 cwd = os.getcwd()
133 os.chdir(os.path.join('IPython', 'frontend', 'html', 'notebook'))
141 os.chdir(os.path.join('IPython', 'frontend', 'html', 'notebook'))
134 static_walk = list(os.walk('static'))
142 static_walk = list(os.walk('static'))
135 os.chdir(cwd)
143 os.chdir(cwd)
136 static_data = []
144 static_data = []
137 for parent, dirs, files in static_walk:
145 for parent, dirs, files in static_walk:
138 if parent.startswith(excludes):
146 if parent.startswith(excludes):
139 continue
147 continue
140 for f in files:
148 for f in files:
141 static_data.append(os.path.join(parent, f))
149 static_data.append(os.path.join(parent, f))
142
150
143 package_data = {
151 package_data = {
144 'IPython.config.profile' : ['README*', '*/*.py'],
152 'IPython.config.profile' : ['README*', '*/*.py'],
145 'IPython.testing' : ['*.txt'],
153 'IPython.testing' : ['*.txt'],
146 'IPython.frontend.html.notebook' : ['templates/*'] + static_data,
154 'IPython.frontend.html.notebook' : ['templates/*'] + static_data,
147 'IPython.frontend.qt.console' : ['resources/icon/*.svg'],
155 'IPython.frontend.qt.console' : ['resources/icon/*.svg'],
148 }
156 }
149 return package_data
157 return package_data
150
158
151
159
152 #---------------------------------------------------------------------------
160 #---------------------------------------------------------------------------
153 # Find data files
161 # Find data files
154 #---------------------------------------------------------------------------
162 #---------------------------------------------------------------------------
155
163
156 def make_dir_struct(tag,base,out_base):
164 def make_dir_struct(tag,base,out_base):
157 """Make the directory structure of all files below a starting dir.
165 """Make the directory structure of all files below a starting dir.
158
166
159 This is just a convenience routine to help build a nested directory
167 This is just a convenience routine to help build a nested directory
160 hierarchy because distutils is too stupid to do this by itself.
168 hierarchy because distutils is too stupid to do this by itself.
161
169
162 XXX - this needs a proper docstring!
170 XXX - this needs a proper docstring!
163 """
171 """
164
172
165 # we'll use these a lot below
173 # we'll use these a lot below
166 lbase = len(base)
174 lbase = len(base)
167 pathsep = os.path.sep
175 pathsep = os.path.sep
168 lpathsep = len(pathsep)
176 lpathsep = len(pathsep)
169
177
170 out = []
178 out = []
171 for (dirpath,dirnames,filenames) in os.walk(base):
179 for (dirpath,dirnames,filenames) in os.walk(base):
172 # we need to strip out the dirpath from the base to map it to the
180 # we need to strip out the dirpath from the base to map it to the
173 # output (installation) path. This requires possibly stripping the
181 # output (installation) path. This requires possibly stripping the
174 # path separator, because otherwise pjoin will not work correctly
182 # path separator, because otherwise pjoin will not work correctly
175 # (pjoin('foo/','/bar') returns '/bar').
183 # (pjoin('foo/','/bar') returns '/bar').
176
184
177 dp_eff = dirpath[lbase:]
185 dp_eff = dirpath[lbase:]
178 if dp_eff.startswith(pathsep):
186 if dp_eff.startswith(pathsep):
179 dp_eff = dp_eff[lpathsep:]
187 dp_eff = dp_eff[lpathsep:]
180 # The output path must be anchored at the out_base marker
188 # The output path must be anchored at the out_base marker
181 out_path = pjoin(out_base,dp_eff)
189 out_path = pjoin(out_base,dp_eff)
182 # Now we can generate the final filenames. Since os.walk only produces
190 # Now we can generate the final filenames. Since os.walk only produces
183 # filenames, we must join back with the dirpath to get full valid file
191 # filenames, we must join back with the dirpath to get full valid file
184 # paths:
192 # paths:
185 pfiles = [pjoin(dirpath,f) for f in filenames]
193 pfiles = [pjoin(dirpath,f) for f in filenames]
186 # Finally, generate the entry we need, which is a pari of (output
194 # Finally, generate the entry we need, which is a pari of (output
187 # path, files) for use as a data_files parameter in install_data.
195 # path, files) for use as a data_files parameter in install_data.
188 out.append((out_path, pfiles))
196 out.append((out_path, pfiles))
189
197
190 return out
198 return out
191
199
192
200
193 def find_data_files():
201 def find_data_files():
194 """
202 """
195 Find IPython's data_files.
203 Find IPython's data_files.
196
204
197 Most of these are docs.
205 Most of these are docs.
198 """
206 """
199
207
200 docdirbase = pjoin('share', 'doc', 'ipython')
208 docdirbase = pjoin('share', 'doc', 'ipython')
201 manpagebase = pjoin('share', 'man', 'man1')
209 manpagebase = pjoin('share', 'man', 'man1')
202
210
203 # Simple file lists can be made by hand
211 # Simple file lists can be made by hand
204 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
212 manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
205 if not manpages:
213 if not manpages:
206 # When running from a source tree, the manpages aren't gzipped
214 # When running from a source tree, the manpages aren't gzipped
207 manpages = filter(isfile, glob(pjoin('docs','man','*.1')))
215 manpages = filter(isfile, glob(pjoin('docs','man','*.1')))
208 igridhelpfiles = filter(isfile,
216 igridhelpfiles = filter(isfile,
209 glob(pjoin('IPython','extensions','igrid_help.*')))
217 glob(pjoin('IPython','extensions','igrid_help.*')))
210
218
211 # For nested structures, use the utility above
219 # For nested structures, use the utility above
212 example_files = make_dir_struct(
220 example_files = make_dir_struct(
213 'data',
221 'data',
214 pjoin('docs','examples'),
222 pjoin('docs','examples'),
215 pjoin(docdirbase,'examples')
223 pjoin(docdirbase,'examples')
216 )
224 )
217 manual_files = make_dir_struct(
225 manual_files = make_dir_struct(
218 'data',
226 'data',
219 pjoin('docs','html'),
227 pjoin('docs','html'),
220 pjoin(docdirbase,'manual')
228 pjoin(docdirbase,'manual')
221 )
229 )
222
230
223 # And assemble the entire output list
231 # And assemble the entire output list
224 data_files = [ (manpagebase, manpages),
232 data_files = [ (manpagebase, manpages),
225 (pjoin(docdirbase, 'extensions'), igridhelpfiles),
233 (pjoin(docdirbase, 'extensions'), igridhelpfiles),
226 ] + manual_files + example_files
234 ] + manual_files + example_files
227
235
228 return data_files
236 return data_files
229
237
230
238
231 def make_man_update_target(manpage):
239 def make_man_update_target(manpage):
232 """Return a target_update-compliant tuple for the given manpage.
240 """Return a target_update-compliant tuple for the given manpage.
233
241
234 Parameters
242 Parameters
235 ----------
243 ----------
236 manpage : string
244 manpage : string
237 Name of the manpage, must include the section number (trailing number).
245 Name of the manpage, must include the section number (trailing number).
238
246
239 Example
247 Example
240 -------
248 -------
241
249
242 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
250 >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE
243 ('docs/man/ipython.1.gz',
251 ('docs/man/ipython.1.gz',
244 ['docs/man/ipython.1'],
252 ['docs/man/ipython.1'],
245 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
253 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz')
246 """
254 """
247 man_dir = pjoin('docs', 'man')
255 man_dir = pjoin('docs', 'man')
248 manpage_gz = manpage + '.gz'
256 manpage_gz = manpage + '.gz'
249 manpath = pjoin(man_dir, manpage)
257 manpath = pjoin(man_dir, manpage)
250 manpath_gz = pjoin(man_dir, manpage_gz)
258 manpath_gz = pjoin(man_dir, manpage_gz)
251 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
259 gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
252 locals() )
260 locals() )
253 return (manpath_gz, [manpath], gz_cmd)
261 return (manpath_gz, [manpath], gz_cmd)
254
262
255 # The two functions below are copied from IPython.utils.path, so we don't need
263 # The two functions below are copied from IPython.utils.path, so we don't need
256 # to import IPython during setup, which fails on Python 3.
264 # to import IPython during setup, which fails on Python 3.
257
265
258 def target_outdated(target,deps):
266 def target_outdated(target,deps):
259 """Determine whether a target is out of date.
267 """Determine whether a target is out of date.
260
268
261 target_outdated(target,deps) -> 1/0
269 target_outdated(target,deps) -> 1/0
262
270
263 deps: list of filenames which MUST exist.
271 deps: list of filenames which MUST exist.
264 target: single filename which may or may not exist.
272 target: single filename which may or may not exist.
265
273
266 If target doesn't exist or is older than any file listed in deps, return
274 If target doesn't exist or is older than any file listed in deps, return
267 true, otherwise return false.
275 true, otherwise return false.
268 """
276 """
269 try:
277 try:
270 target_time = os.path.getmtime(target)
278 target_time = os.path.getmtime(target)
271 except os.error:
279 except os.error:
272 return 1
280 return 1
273 for dep in deps:
281 for dep in deps:
274 dep_time = os.path.getmtime(dep)
282 dep_time = os.path.getmtime(dep)
275 if dep_time > target_time:
283 if dep_time > target_time:
276 #print "For target",target,"Dep failed:",dep # dbg
284 #print "For target",target,"Dep failed:",dep # dbg
277 #print "times (dep,tar):",dep_time,target_time # dbg
285 #print "times (dep,tar):",dep_time,target_time # dbg
278 return 1
286 return 1
279 return 0
287 return 0
280
288
281
289
282 def target_update(target,deps,cmd):
290 def target_update(target,deps,cmd):
283 """Update a target with a given command given a list of dependencies.
291 """Update a target with a given command given a list of dependencies.
284
292
285 target_update(target,deps,cmd) -> runs cmd if target is outdated.
293 target_update(target,deps,cmd) -> runs cmd if target is outdated.
286
294
287 This is just a wrapper around target_outdated() which calls the given
295 This is just a wrapper around target_outdated() which calls the given
288 command if target is outdated."""
296 command if target is outdated."""
289
297
290 if target_outdated(target,deps):
298 if target_outdated(target,deps):
291 os.system(cmd)
299 os.system(cmd)
292
300
293 #---------------------------------------------------------------------------
301 #---------------------------------------------------------------------------
294 # Find scripts
302 # Find scripts
295 #---------------------------------------------------------------------------
303 #---------------------------------------------------------------------------
296
304
297 def find_scripts(entry_points=False, suffix=''):
305 def find_scripts(entry_points=False, suffix=''):
298 """Find IPython's scripts.
306 """Find IPython's scripts.
299
307
300 if entry_points is True:
308 if entry_points is True:
301 return setuptools entry_point-style definitions
309 return setuptools entry_point-style definitions
302 else:
310 else:
303 return file paths of plain scripts [default]
311 return file paths of plain scripts [default]
304
312
305 suffix is appended to script names if entry_points is True, so that the
313 suffix is appended to script names if entry_points is True, so that the
306 Python 3 scripts get named "ipython3" etc.
314 Python 3 scripts get named "ipython3" etc.
307 """
315 """
308 if entry_points:
316 if entry_points:
309 console_scripts = [s % suffix for s in [
317 console_scripts = [s % suffix for s in [
310 'ipython%s = IPython.frontend.terminal.ipapp:launch_new_instance',
318 'ipython%s = IPython.frontend.terminal.ipapp:launch_new_instance',
311 'pycolor%s = IPython.utils.PyColorize:main',
319 'pycolor%s = IPython.utils.PyColorize:main',
312 'ipcontroller%s = IPython.parallel.apps.ipcontrollerapp:launch_new_instance',
320 'ipcontroller%s = IPython.parallel.apps.ipcontrollerapp:launch_new_instance',
313 'ipengine%s = IPython.parallel.apps.ipengineapp:launch_new_instance',
321 'ipengine%s = IPython.parallel.apps.ipengineapp:launch_new_instance',
314 'iplogger%s = IPython.parallel.apps.iploggerapp:launch_new_instance',
322 'iplogger%s = IPython.parallel.apps.iploggerapp:launch_new_instance',
315 'ipcluster%s = IPython.parallel.apps.ipclusterapp:launch_new_instance',
323 'ipcluster%s = IPython.parallel.apps.ipclusterapp:launch_new_instance',
316 'iptest%s = IPython.testing.iptest:main',
324 'iptest%s = IPython.testing.iptest:main',
317 'irunner%s = IPython.lib.irunner:main'
325 'irunner%s = IPython.lib.irunner:main'
318 ]]
326 ]]
319 gui_scripts = [s % suffix for s in [
327 gui_scripts = [s % suffix for s in [
320 'ipython%s-qtconsole = IPython.frontend.qt.console.qtconsoleapp:main',
328 'ipython%s-qtconsole = IPython.frontend.qt.console.qtconsoleapp:main',
321 ]]
329 ]]
322 scripts = dict(console_scripts=console_scripts, gui_scripts=gui_scripts)
330 scripts = dict(console_scripts=console_scripts, gui_scripts=gui_scripts)
323 else:
331 else:
324 parallel_scripts = pjoin('IPython','parallel','scripts')
332 parallel_scripts = pjoin('IPython','parallel','scripts')
325 main_scripts = pjoin('IPython','scripts')
333 main_scripts = pjoin('IPython','scripts')
326 scripts = [
334 scripts = [
327 pjoin(parallel_scripts, 'ipengine'),
335 pjoin(parallel_scripts, 'ipengine'),
328 pjoin(parallel_scripts, 'ipcontroller'),
336 pjoin(parallel_scripts, 'ipcontroller'),
329 pjoin(parallel_scripts, 'ipcluster'),
337 pjoin(parallel_scripts, 'ipcluster'),
330 pjoin(parallel_scripts, 'iplogger'),
338 pjoin(parallel_scripts, 'iplogger'),
331 pjoin(main_scripts, 'ipython'),
339 pjoin(main_scripts, 'ipython'),
332 pjoin(main_scripts, 'pycolor'),
340 pjoin(main_scripts, 'pycolor'),
333 pjoin(main_scripts, 'irunner'),
341 pjoin(main_scripts, 'irunner'),
334 pjoin(main_scripts, 'iptest')
342 pjoin(main_scripts, 'iptest')
335 ]
343 ]
336 return scripts
344 return scripts
337
345
338 #---------------------------------------------------------------------------
346 #---------------------------------------------------------------------------
339 # Verify all dependencies
347 # Verify all dependencies
340 #---------------------------------------------------------------------------
348 #---------------------------------------------------------------------------
341
349
342 def check_for_dependencies():
350 def check_for_dependencies():
343 """Check for IPython's dependencies.
351 """Check for IPython's dependencies.
344
352
345 This function should NOT be called if running under setuptools!
353 This function should NOT be called if running under setuptools!
346 """
354 """
347 from setupext.setupext import (
355 from setupext.setupext import (
348 print_line, print_raw, print_status,
356 print_line, print_raw, print_status,
349 check_for_sphinx, check_for_pygments,
357 check_for_sphinx, check_for_pygments,
350 check_for_nose, check_for_pexpect,
358 check_for_nose, check_for_pexpect,
351 check_for_pyzmq, check_for_readline
359 check_for_pyzmq, check_for_readline
352 )
360 )
353 print_line()
361 print_line()
354 print_raw("BUILDING IPYTHON")
362 print_raw("BUILDING IPYTHON")
355 print_status('python', sys.version)
363 print_status('python', sys.version)
356 print_status('platform', sys.platform)
364 print_status('platform', sys.platform)
357 if sys.platform == 'win32':
365 if sys.platform == 'win32':
358 print_status('Windows version', sys.getwindowsversion())
366 print_status('Windows version', sys.getwindowsversion())
359
367
360 print_raw("")
368 print_raw("")
361 print_raw("OPTIONAL DEPENDENCIES")
369 print_raw("OPTIONAL DEPENDENCIES")
362
370
363 check_for_sphinx()
371 check_for_sphinx()
364 check_for_pygments()
372 check_for_pygments()
365 check_for_nose()
373 check_for_nose()
366 check_for_pexpect()
374 check_for_pexpect()
367 check_for_pyzmq()
375 check_for_pyzmq()
368 check_for_readline()
376 check_for_readline()
369
377
370 def record_commit_info(pkg_dir, build_cmd=build_py):
378 def record_commit_info(pkg_dir, build_cmd=build_py):
371 """ Return extended build command class for recording commit
379 """ Return extended build command class for recording commit
372
380
373 records git commit in IPython.utils._sysinfo.commit
381 records git commit in IPython.utils._sysinfo.commit
374
382
375 for use in IPython.utils.sysinfo.sys_info() calls after installation.
383 for use in IPython.utils.sysinfo.sys_info() calls after installation.
376 """
384 """
377
385
378 class MyBuildPy(build_cmd):
386 class MyBuildPy(build_cmd):
379 ''' Subclass to write commit data into installation tree '''
387 ''' Subclass to write commit data into installation tree '''
380 def run(self):
388 def run(self):
381 build_cmd.run(self)
389 build_cmd.run(self)
382 import subprocess
390 import subprocess
383 proc = subprocess.Popen('git rev-parse --short HEAD',
391 proc = subprocess.Popen('git rev-parse --short HEAD',
384 stdout=subprocess.PIPE,
392 stdout=subprocess.PIPE,
385 stderr=subprocess.PIPE,
393 stderr=subprocess.PIPE,
386 shell=True)
394 shell=True)
387 repo_commit, _ = proc.communicate()
395 repo_commit, _ = proc.communicate()
388 repo_commit = repo_commit.strip()
396 repo_commit = repo_commit.strip()
389 # We write the installation commit even if it's empty
397 # We write the installation commit even if it's empty
390 out_pth = pjoin(self.build_lib, pkg_dir, 'utils', '_sysinfo.py')
398 out_pth = pjoin(self.build_lib, pkg_dir, 'utils', '_sysinfo.py')
391 with io.open(out_pth, 'w') as out_file:
399 with io.open(out_pth, 'w') as out_file:
392 out_file.writelines([
400 out_file.writelines(map(unicode, [
393 u"# GENERATED BY setup.py\n",
401 '# GENERATED BY setup.py\n',
394 u"commit = '%s'\n" % repo_commit,
402 'commit = "%s"\n' % repo_commit,
395 ])
403 ]))
396 return MyBuildPy
404 return MyBuildPy
General Comments 0
You need to be logged in to leave comments. Login now