Commit 718c66c4 authored by Jason R. Coombs's avatar Jason R. Coombs

Re-use metadata loading functionality from Provider. Fixes #469.

parent e36ec568
...@@ -3,6 +3,13 @@ CHANGES ...@@ -3,6 +3,13 @@ CHANGES
======= =======
------
18.7.1
------
* Issue #469: Refactored logic for Issue #419 fix to re-use metadata
loading from Provider.
---- ----
18.7 18.7
---- ----
......
...@@ -2507,7 +2507,6 @@ class Distribution(object): ...@@ -2507,7 +2507,6 @@ class Distribution(object):
@classmethod @classmethod
def from_location(cls, location, basename, metadata=None, **kw): def from_location(cls, location, basename, metadata=None, **kw):
project_name, version, py_version, platform = [None]*4 project_name, version, py_version, platform = [None]*4
dist_path = os.path.join(location, basename)
basename, ext = os.path.splitext(basename) basename, ext = os.path.splitext(basename)
if ext.lower() in _distributionImpl: if ext.lower() in _distributionImpl:
cls = _distributionImpl[ext.lower()] cls = _distributionImpl[ext.lower()]
...@@ -2517,16 +2516,13 @@ class Distribution(object): ...@@ -2517,16 +2516,13 @@ class Distribution(object):
project_name, version, py_version, platform = match.group( project_name, version, py_version, platform = match.group(
'name', 'ver', 'pyver', 'plat' 'name', 'ver', 'pyver', 'plat'
) )
version = cls._version_from_metadata(dist_path) or version
return cls( return cls(
location, metadata, project_name=project_name, version=version, location, metadata, project_name=project_name, version=version,
py_version=py_version, platform=platform, **kw py_version=py_version, platform=platform, **kw
) )._reload_version()
@staticmethod def _reload_version(self):
def _version_from_metadata(dist_path): return self
pass
@property @property
def hashcmp(self): def hashcmp(self):
...@@ -2824,8 +2820,7 @@ class Distribution(object): ...@@ -2824,8 +2820,7 @@ class Distribution(object):
class EggInfoDistribution(Distribution): class EggInfoDistribution(Distribution):
@staticmethod def _reload_version(self):
def _version_from_metadata(dist_path):
""" """
Packages installed by distutils (e.g. numpy or scipy), Packages installed by distutils (e.g. numpy or scipy),
which uses an old safe_version, and so which uses an old safe_version, and so
...@@ -2837,13 +2832,9 @@ class EggInfoDistribution(Distribution): ...@@ -2837,13 +2832,9 @@ class EggInfoDistribution(Distribution):
take an extra step and try to get the version number from take an extra step and try to get the version number from
the metadata file itself instead of the filename. the metadata file itself instead of the filename.
""" """
if not os.path.isfile(dist_path): md_version = _version_from_file(self._get_metadata(self.PKG_INFO))
return self._version = md_version or self._version
try: return self
with open(dist_path) as strm:
return _version_from_file(strm)
except IOError:
pass
class DistInfoDistribution(Distribution): class DistInfoDistribution(Distribution):
......
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