##// END OF EJS Templates
Fix IPython.utils.sysinfo for Python 3.
Thomas Kluyver -
Show More
@@ -70,9 +70,13 b' def pkg_commit_hash(pkg_path):'
70 raise IOError('Missing commit info file %s' % pth)
70 raise IOError('Missing commit info file %s' % pth)
71 cfg_parser = ConfigParser()
71 cfg_parser = ConfigParser()
72 cfg_parser.read(pth)
72 cfg_parser.read(pth)
73 archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash')
73 try:
74 if not archive_subst.startswith('$Format'): # it has been substituted
74 archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash')
75 return 'archive substitution', archive_subst
75 except Exception:
76 pass
77 else:
78 if not archive_subst.startswith('$Format'): # it has been substituted
79 return 'archive substitution', archive_subst
76 install_subst = cfg_parser.get('commit hash', 'install_hash')
80 install_subst = cfg_parser.get('commit hash', 'install_hash')
77 if install_subst != '':
81 if install_subst != '':
78 return 'installation', install_subst
82 return 'installation', install_subst
@@ -1,15 +1,18 b''
1 import os.path
1 import os.path
2 from setuptools import setup
2 from setuptools import setup
3 from setuptools.command.build_py import build_py
3
4
4 from setupbase import (setup_args,
5 from setupbase import (setup_args,
5 find_scripts,
6 find_scripts,
6 find_packages,
7 find_packages,
7 find_package_data,
8 find_package_data,
9 record_commit_info,
8 )
10 )
9
11
10 setup_args['entry_points'] = find_scripts(True, suffix='3')
12 setup_args['entry_points'] = find_scripts(True, suffix='3')
11 setup_args['packages'] = find_packages()
13 setup_args['packages'] = find_packages()
12 setup_args['package_data'] = find_package_data()
14 setup_args['package_data'] = find_package_data()
15 setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)}
13
16
14 def main():
17 def main():
15 setup(use_2to3 = True, **setup_args)
18 setup(use_2to3 = True, **setup_args)
@@ -359,7 +359,7 b' def record_commit_info(pkg_dir, build_cmd=build_py):'
359 class MyBuildPy(build_cmd):
359 class MyBuildPy(build_cmd):
360 ''' Subclass to write commit data into installation tree '''
360 ''' Subclass to write commit data into installation tree '''
361 def run(self):
361 def run(self):
362 build_py.run(self)
362 build_cmd.run(self)
363 import subprocess
363 import subprocess
364 proc = subprocess.Popen('git rev-parse --short HEAD',
364 proc = subprocess.Popen('git rev-parse --short HEAD',
365 stdout=subprocess.PIPE,
365 stdout=subprocess.PIPE,
@@ -369,7 +369,7 b' def record_commit_info(pkg_dir, build_cmd=build_py):'
369 # We write the installation commit even if it's empty
369 # We write the installation commit even if it's empty
370 cfg_parser = ConfigParser()
370 cfg_parser = ConfigParser()
371 cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini'))
371 cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini'))
372 cfg_parser.set('commit hash', 'install_hash', repo_commit)
372 cfg_parser.set('commit hash', 'install_hash', repo_commit.decode('ascii'))
373 out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini')
373 out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini')
374 out_file = open(out_pth, 'wt')
374 out_file = open(out_pth, 'wt')
375 cfg_parser.write(out_file)
375 cfg_parser.write(out_file)
General Comments 0
You need to be logged in to leave comments. Login now