[Python-checkins] commit of r41401 - in sandbox/trunk/setuptools: . setuptools setuptools/command
phillip.eby@python.org
phillip.eby at python.org
Sat Nov 5 06:50:27 CET 2005
Author: phillip.eby
Date: Sat Nov 5 06:50:26 2005
New Revision: 41401
Modified:
sandbox/trunk/setuptools/setuptools.txt
sandbox/trunk/setuptools/setuptools/command/egg_info.py
sandbox/trunk/setuptools/setuptools/dist.py
Log:
Fixed some problems with fresh checkouts of projects that don't include
``.egg-info/PKG-INFO`` under revision control and put the project's source
code directly in the project directory. If such a package had any
requirements that get processed before the ``egg_info`` command can be run,
the setup scripts would fail with a "Missing 'Version:' header and/or
PKG-INFO file" error, because the egg runtime interpreted the unbuilt
metadata in a directory on ``sys.path`` (i.e. the current directory) as
being a corrupted egg. Setuptools now monkeypatches the distribution
metadata cache to pretend that the egg has valid version information, until
it has a chance to make it actually be so (via the ``egg_info`` command).
Modified: sandbox/trunk/setuptools/setuptools.txt
==============================================================================
--- sandbox/trunk/setuptools/setuptools.txt (original)
+++ sandbox/trunk/setuptools/setuptools.txt Sat Nov 5 06:50:26 2005
@@ -1966,6 +1966,17 @@
number from ``PKG-INFO`` in case it is being run on a source distribution of
a snapshot taken from a Subversion-based project.
+ * Fixed some problems with fresh checkouts of projects that don't include
+ ``.egg-info/PKG-INFO`` under revision control and put the project's source
+ code directly in the project directory. If such a package had any
+ requirements that get processed before the ``egg_info`` command can be run,
+ the setup scripts would fail with a "Missing 'Version:' header and/or
+ PKG-INFO file" error, because the egg runtime interpreted the unbuilt
+ metadata in a directory on ``sys.path`` (i.e. the current directory) as
+ being a corrupted egg. Setuptools now monkeypatches the distribution
+ metadata cache to pretend that the egg has valid version information, until
+ it has a chance to make it actually be so (via the ``egg_info`` command).
+
0.6a5
* Fixed missing gui/cli .exe files in distribution. Fixed bugs in tests.
Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/egg_info.py (original)
+++ sandbox/trunk/setuptools/setuptools/command/egg_info.py Sat Nov 5 06:50:26 2005
@@ -7,7 +7,7 @@
from setuptools import Command
from distutils.errors import *
from distutils import log
-from pkg_resources import parse_requirements, safe_name, \
+from pkg_resources import parse_requirements, safe_name, parse_version, \
safe_version, yield_lines, EntryPoint, iter_entry_points
class egg_info(Command):
@@ -65,16 +65,16 @@
#
self.distribution.metadata.version = self.egg_version
-
-
-
-
-
-
-
-
-
-
+ # If we bootstrapped around the lack of a PKG-INFO, as might be the
+ # case in a fresh checkout, make sure that any special tags get added
+ # to the version info
+ #
+ pd = self.distribution._patched_dist
+ if pd is not None and pd.key==self.egg_name.lower():
+ pd._version = self.egg_version
+ pd._parsed_version = parse_version(self.egg_version)
+ self.distribution._patched_dist = None
+
Modified: sandbox/trunk/setuptools/setuptools/dist.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/dist.py (original)
+++ sandbox/trunk/setuptools/setuptools/dist.py Sat Nov 5 06:50:26 2005
@@ -188,20 +188,20 @@
distribution for the included and excluded features.
"""
+ _patched_dist = None
-
-
-
-
-
-
-
-
-
-
-
-
-
+ def patch_missing_pkg_info(self, attrs):
+ # Fake up a replacement for the data that would normally come from
+ # PKG-INFO, but which might not yet be built if this is a fresh
+ # checkout.
+ #
+ if not attrs or 'name' not in attrs or 'version' not in attrs:
+ return
+ key = pkg_resources.safe_name(str(attrs['name'])).lower()
+ dist = pkg_resources.working_set.by_key.get(key)
+ if dist is not None and not dist.has_metadata('PKG-INFO'):
+ dist._version = pkg_resources.safe_version(str(attrs['version']))
+ self._patched_dist = dist
def __init__ (self, attrs=None):
have_package_data = hasattr(self, "package_data")
@@ -210,7 +210,7 @@
self.requires = [] # XXX
self.features = {}
self.dist_files = []
-
+ self.patch_missing_pkg_info(attrs)
if attrs and 'setup_requires' in attrs:
# Make sure we have any eggs needed to interpret 'attrs'
self.fetch_build_eggs(attrs.pop('setup_requires'))
More information about the Python-checkins
mailing list