summaryrefslogtreecommitdiff
path: root/setuptools/command/egg_info.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-11-04 05:38:22 +0000
committerPJ Eby <distutils-sig@python.org>2005-11-04 05:38:22 +0000
commit18f7fa25a184ec0cde7ff5d765e417eb17f90edc (patch)
treed2f3da9a1e3ed43a3b14032dc67fd95b7c48874e /setuptools/command/egg_info.py
parentd652ac7bce6b7d491e45fd58405d7ac7bc625a48 (diff)
downloadpython-setuptools-bitbucket-18f7fa25a184ec0cde7ff5d765e417eb17f90edc.tar.gz
Made ``egg_info --tag-svn-revision`` fall back to extracting the
revision number from ``PKG-INFO`` in case it is being run on a source distribution of a snapshot taken from a Subversion-based project. That is, if a project builds an sdist with --tag-svn-revision in setup.cfg, then the built sdist will create binaries with the same version number as the checkout that was used to create the sdist.
Diffstat (limited to 'setuptools/command/egg_info.py')
-rwxr-xr-xsetuptools/command/egg_info.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index 2c9a953e..c5a404e9 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -160,7 +160,7 @@ class egg_info(Command):
continue # not part of the same svn tree, skip it
for match in revre.finditer(data):
revision = max(revision, int(match.group(1)))
- return str(revision)
+ return str(revision or get_pkg_info_revision())
def write_pkg_info(cmd, basename, filename):
log.info("writing %s", filename)
@@ -226,17 +226,17 @@ def write_entries(cmd, basename, filename):
cmd.write_or_delete_file('entry points', filename, data)
-
-
-
-
-
-
-
-
-
-
-
+def get_pkg_info_revision():
+ # See if we can get a -r### off of PKG-INFO, in case this is an sdist of
+ # a subversion revision
+ #
+ if os.path.exists('PKG-INFO'):
+ f = open('PKG-INFO','rU')
+ for line in f:
+ match = re.match(r"Version:.*-r(\d+)\s*$", line)
+ if match:
+ return int(match.group(1))
+ return 0