Path: blob/main/test/lib/python3.9/site-packages/setuptools/command/install_egg_info.py
4799 views
from distutils import log, dir_util1import os23from setuptools import Command4from setuptools import namespaces5from setuptools.archive_util import unpack_archive6from .._path import ensure_directory7import pkg_resources8910class install_egg_info(namespaces.Installer, Command):11"""Install an .egg-info directory for the package"""1213description = "Install an .egg-info directory for the package"1415user_options = [16('install-dir=', 'd', "directory to install to"),17]1819def initialize_options(self):20self.install_dir = None2122def finalize_options(self):23self.set_undefined_options('install_lib',24('install_dir', 'install_dir'))25ei_cmd = self.get_finalized_command("egg_info")26basename = pkg_resources.Distribution(27None, None, ei_cmd.egg_name, ei_cmd.egg_version28).egg_name() + '.egg-info'29self.source = ei_cmd.egg_info30self.target = os.path.join(self.install_dir, basename)31self.outputs = []3233def run(self):34self.run_command('egg_info')35if os.path.isdir(self.target) and not os.path.islink(self.target):36dir_util.remove_tree(self.target, dry_run=self.dry_run)37elif os.path.exists(self.target):38self.execute(os.unlink, (self.target,), "Removing " + self.target)39if not self.dry_run:40ensure_directory(self.target)41self.execute(42self.copytree, (), "Copying %s to %s" % (self.source, self.target)43)44self.install_namespaces()4546def get_outputs(self):47return self.outputs4849def copytree(self):50# Copy the .egg-info tree to site-packages51def skimmer(src, dst):52# filter out source-control directories; note that 'src' is always53# a '/'-separated path, regardless of platform. 'dst' is a54# platform-specific path.55for skip in '.svn/', 'CVS/':56if src.startswith(skip) or '/' + skip in src:57return None58self.outputs.append(dst)59log.debug("Copying %s to %s", src, dst)60return dst6162unpack_archive(self.source, self.target, skimmer)636465