]> jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/setuptools/command/install_egg_info.py
init: venv aand flask
[dlqueue.git] / venv / lib / python3.11 / site-packages / setuptools / command / install_egg_info.py
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
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', ('install_dir', 'install_dir'))
24 ei_cmd = self.get_finalized_command("egg_info")
25 basename = f"{ei_cmd._get_egg_basename()}.egg-info"
26 self.source = ei_cmd.egg_info
27 self.target = os.path.join(self.install_dir, basename)
28 self.outputs = []
29
30 def run(self):
31 self.run_command('egg_info')
32 if os.path.isdir(self.target) and not os.path.islink(self.target):
33 dir_util.remove_tree(self.target, dry_run=self.dry_run)
34 elif os.path.exists(self.target):
35 self.execute(os.unlink, (self.target,), "Removing " + self.target)
36 if not self.dry_run:
37 ensure_directory(self.target)
38 self.execute(self.copytree, (), "Copying %s to %s" % (self.source, self.target))
39 self.install_namespaces()
40
41 def get_outputs(self):
42 return self.outputs
43
44 def copytree(self):
45 # Copy the .egg-info tree to site-packages
46 def skimmer(src, dst):
47 # filter out source-control directories; note that 'src' is always
48 # a '/'-separated path, regardless of platform. 'dst' is a
49 # platform-specific path.
50 for skip in '.svn/', 'CVS/':
51 if src.startswith(skip) or '/' + skip in src:
52 return None
53 self.outputs.append(dst)
54 log.debug("Copying %s to %s", src, dst)
55 return dst
56
57 unpack_archive(self.source, self.target, skimmer)