From 30b93ed6a6884e1fc5491c428dba154b144f6291 2011-10-08 17:27:08 From: Thomas Kluyver Date: 2011-10-08 17:27:08 Subject: [PATCH] Fix IPython.utils.sysinfo for Python 3. --- diff --git a/IPython/utils/sysinfo.py b/IPython/utils/sysinfo.py index a49c735..b9b7c74 100644 --- a/IPython/utils/sysinfo.py +++ b/IPython/utils/sysinfo.py @@ -70,9 +70,13 @@ def pkg_commit_hash(pkg_path): raise IOError('Missing commit info file %s' % pth) cfg_parser = ConfigParser() cfg_parser.read(pth) - archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash') - if not archive_subst.startswith('$Format'): # it has been substituted - return 'archive substitution', archive_subst + try: + archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash') + except Exception: + pass + else: + if not archive_subst.startswith('$Format'): # it has been substituted + return 'archive substitution', archive_subst install_subst = cfg_parser.get('commit hash', 'install_hash') if install_subst != '': return 'installation', install_subst diff --git a/setup3.py b/setup3.py index 43079dc..4cc13a7 100644 --- a/setup3.py +++ b/setup3.py @@ -1,15 +1,18 @@ import os.path from setuptools import setup +from setuptools.command.build_py import build_py from setupbase import (setup_args, find_scripts, find_packages, find_package_data, + record_commit_info, ) setup_args['entry_points'] = find_scripts(True, suffix='3') setup_args['packages'] = find_packages() setup_args['package_data'] = find_package_data() +setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)} def main(): setup(use_2to3 = True, **setup_args) diff --git a/setupbase.py b/setupbase.py index df406bb..1a030ef 100644 --- a/setupbase.py +++ b/setupbase.py @@ -359,7 +359,7 @@ def record_commit_info(pkg_dir, build_cmd=build_py): class MyBuildPy(build_cmd): ''' Subclass to write commit data into installation tree ''' def run(self): - build_py.run(self) + build_cmd.run(self) import subprocess proc = subprocess.Popen('git rev-parse --short HEAD', stdout=subprocess.PIPE, @@ -369,7 +369,7 @@ def record_commit_info(pkg_dir, build_cmd=build_py): # We write the installation commit even if it's empty cfg_parser = ConfigParser() cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini')) - cfg_parser.set('commit hash', 'install_hash', repo_commit) + cfg_parser.set('commit hash', 'install_hash', repo_commit.decode('ascii')) out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini') out_file = open(out_pth, 'wt') cfg_parser.write(out_file)