Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/setuptools/command/install.py
7747 views
from distutils.errors import DistutilsArgError1import inspect2import glob3import warnings4import platform5import distutils.command.install as orig67import setuptools89# Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for10# now. See https://github.com/pypa/setuptools/issues/199/11_install = orig.install121314class install(orig.install):15"""Use easy_install to install the package, w/dependencies"""1617user_options = orig.install.user_options + [18('old-and-unmanageable', None, "Try not to use this!"),19('single-version-externally-managed', None,20"used by system package builders to create 'flat' eggs"),21]22boolean_options = orig.install.boolean_options + [23'old-and-unmanageable', 'single-version-externally-managed',24]25new_commands = [26('install_egg_info', lambda self: True),27('install_scripts', lambda self: True),28]29_nc = dict(new_commands)3031def initialize_options(self):32orig.install.initialize_options(self)33self.old_and_unmanageable = None34self.single_version_externally_managed = None3536def finalize_options(self):37orig.install.finalize_options(self)38if self.root:39self.single_version_externally_managed = True40elif self.single_version_externally_managed:41if not self.root and not self.record:42raise DistutilsArgError(43"You must specify --record or --root when building system"44" packages"45)4647def handle_extra_path(self):48if self.root or self.single_version_externally_managed:49# explicit backward-compatibility mode, allow extra_path to work50return orig.install.handle_extra_path(self)5152# Ignore extra_path when installing an egg (or being run by another53# command without --root or --single-version-externally-managed54self.path_file = None55self.extra_dirs = ''5657def run(self):58# Explicit request for old-style install? Just do it59if self.old_and_unmanageable or self.single_version_externally_managed:60return orig.install.run(self)6162if not self._called_from_setup(inspect.currentframe()):63# Run in backward-compatibility mode to support bdist_* commands.64orig.install.run(self)65else:66self.do_egg_install()6768@staticmethod69def _called_from_setup(run_frame):70"""71Attempt to detect whether run() was called from setup() or by another72command. If called by setup(), the parent caller will be the73'run_command' method in 'distutils.dist', and *its* caller will be74the 'run_commands' method. If called any other way, the75immediate caller *might* be 'run_command', but it won't have been76called by 'run_commands'. Return True in that case or if a call stack77is unavailable. Return False otherwise.78"""79if run_frame is None:80msg = "Call stack not available. bdist_* commands may fail."81warnings.warn(msg)82if platform.python_implementation() == 'IronPython':83msg = "For best results, pass -X:Frames to enable call stack."84warnings.warn(msg)85return True86res = inspect.getouterframes(run_frame)[2]87caller, = res[:1]88info = inspect.getframeinfo(caller)89caller_module = caller.f_globals.get('__name__', '')90return (91caller_module == 'distutils.dist'92and info.function == 'run_commands'93)9495def do_egg_install(self):9697easy_install = self.distribution.get_command_class('easy_install')9899cmd = easy_install(100self.distribution, args="x", root=self.root, record=self.record,101)102cmd.ensure_finalized() # finalize before bdist_egg munges install cmd103cmd.always_copy_from = '.' # make sure local-dir eggs get installed104105# pick up setup-dir .egg files only: no .egg-info106cmd.package_index.scan(glob.glob('*.egg'))107108self.run_command('bdist_egg')109args = [self.distribution.get_command_obj('bdist_egg').egg_output]110111if setuptools.bootstrap_install_from:112# Bootstrap self-installation of setuptools113args.insert(0, setuptools.bootstrap_install_from)114115cmd.args = args116cmd.run(show_deprecation=False)117setuptools.bootstrap_install_from = None118119120# XXX Python 3.1 doesn't see _nc if this is inside the class121install.sub_commands = (122[cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc] +123install.new_commands124)125126127