comparison lib/python3.8/site-packages/setuptools/command/install_egg_info.py @ 0:9e54283cc701 draft

"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author guerler
date Mon, 27 Jul 2020 03:47:31 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:9e54283cc701
1 from distutils import log, dir_util
2 import os
3
4 from setuptools import Command
5 from setuptools import namespaces
6 from setuptools.archive_util import unpack_archive
7 import pkg_resources
8
9
10 class install_egg_info(namespaces.Installer, Command):
11 """Install an .egg-info directory for the package"""
12
13 description = "Install an .egg-info directory for the package"
14
15 user_options = [
16 ('install-dir=', 'd', "directory to install to"),
17 ]
18
19 def initialize_options(self):
20 self.install_dir = None
21
22 def finalize_options(self):
23 self.set_undefined_options('install_lib',
24 ('install_dir', 'install_dir'))
25 ei_cmd = self.get_finalized_command("egg_info")
26 basename = pkg_resources.Distribution(
27 None, None, ei_cmd.egg_name, ei_cmd.egg_version
28 ).egg_name() + '.egg-info'
29 self.source = ei_cmd.egg_info
30 self.target = os.path.join(self.install_dir, basename)
31 self.outputs = []
32
33 def run(self):
34 self.run_command('egg_info')
35 if os.path.isdir(self.target) and not os.path.islink(self.target):
36 dir_util.remove_tree(self.target, dry_run=self.dry_run)
37 elif os.path.exists(self.target):
38 self.execute(os.unlink, (self.target,), "Removing " + self.target)
39 if not self.dry_run:
40 pkg_resources.ensure_directory(self.target)
41 self.execute(
42 self.copytree, (), "Copying %s to %s" % (self.source, self.target)
43 )
44 self.install_namespaces()
45
46 def get_outputs(self):
47 return self.outputs
48
49 def copytree(self):
50 # Copy the .egg-info tree to site-packages
51 def skimmer(src, dst):
52 # filter out source-control directories; note that 'src' is always
53 # a '/'-separated path, regardless of platform. 'dst' is a
54 # platform-specific path.
55 for skip in '.svn/', 'CVS/':
56 if src.startswith(skip) or '/' + skip in src:
57 return None
58 self.outputs.append(dst)
59 log.debug("Copying %s to %s", src, dst)
60 return dst
61
62 unpack_archive(self.source, self.target, skimmer)