Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

record sysinfo in sdist #2068

Merged
merged 1 commit into from

2 participants

@minrk
Owner

closes #2054

@fperez
Owner

Wow, you're becoming quite the distutils expert. Be careful, you might like it ;)

Thanks, looks solid; merging now.

@fperez fperez merged commit b2ab7f5 into ipython:master
@minrk
Owner

Here's how I do ~100% of my distutils customization (here, and in pyzmq where it's much more complicated):

  1. Stick import IPython; IPython.embed() in the run() method.
  2. Inspect with self.method??
  3. Repeat 2. until I get to the part that needs to behave differently
  4. Wonder why it doesn't work the way it seems like it should

Be careful, you might like it ;)

I don't think there's any risk of that.

@fperez
Owner
@Carreau Carreau referenced this pull request from a commit in Carreau/ipython
@minrk minrk record sysinfo in sdist
closes #2054

backported to 0.13.1 from PR #2068
dd82175
@minrk minrk referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@minrk minrk referenced this pull request from a commit
@minrk minrk Backport PR #2068: record sysinfo in sdist
closes #2054
0ff0ffc
@minrk minrk deleted the minrk:sysinfo branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 30, 2012
  1. @minrk

    record sysinfo in sdist

    minrk authored
    closes #2054
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 9 deletions.
  1. +9 −4 setup.py
  2. +27 −5 setupbase.py
View
13 setup.py
@@ -52,7 +52,6 @@
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
from distutils.core import setup
-from distutils.command.upload import upload
# On Python 3, we need distribute (new setuptools) to do the 2to3 conversion
if PY3:
@@ -166,14 +165,16 @@ def cleanup():
package_data = find_package_data()
data_files = find_data_files()
-setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')}
setup_args['packages'] = packages
setup_args['package_data'] = package_data
setup_args['data_files'] = data_files
#---------------------------------------------------------------------------
-# custom upload_wininst command
+# custom distutils commands
#---------------------------------------------------------------------------
+# imports here, so they are after setuptools import if there was one
+from distutils.command.sdist import sdist
+from distutils.command.upload import upload
class UploadWindowsInstallers(upload):
@@ -194,7 +195,11 @@ def run(self):
for dist_file in glob(self.files):
self.upload_file('bdist_wininst', 'any', dist_file)
-setup_args['cmdclass']['upload_wininst'] = UploadWindowsInstallers
+setup_args['cmdclass'] = {
+ 'build_py': record_commit_info('IPython'),
+ 'sdist' : record_commit_info('IPython', sdist),
+ 'upload_wininst' : UploadWindowsInstallers,
+}
#---------------------------------------------------------------------------
# Handle scripts, dependencies, and setuptools specific things
View
32 setupbase.py
@@ -369,7 +369,7 @@ def check_for_dependencies():
check_for_readline()
def record_commit_info(pkg_dir, build_cmd=build_py):
- """ Return extended build command class for recording commit
+ """ Return extended build or sdist command class for recording commit
records git commit in IPython.utils._sysinfo.commit
@@ -380,18 +380,40 @@ class MyBuildPy(build_cmd):
''' Subclass to write commit data into installation tree '''
def run(self):
build_cmd.run(self)
+ # this one will only fire for build commands
+ if hasattr(self, 'build_lib'):
+ self._record_commit(self.build_lib)
+
+ def make_release_tree(self, base_dir, files):
+ # this one will fire for sdist
+ build_cmd.make_release_tree(self, base_dir, files)
+ self._record_commit(base_dir)
+
+ def _record_commit(self, base_dir):
import subprocess
proc = subprocess.Popen('git rev-parse --short HEAD',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
repo_commit, _ = proc.communicate()
- repo_commit = repo_commit.strip()
- # We write the installation commit even if it's empty
- out_pth = pjoin(self.build_lib, pkg_dir, 'utils', '_sysinfo.py')
+ repo_commit = repo_commit.strip().decode("ascii")
+
+ out_pth = pjoin(base_dir, pkg_dir, 'utils', '_sysinfo.py')
+ if os.path.isfile(out_pth) and not repo_commit:
+ # nothing to write, don't clobber
+ return
+
+ print("writing git commit '%s' to %s" % (repo_commit, out_pth))
+
+ # remove to avoid overwriting original via hard link
+ try:
+ os.remove(out_pth)
+ except (IOError, OSError):
+ pass
+ print (out_pth, file=sys.stderr)
with open(out_pth, 'w') as out_file:
out_file.writelines([
'# GENERATED BY setup.py\n',
- 'commit = "%s"\n' % repo_commit.decode('ascii'),
+ 'commit = "%s"\n' % repo_commit,
])
return MyBuildPy
Something went wrong with that request. Please try again.