def do_build_and_install(self, dist): srcdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, srcdir) dstdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, dstdir) paths = install_dist(dist, srcdir) paths['prefix'] = srcdir w = Wheel() w.name = paths.pop('name') w.version = paths.pop('version') w.dirname = srcdir pathname = w.build(paths) self.assertTrue(os.path.exists(pathname)) paths = {'prefix': dstdir} for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): paths[key] = os.path.join(dstdir, key) w = Wheel(pathname) executable = os.path.join(paths['scripts'], 'python') dist = w.install(paths, executable=executable) self.assertIsNotNone(dist) self.assertEqual(dist.name, w.name) self.assertEqual(dist.version, w.version) os.remove(pathname) sm = Manifest(srcdir) sm.findall() sfiles = set([os.path.relpath(p, srcdir) for p in sm.allfiles]) dm = Manifest(dstdir) dm.findall() dfiles = set([os.path.relpath(p, dstdir) for p in dm.allfiles]) omitted = sfiles - dfiles omitted = omitted.pop() endings = os.path.join('.dist-info', 'WHEEL'), '.pyc', '.pyo' self.assertTrue(omitted.endswith(endings))
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)
def convert_egg_info(libdir, prefix): 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) files = os.listdir(newdn) for oldfn in files: pn = os.path.join(newdn, oldfn) if oldfn == 'PKG-INFO': md = Metadata(path=pn) mn = os.path.join(newdn, METADATA_FILENAME) md.write(mn) os.remove(pn) manifest = Manifest(os.path.dirname(libdir)) manifest.findall() dp = DistributionPath([libdir]) dist = next(dp.get_distributions()) dist.write_installed_files(manifest.allfiles, prefix)
def convert_egg_info(libdir, prefix): 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) renames = { 'PKG-INFO': 'METADATA', } files = os.listdir(newdn) for oldfn in files: pn = os.path.join(newdn, oldfn) if oldfn in renames: os.rename(pn, os.path.join(newdn, renames[oldfn])) else: os.remove(pn) manifest = Manifest(os.path.dirname(libdir)) manifest.findall() dp = DistributionPath([libdir]) dist = next(dp.get_distributions()) dist.write_installed_files(manifest.allfiles, prefix)
def do_build_and_install(self, dist): srcdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, srcdir) dstdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, dstdir) paths = install_dist(dist, srcdir) paths['prefix'] = srcdir w = Wheel() w.name = paths.pop('name') w.version = paths.pop('version') w.dirname = srcdir pathname = w.build(paths) self.assertTrue(os.path.exists(pathname)) paths = {'prefix': dstdir} for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): paths[key] = os.path.join(dstdir, key) w = Wheel(pathname) maker = ScriptMaker(None, None, add_launchers=False) maker.executable = os.path.join(paths['scripts'], 'python') dist = w.install(paths, maker) self.assertIsNotNone(dist) self.assertEqual(dist.name, w.name) self.assertEqual(dist.version, w.version) shared = dist.shared_locations self.assertTrue(shared) os.remove(pathname) sm = Manifest(srcdir) sm.findall() sfiles = set([os.path.relpath(p, srcdir) for p in sm.allfiles]) dm = Manifest(dstdir) dm.findall() dfiles = set([os.path.relpath(p, dstdir) for p in dm.allfiles]) omitted = sfiles - dfiles omitted = omitted.pop() endings = os.path.join('.dist-info', 'WHEEL'), '.pyc', '.pyo' self.assertTrue(omitted.endswith(endings))
def do_build_and_install(self, dist): srcdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, srcdir) dstdir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, dstdir) paths = install_dist(dist, srcdir) paths["prefix"] = srcdir w = Wheel() w.name = paths.pop("name") w.version = paths.pop("version") w.dirname = srcdir pathname = w.build(paths) self.assertTrue(os.path.exists(pathname)) paths = {"prefix": dstdir} for key in ("purelib", "platlib", "headers", "scripts", "data"): paths[key] = os.path.join(dstdir, key) w = Wheel(pathname) maker = ScriptMaker(None, None, add_launchers=False) maker.executable = os.path.join(paths["scripts"], "python") dist = w.install(paths, maker) self.assertIsNotNone(dist) self.assertEqual(dist.name, w.name) self.assertEqual(dist.version, w.version) shared = dist.shared_locations self.assertTrue(shared) os.remove(pathname) sm = Manifest(srcdir) sm.findall() sfiles = set([os.path.relpath(p, srcdir) for p in sm.allfiles]) dm = Manifest(dstdir) dm.findall() dfiles = set([os.path.relpath(p, dstdir) for p in dm.allfiles]) omitted = sfiles - dfiles omitted = omitted.pop() endings = os.path.join(".dist-info", "WHEEL"), ".pyc", ".pyo" self.assertTrue(omitted.endswith(endings))