[Python-checkins] commit of r41469 - sandbox/trunk/setuptools

phillip.eby@python.org phillip.eby at python.org
Fri Nov 18 03:07:32 CET 2005


Author: phillip.eby
Date: Fri Nov 18 03:07:30 2005
New Revision: 41469

Modified:
   sandbox/trunk/setuptools/pkg_resources.py
   sandbox/trunk/setuptools/pkg_resources.txt
Log:
Don't raise an error when an invalid (unfinished) distribution is found
unless absolutely necessary.  Warn about skipping invalid/unfinished eggs
when building an Environment.


Modified: sandbox/trunk/setuptools/pkg_resources.py
==============================================================================
--- sandbox/trunk/setuptools/pkg_resources.py	(original)
+++ sandbox/trunk/setuptools/pkg_resources.py	Fri Nov 18 03:07:30 2005
@@ -605,7 +605,7 @@
 
     def add(self,dist):
         """Add `dist` if we ``can_add()`` it and it isn't already added"""
-        if self.can_add(dist):
+        if self.can_add(dist) and dist.has_version():
             dists = self._distmap.setdefault(dist.key,[])
             if dist not in dists:
                 dists.append(dist)
@@ -1940,31 +1940,31 @@
             fn = getattr(sys.modules[modname], '__file__', None)
             if fn and fn.startswith(self.location):
                 continue
-
-            level = 1
-            g = globals()
-            try:
-                # find the first stack frame that is *not* code in
-                # the pkg_resources module, to use for the warning
-                while sys._getframe(level).f_globals is g:
-                    level += 1
-            except ValueError:
-                pass
-
-            from warnings import warn
-            warn(
+            issue_warning(
                 "Module %s was already imported from %s, but %s is being added"
                 " to sys.path" % (modname, fn, self.location),
-                stacklevel = level+1
             )
 
-
-
-
-
-
-
-
+    def has_version(self):
+        try:
+            self.version
+        except ValueError:
+            issue_warning("Unbuilt egg for "+repr(self))
+            return False
+        return True
+
+def issue_warning(*args,**kw):
+    level = 1
+    g = globals()
+    try:
+        # find the first stack frame that is *not* code in
+        # the pkg_resources module, to use for the warning
+        while sys._getframe(level).f_globals is g:
+            level += 1
+    except ValueError:
+        pass
+    from warnings import warn
+    warn(stacklevel = level+1, *args, **kw)
 
 def parse_requirements(strs):
     """Yield ``Requirement`` objects for each specification in `strs`
@@ -2076,7 +2076,7 @@
     def __contains__(self,item):
         if isinstance(item,Distribution):
             if item.key <> self.key: return False
-            item = item.parsed_version
+            if self.index: item = item.parsed_version  # only get if we need it
         elif isinstance(item,basestring):
             item = parse_version(item)
         last = None

Modified: sandbox/trunk/setuptools/pkg_resources.txt
==============================================================================
--- sandbox/trunk/setuptools/pkg_resources.txt	(original)
+++ sandbox/trunk/setuptools/pkg_resources.txt	Fri Nov 18 03:07:30 2005
@@ -1348,7 +1348,7 @@
     The algorithm assumes that strings like "-" and any alpha string that
     alphabetically follows "final"  represents a "patch level".  So, "2.4-1"
     is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is
-    considered newer than "2.4-1", whic in turn is newer than "2.4".
+    considered newer than "2.4-1", which in turn is newer than "2.4".
 
     Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that
     come before "final" alphabetically) are assumed to be pre-release versions,
@@ -1488,6 +1488,11 @@
 Release Notes/Change History
 ----------------------------
 
+0.6a9
+ * Don't raise an error when an invalid (unfinished) distribution is found
+   unless absolutely necessary.  Warn about skipping invalid/unfinished eggs
+   when building an Environment.
+
 0.6a8
  * Fixed a problem with ``WorkingSet.resolve()`` that prevented version
    conflicts from being detected at runtime.


More information about the Python-checkins mailing list