Commit 13c8739a authored by PJ Eby's avatar PJ Eby

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).

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041068
parent c386a7e6
...@@ -22,7 +22,7 @@ __all__ = [ ...@@ -22,7 +22,7 @@ __all__ = [
'InvalidOption', 'Distribution', 'Requirement', 'yield_lines', 'InvalidOption', 'Distribution', 'Requirement', 'yield_lines',
'get_importer', 'find_distributions', 'find_on_path', 'register_finder', 'get_importer', 'find_distributions', 'find_on_path', 'register_finder',
'split_sections', 'declare_namespace', 'register_namespace_handler', '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 import sys, os, zipimport, time, re, imp
...@@ -54,7 +54,8 @@ class InvalidOption(ResolutionError): ...@@ -54,7 +54,8 @@ class InvalidOption(ResolutionError):
_provider_factories = {} _provider_factories = {}
PY_MAJOR = sys.version[:3] PY_MAJOR = sys.version[:3]
EGG_DIST = 2 EGG_DIST = 3
BINARY_DIST = 2
SOURCE_DIST = 1 SOURCE_DIST = 1
def register_loader_type(loader_type, provider_factory): def register_loader_type(loader_type, provider_factory):
...@@ -79,7 +80,6 @@ def get_provider(moduleName): ...@@ -79,7 +80,6 @@ def get_provider(moduleName):
def get_platform(): def get_platform():
"""Return this platform's string for platform-specific distributions """Return this platform's string for platform-specific distributions
...@@ -231,7 +231,8 @@ class AvailableDistributions(object): ...@@ -231,7 +231,8 @@ class AvailableDistributions(object):
def can_add(self, dist): def can_add(self, dist):
"""Is distribution `dist` acceptable for this collection?""" """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) and compatible_platforms(dist.platform,self.platform)
def __iter__(self): def __iter__(self):
...@@ -242,7 +243,6 @@ class AvailableDistributions(object): ...@@ -242,7 +243,6 @@ class AvailableDistributions(object):
"""Has a distribution named `name` ever been added to this map?""" """Has a distribution named `name` ever been added to this map?"""
return name.lower() in self._distmap return name.lower() in self._distmap
def __len__(self): return len(self._distmap)
def get(self,key,default=None): def get(self,key,default=None):
"""Return ``self[key]`` if `key` in self, otherwise return `default`""" """Return ``self[key]`` if `key` in self, otherwise return `default`"""
...@@ -361,11 +361,11 @@ class AvailableDistributions(object): ...@@ -361,11 +361,11 @@ class AvailableDistributions(object):
return to_install # return list of distros to install return to_install # return list of distros to install
def obtain(self, requirement): def obtain(self, requirement):
"""Obtain a distro that matches requirement (e.g. via download)""" """Obtain a distro that matches requirement (e.g. via download)"""
return None # override this in subclasses return None # override this in subclasses
def __len__(self): return len(self._distmap)
class ResourceManager: class ResourceManager:
"""Manage resource extraction and packages""" """Manage resource extraction and packages"""
...@@ -373,7 +373,7 @@ class ResourceManager: ...@@ -373,7 +373,7 @@ class ResourceManager:
extraction_path = None extraction_path = None
def __init__(self): def __init__(self):
self.cached_files = [] self.cached_files = {}
def resource_exists(self, package_name, resource_name): def resource_exists(self, package_name, resource_name):
"""Does the named resource exist in the named package?""" """Does the named resource exist in the named package?"""
...@@ -425,7 +425,7 @@ class ResourceManager: ...@@ -425,7 +425,7 @@ class ResourceManager:
extract_path = extract_path or os.path.expanduser('~/.python-eggs') extract_path = extract_path or os.path.expanduser('~/.python-eggs')
target_path = os.path.join(extract_path, archive_name, *names) target_path = os.path.join(extract_path, archive_name, *names)
ensure_directory(target_path) ensure_directory(target_path)
self.cached_files.append(target_path) self.cached_files[target_path] = 1
return target_path return target_path
...@@ -1263,7 +1263,7 @@ class Distribution(object): ...@@ -1263,7 +1263,7 @@ class Distribution(object):
) )
return cls( return cls(
filename, metadata, name=name, version=version, 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) from_filename = classmethod(from_filename)
...@@ -1453,7 +1453,7 @@ def parse_requirements(strs): ...@@ -1453,7 +1453,7 @@ def parse_requirements(strs):
def _sort_dists(dists): 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() tmp.sort()
dists[::-1] = [d for v,t,d in tmp] dists[::-1] = [d for v,t,d in tmp]
......
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