diff options
author | PJ Eby <distutils-sig@python.org> | 2005-06-05 00:47:36 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-06-05 00:47:36 +0000 |
commit | 06afb1cd6df106cb1bc10f69b5b0117680bb2aa1 (patch) | |
tree | 16086fba0273df2a218fc1538ad1167b82db4b6b | |
parent | 28a6fa31fff4cf5a38894988c4b6bfaf14e40438 (diff) | |
download | external_python_setuptools-06afb1cd6df106cb1bc10f69b5b0117680bb2aa1.tar.gz external_python_setuptools-06afb1cd6df106cb1bc10f69b5b0117680bb2aa1.tar.bz2 external_python_setuptools-06afb1cd6df106cb1bc10f69b5b0117680bb2aa1.zip |
Add support for prioritized sorting of distributions by distribution type,
to assist easy_install in indexing packages from PyPI.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041036
-rw-r--r-- | pkg_resources.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index 058c32bc..2e2a1bde 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -15,8 +15,8 @@ method. __all__ = [ 'register_loader_type', 'get_provider', 'IResourceProvider','PathMetadata', 'ResourceManager', 'AvailableDistributions', 'require', 'resource_string', - 'resource_stream', 'resource_filename', 'set_extraction_path', - 'cleanup_resources', 'parse_requirements', 'ensure_directory', + 'resource_stream', 'resource_filename', 'set_extraction_path', 'EGG_DIST', + 'cleanup_resources', 'parse_requirements', 'ensure_directory','SOURCE_DIST', 'compatible_platforms', 'get_platform', 'IMetadataProvider','parse_version', 'ResolutionError', 'VersionConflict', 'DistributionNotFound','EggMetadata', 'InvalidOption', 'Distribution', 'Requirement', 'yield_lines', @@ -1105,9 +1105,12 @@ def parse_version(s): +EGG_DIST = 2 +SOURCE_DIST = 1 + class Distribution(object): """Wrap an actual or potential sys.path entry w/metadata""" - + typecode = EGG_DIST def __init__(self, path_str, metadata=None, name=None, version=None, py_version=PY_MAJOR, platform=None @@ -1116,7 +1119,6 @@ class Distribution(object): self.name = name.replace('_','-') if version: self._version = version.replace('_','-') - self.py_version = py_version self.platform = platform self.path = path_str @@ -1144,8 +1146,6 @@ class Distribution(object): ) from_filename = classmethod(from_filename) - - # These properties have to be lazy so that we don't have to load any # metadata until/unless it's actually needed. (i.e., some distributions # may not know their name or version without loading PKG-INFO) @@ -1174,13 +1174,13 @@ class Distribution(object): try: return self._version except AttributeError: - for line in self.metadata.get_metadata_lines('PKG-INFO'): + for line in self._get_metadata('PKG-INFO'): if line.lower().startswith('version:'): self._version = line.split(':',1)[1].strip() return self._version else: raise AttributeError( - "Missing Version: header in PKG-INFO", self + "Missing 'Version:' header in PKG-INFO", self ) version = property(version) @@ -1215,7 +1215,7 @@ class Distribution(object): return deps def _get_metadata(self,name): - if self.metadata.has_metadata(name): + if self.metadata is not None and self.metadata.has_metadata(name): for line in self.metadata.get_metadata_lines(name): yield line @@ -1289,9 +1289,9 @@ def parse_requirements(strs): def _sort_dists(dists): - tmp = [(dist.version,dist) for dist in dists] + tmp = [(dist.version,dist.typecode,dist) for dist in dists] tmp.sort() - dists[::-1] = [d for v,d in tmp] + dists[::-1] = [d for v,t,d in tmp] |