[Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.33, 1.34

pje@users.sourceforge.net pje at users.sourceforge.net
Wed Jun 15 04:16:06 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9909

Modified Files:
	pkg_resources.py 
Log Message:
Fix incorrect sorting of packages by string version instead of parsed
version info.  Don't set a default Python version for distribution 
objects.  Add enum for binary distributions (like bdist_wininst).


Index: pkg_resources.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- pkg_resources.py	14 Jun 2005 15:29:41 -0000	1.33
+++ pkg_resources.py	15 Jun 2005 02:16:03 -0000	1.34
@@ -22,7 +22,7 @@
     'InvalidOption', 'Distribution', 'Requirement', 'yield_lines',
     'get_importer', 'find_distributions', 'find_on_path', 'register_finder',
     'split_sections', 'declare_namespace', 'register_namespace_handler',
-    'safe_name', 'safe_version', 'run_main',
+    'safe_name', 'safe_version', 'run_main', 'BINARY_DIST',
 ]
 
 import sys, os, zipimport, time, re, imp
@@ -54,7 +54,8 @@
 _provider_factories = {}
 PY_MAJOR = sys.version[:3]
 
-EGG_DIST    = 2
+EGG_DIST    = 3
+BINARY_DIST = 2
 SOURCE_DIST = 1
 
 def register_loader_type(loader_type, provider_factory):
@@ -79,7 +80,6 @@
 
 
 
-
 def get_platform():
     """Return this platform's string for platform-specific distributions
 
@@ -231,7 +231,8 @@
 
     def can_add(self, dist):
         """Is distribution `dist` acceptable for this collection?"""
-        return (self.python is None or dist.py_version==self.python) \
+        return (self.python is None or dist.py_version is None
+            or dist.py_version==self.python) \
            and compatible_platforms(dist.platform,self.platform)
 
     def __iter__(self):
@@ -242,7 +243,6 @@
         """Has a distribution named `name` ever been added to this map?"""
         return name.lower() in self._distmap
 
-    def __len__(self): return len(self._distmap)
 
     def get(self,key,default=None):
         """Return ``self[key]`` if `key` in self, otherwise return `default`"""
@@ -361,11 +361,11 @@
 
         return to_install    # return list of distros to install
 
-
     def obtain(self, requirement):
         """Obtain a distro that matches requirement (e.g. via download)"""
         return None     # override this in subclasses
 
+    def __len__(self): return len(self._distmap)
 
 class ResourceManager:
     """Manage resource extraction and packages"""
@@ -373,7 +373,7 @@
     extraction_path = None
 
     def __init__(self):
-        self.cached_files = []
+        self.cached_files = {}
 
     def resource_exists(self, package_name, resource_name):
         """Does the named resource exist in the named package?"""
@@ -425,7 +425,7 @@
         extract_path = extract_path or os.path.expanduser('~/.python-eggs')
         target_path = os.path.join(extract_path, archive_name, *names)
         ensure_directory(target_path)
-        self.cached_files.append(target_path)
+        self.cached_files[target_path] = 1
         return target_path
 
 
@@ -1263,7 +1263,7 @@
                 )
         return cls(
             filename, metadata, name=name, version=version,
-            py_version=py_version or PY_MAJOR, platform=platform
+            py_version=py_version, platform=platform
         )
     from_filename = classmethod(from_filename)
 
@@ -1453,7 +1453,7 @@
 
 
 def _sort_dists(dists):
-    tmp = [(dist.version,dist.distro_type,dist) for dist in dists]
+    tmp = [(dist.parsed_version,dist.distro_type,dist) for dist in dists]
     tmp.sort()
     dists[::-1] = [d for v,t,d in tmp]
 



More information about the Python-checkins mailing list