Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
keewenaw
GitHub Repository: keewenaw/ethereum-wallet-cracker
Path: blob/main/test/lib/python3.9/site-packages/setuptools/command/install_egg_info.py
4799 views
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
from .._path import ensure_directory
8
import pkg_resources
9
10
11
class install_egg_info(namespaces.Installer, Command):
12
"""Install an .egg-info directory for the package"""
13
14
description = "Install an .egg-info directory for the package"
15
16
user_options = [
17
('install-dir=', 'd', "directory to install to"),
18
]
19
20
def initialize_options(self):
21
self.install_dir = None
22
23
def finalize_options(self):
24
self.set_undefined_options('install_lib',
25
('install_dir', 'install_dir'))
26
ei_cmd = self.get_finalized_command("egg_info")
27
basename = pkg_resources.Distribution(
28
None, None, ei_cmd.egg_name, ei_cmd.egg_version
29
).egg_name() + '.egg-info'
30
self.source = ei_cmd.egg_info
31
self.target = os.path.join(self.install_dir, basename)
32
self.outputs = []
33
34
def run(self):
35
self.run_command('egg_info')
36
if os.path.isdir(self.target) and not os.path.islink(self.target):
37
dir_util.remove_tree(self.target, dry_run=self.dry_run)
38
elif os.path.exists(self.target):
39
self.execute(os.unlink, (self.target,), "Removing " + self.target)
40
if not self.dry_run:
41
ensure_directory(self.target)
42
self.execute(
43
self.copytree, (), "Copying %s to %s" % (self.source, self.target)
44
)
45
self.install_namespaces()
46
47
def get_outputs(self):
48
return self.outputs
49
50
def copytree(self):
51
# Copy the .egg-info tree to site-packages
52
def skimmer(src, dst):
53
# filter out source-control directories; note that 'src' is always
54
# a '/'-separated path, regardless of platform. 'dst' is a
55
# platform-specific path.
56
for skip in '.svn/', 'CVS/':
57
if src.startswith(skip) or '/' + skip in src:
58
return None
59
self.outputs.append(dst)
60
log.debug("Copying %s to %s", src, dst)
61
return dst
62
63
unpack_archive(self.source, self.target, skimmer)
64
65