示例#1
0
 def test_package_data(self):
     data = get_package_data(name='config', version='0.3.6')
     self.assertTrue(data)
     self.assertTrue('index-metadata' in data)
     metadata = data['index-metadata']
     self.assertEqual(metadata['name'], 'config')
     self.assertEqual(metadata['version'], '0.3.6')
     data = get_package_data(name='config', version='0.3.5')
     self.assertFalse(data)
示例#2
0
 def test_package_data(self):
     data = get_package_data(name='config', version='0.3.6')
     self.assertTrue(data)
     self.assertTrue('index-metadata' in data)
     metadata = data['index-metadata']
     self.assertEqual(metadata['name'], 'config')
     self.assertEqual(metadata['version'], '0.3.6')
     data = get_package_data(name='config', version='0.3.5')
     self.assertFalse(data)
示例#3
0
 def test_package_data(self):
     data = get_package_data(Container(name='config', version='0.3.6',
                             metadata=None))
     self.assertTrue(data)
     self.assertTrue('metadata' in data)
     metadata = data['metadata']
     self.assertEqual(metadata['name'], 'config')
     self.assertEqual(metadata['version'], '0.3.6')
     data = get_package_data(Container(name='config', version='0.3.5',
                             metadata=None))
     self.assertFalse(data)
示例#4
0
def convert_egg_info(libdir, prefix, options):
    files = os.listdir(libdir)
    ei = list(filter(lambda d: d.endswith('.egg-info'), files))[0]
    olddn = os.path.join(libdir, ei)
    di = EGG_INFO_RE.sub('.dist-info', ei)
    newdn = os.path.join(libdir, di)
    os.rename(olddn, newdn)
    if options.compatible:
        renames = {}
    else:
        renames = {
            'entry_points.txt': 'EXPORTS',
        }
    excludes = set([
        'SOURCES.txt',          # of no interest in/post WHEEL
        'installed-files.txt',  # replaced by RECORD, so not needed
        'requires.txt',         # added to METADATA, so not needed
        'PKG-INFO',             # replaced by METADATA
        'not-zip-safe',         # not applicable
    ])
    files = os.listdir(newdn)
    metadata = mdname = reqts = None
    for oldfn in files:
        pn = os.path.join(newdn, oldfn)
        if oldfn in renames:
            os.rename(pn, os.path.join(newdn, renames[oldfn]))
        else:
            if oldfn == 'requires.txt':
                with open(pn, 'r') as f:
                    reqts = get_requirements(f.read())
            elif oldfn == 'PKG-INFO':
                metadata = Metadata(path=pn)
                pd = get_package_data(metadata.name, metadata.version)
                metadata = Metadata(mapping=pd['index-metadata'])
                mdname = os.path.join(newdn, 'pydist.json')
            if oldfn in excludes or not options.compatible:
                os.remove(pn)
    if metadata:
        # Use Metadata 1.2 or later
        metadata.provides += ['%s (%s)' % (metadata.name,
                                           metadata.version)]
        # Update if not set up by get_package_data
        if reqts and not metadata.run_requires:
            metadata.dependencies = reqts
        metadata.write(path=mdname)
    manifest = Manifest(os.path.dirname(libdir))
    manifest.findall()
    paths = manifest.allfiles
    dp = DistributionPath([libdir])
    dist = next(dp.get_distributions())
    dist.write_installed_files(paths, prefix)