[Python-checkins] distutils2: make sure the existing metadata Provides field is translated when translating
tarek.ziade
python-checkins at python.org
Wed May 16 14:22:49 CEST 2012
http://hg.python.org/distutils2/rev/d015f9edccb8
changeset: 1341:d015f9edccb8
user: Tarek Ziade <tarek at ziade.org>
date: Wed May 16 14:22:44 2012 +0200
summary:
make sure the existing metadata Provides field is translated when translating an old PKG-INFO
files:
distutils2/tests/test_util.py | 45 +++++++++++++++++++---
distutils2/util.py | 11 ++++-
2 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/distutils2/tests/test_util.py b/distutils2/tests/test_util.py
--- a/distutils2/tests/test_util.py
+++ b/distutils2/tests/test_util.py
@@ -756,6 +756,31 @@
self.assertRaises(ValueError, iglob, pattern)
+PKG_INFO = '''\
+Metadata-Version: 1.1
+Name: hello
+Version: 0.1.1
+Summary: Hello World
+Home-page: https://example.com
+Author: John Doe
+Author-email: j.doe at example.com
+License: UNKNOWN
+Download-URL: https://example.com/tarball/master
+Description: UNKNOWN
+Platform: Any
+Classifier: Development Status :: 3 - Alpha
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Intended Audience :: Developers
+Classifier: Environment :: Console
+Provides: hello
+'''
+
+
class EggInfoToDistInfoTestCase(support.TempdirManager,
support.LoggingCatcher,
unittest.TestCase):
@@ -774,10 +799,14 @@
dirs = [egginfo]
files = ['hello.py', 'hello.pyc']
extra_metadata = ['dependency_links.txt', 'entry_points.txt',
- 'not-zip-safe', 'PKG-INFO', 'top_level.txt',
- 'SOURCES.txt']
+ 'not-zip-safe', ('PKG-INFO', PKG_INFO),
+ 'top_level.txt', 'SOURCES.txt']
for f in extra_metadata:
- files.append(os.path.join(egginfo, f))
+ if isinstance(f, tuple):
+ f, content = f
+ else:
+ content = 'XXX'
+ files.append((os.path.join(egginfo, f), content))
tempdir, record_file = self.build_dist_tree(files, dirs)
distinfo_path = os.path.join(tempdir, distinfo)
@@ -796,13 +825,12 @@
distinfo = 'hello-0.1.1-py3.3.dist-info'
egginfo = 'hello-0.1.1-py3.3.egg-info'
# egginfo is a file in distutils which contains the metadata
- files = ['hello.py', 'hello.pyc', egginfo]
+ files = ['hello.py', 'hello.pyc', (egginfo, PKG_INFO)]
tempdir, record_file = self.build_dist_tree(files, dirs=[])
distinfo_path = os.path.join(tempdir, distinfo)
egginfo_path = os.path.join(tempdir, egginfo)
metadata_file_paths = self.get_metadata_file_paths(distinfo_path)
-
egginfo_to_distinfo(record_file)
# test that directories and files get created
self.assertTrue(os.path.isdir(distinfo_path))
@@ -820,10 +848,15 @@
os.makedirs(path)
dir_paths.append(path)
for f in files:
+ if isinstance(f, (list, tuple)):
+ f, content = f
+ else:
+ content = ''
+
path = os.path.join(tempdir, f)
_f = open(path, 'w')
try:
- _f.write(f)
+ _f.write(content)
finally:
_f.close()
file_paths.append(path)
diff --git a/distutils2/util.py b/distutils2/util.py
--- a/distutils2/util.py
+++ b/distutils2/util.py
@@ -1272,11 +1272,18 @@
requires = None
req_path = os.path.join(distinfo_dir, 'requires.txt')
requires = parse_requires(req_path)
+
+ # adapting the metadata
+ metadata = Metadata(path=metadata_path)
+ if metadata['Provides'] != []:
+ metadata['Provides-Dist'] = metadata['Provides']
+ metadata['Provides'] = []
+
if requires is not None:
# create a metadata instance to handle the reqs injection
- metadata = Metadata(path=metadata_path)
metadata['Requires-Dist'] = requires
- metadata.write(metadata_path)
+
+ metadata.write(metadata_path)
installer_path = distinfo['installer_path']
logger.info('creating %s', installer_path)
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list