Tarek Ziadé avatar Tarek Ziadé committed d015f9e Draft

make sure the existing metadata Provides field is translated when translating an old PKG-INFO

Comments (0)

Files changed (2)

distutils2/tests/test_util.py

             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@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):
         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)
         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))
             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)

distutils2/util.py

     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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.