Commit 56fcb8fd authored by PJ Eby's avatar PJ Eby

The "egg_info" command now always sets the distribution metadata to "safe"

forms of the distribution name and version, so that distribution files will
be generated with parseable names (i.e., ones that don't include '-' in the
name or version).  Also, this means that if you use the various ``--tag``
options of "egg_info", any distributions generated will use the tags in the
version, not just egg distributions.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041092
parent 5b4efda5
...@@ -1299,7 +1299,7 @@ class Distribution(object): ...@@ -1299,7 +1299,7 @@ class Distribution(object):
except AttributeError: except AttributeError:
for line in self._get_metadata('PKG-INFO'): for line in self._get_metadata('PKG-INFO'):
if line.lower().startswith('version:'): if line.lower().startswith('version:'):
self._version = line.split(':',1)[1].strip() self._version = safe_version(line.split(':',1)[1].strip())
return self._version return self._version
else: else:
raise AttributeError( raise AttributeError(
......
...@@ -60,13 +60,13 @@ class egg_info(Command): ...@@ -60,13 +60,13 @@ class egg_info(Command):
self.ensure_dirname('egg_base') self.ensure_dirname('egg_base')
self.egg_info = os.path.join(self.egg_base, self.egg_name+'.egg-info') self.egg_info = os.path.join(self.egg_base, self.egg_name+'.egg-info')
# Set package version and name for the benefit of dumber commands
# (e.g. sdist, bdist_wininst, etc.) We escape '-' so filenames will
# be more machine-parseable.
#
metadata = self.distribution.metadata
metadata.version = self.egg_version.replace('-','_')
metadata.name = self.egg_name.replace('-','_')
...@@ -90,6 +90,8 @@ class egg_info(Command): ...@@ -90,6 +90,8 @@ class egg_info(Command):
metadata.version, oldver = self.egg_version, metadata.version metadata.version, oldver = self.egg_version, metadata.version
metadata.name, oldname = self.egg_name, metadata.name metadata.name, oldname = self.egg_name, metadata.name
try: try:
# write unescaped data to PKG-INFO, so older pkg_resources
# can still parse it
metadata.write_pkg_info(self.egg_info) metadata.write_pkg_info(self.egg_info)
finally: finally:
metadata.name, metadata.version = oldname, oldver metadata.name, metadata.version = oldname, oldver
...@@ -119,8 +121,6 @@ class egg_info(Command): ...@@ -119,8 +121,6 @@ class egg_info(Command):
f.close() f.close()
def tagged_version(self): def tagged_version(self):
version = self.distribution.get_version() version = self.distribution.get_version()
if self.tag_build: if self.tag_build:
......
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