Commit 8312542d authored by PJ Eby's avatar PJ Eby

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.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041396
parent 12022171
...@@ -1471,10 +1471,11 @@ added in the following order: ...@@ -1471,10 +1471,11 @@ added in the following order:
Append NAME to the project's version string. Due to the way setuptools Append NAME to the project's version string. Due to the way setuptools
processes "pre-release" version suffixes beginning with the letters "a" processes "pre-release" version suffixes beginning with the letters "a"
through "e" (like "alpha", "beta", and "candidate"), you will usually want through "e" (like "alpha", "beta", and "candidate"), you will usually want
to use a tag like "build" or "dev", as this will cause the version number to use a tag like ".build" or ".dev", as this will cause the version number
to be considered *lower* than the project's default version. (If you to be considered *lower* than the project's default version. (If you
want to make the version number *higher* than the default version, you can want to make the version number *higher* than the default version, you can
always leave off --tag-build and use one or both of the following options.) always leave off --tag-build and then use one or both of the following
options.)
``--tag-svn-revision, -r`` ``--tag-svn-revision, -r``
If the current directory is a Subversion checkout (i.e. has a ``.svn`` If the current directory is a Subversion checkout (i.e. has a ``.svn``
...@@ -1483,6 +1484,16 @@ added in the following order: ...@@ -1483,6 +1484,16 @@ added in the following order:
modification to the current directory, as obtained from the ``svn info`` modification to the current directory, as obtained from the ``svn info``
command. command.
If the current directory is not a Subversion checkout, the command will
look for a ``PKG-INFO`` file instead, and try to find the revision number
from that, by looking for a "-rNNNN" string at the end of the version
number. (This is so that building a package from a source distribution of
a Subversion snapshot will produce a binary with the correct version
number.)
If there is no ``PKG-INFO`` file, or the version number contained therein
does not end with ``-r`` and a number, then ``-r0`` is used.
``--tag-date, -d`` ``--tag-date, -d``
Add a date stamp of the form "-YYYYMMDD" (e.g. "-20050528") to the Add a date stamp of the form "-YYYYMMDD" (e.g. "-20050528") to the
project's version number. project's version number.
...@@ -1951,6 +1962,10 @@ Release Notes/Change History ...@@ -1951,6 +1962,10 @@ Release Notes/Change History
* Made ``develop`` command accept all the same options as ``easy_install``, * Made ``develop`` command accept all the same options as ``easy_install``,
and use the ``easy_install`` command's configuration settings as defaults. and use the ``easy_install`` command's configuration settings as defaults.
* 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.
0.6a5 0.6a5
* Fixed missing gui/cli .exe files in distribution. Fixed bugs in tests. * Fixed missing gui/cli .exe files in distribution. Fixed bugs in tests.
......
...@@ -160,7 +160,7 @@ class egg_info(Command): ...@@ -160,7 +160,7 @@ class egg_info(Command):
continue # not part of the same svn tree, skip it continue # not part of the same svn tree, skip it
for match in revre.finditer(data): for match in revre.finditer(data):
revision = max(revision, int(match.group(1))) 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): def write_pkg_info(cmd, basename, filename):
log.info("writing %s", filename) log.info("writing %s", filename)
...@@ -226,17 +226,17 @@ def write_entries(cmd, basename, filename): ...@@ -226,17 +226,17 @@ def write_entries(cmd, basename, filename):
cmd.write_or_delete_file('entry points', filename, data) 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment