]> jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/setuptools/command/install.py
init: venv aand flask
[dlqueue.git] / venv / lib / python3.11 / site-packages / setuptools / command / install.py
1 from distutils.errors import DistutilsArgError
2 import inspect
3 import glob
4 import platform
5 import distutils.command.install as orig
6
7 import setuptools
8 from ..warnings import SetuptoolsDeprecationWarning, SetuptoolsWarning
9
10 # Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for
11 # now. See https://github.com/pypa/setuptools/issues/199/
12 _install = orig.install
13
14
15 class install(orig.install):
16 """Use easy_install to install the package, w/dependencies"""
17
18 user_options = orig.install.user_options + [
19 ('old-and-unmanageable', None, "Try not to use this!"),
20 (
21 'single-version-externally-managed',
22 None,
23 "used by system package builders to create 'flat' eggs",
24 ),
25 ]
26 boolean_options = orig.install.boolean_options + [
27 'old-and-unmanageable',
28 'single-version-externally-managed',
29 ]
30 new_commands = [
31 ('install_egg_info', lambda self: True),
32 ('install_scripts', lambda self: True),
33 ]
34 _nc = dict(new_commands)
35
36 def initialize_options(self):
37 SetuptoolsDeprecationWarning.emit(
38 "setup.py install is deprecated.",
39 """
40 Please avoid running ``setup.py`` directly.
41 Instead, use pypa/build, pypa/installer or other
42 standards-based tools.
43 """,
44 see_url="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html",
45 # TODO: Document how to bootstrap setuptools without install
46 # (e.g. by unziping the wheel file)
47 # and then add a due_date to this warning.
48 )
49
50 orig.install.initialize_options(self)
51 self.old_and_unmanageable = None
52 self.single_version_externally_managed = None
53
54 def finalize_options(self):
55 orig.install.finalize_options(self)
56 if self.root:
57 self.single_version_externally_managed = True
58 elif self.single_version_externally_managed:
59 if not self.root and not self.record:
60 raise DistutilsArgError(
61 "You must specify --record or --root when building system"
62 " packages"
63 )
64
65 def handle_extra_path(self):
66 if self.root or self.single_version_externally_managed:
67 # explicit backward-compatibility mode, allow extra_path to work
68 return orig.install.handle_extra_path(self)
69
70 # Ignore extra_path when installing an egg (or being run by another
71 # command without --root or --single-version-externally-managed
72 self.path_file = None
73 self.extra_dirs = ''
74
75 def run(self):
76 # Explicit request for old-style install? Just do it
77 if self.old_and_unmanageable or self.single_version_externally_managed:
78 return orig.install.run(self)
79
80 if not self._called_from_setup(inspect.currentframe()):
81 # Run in backward-compatibility mode to support bdist_* commands.
82 orig.install.run(self)
83 else:
84 self.do_egg_install()
85
86 @staticmethod
87 def _called_from_setup(run_frame):
88 """
89 Attempt to detect whether run() was called from setup() or by another
90 command. If called by setup(), the parent caller will be the
91 'run_command' method in 'distutils.dist', and *its* caller will be
92 the 'run_commands' method. If called any other way, the
93 immediate caller *might* be 'run_command', but it won't have been
94 called by 'run_commands'. Return True in that case or if a call stack
95 is unavailable. Return False otherwise.
96 """
97 if run_frame is None:
98 msg = "Call stack not available. bdist_* commands may fail."
99 SetuptoolsWarning.emit(msg)
100 if platform.python_implementation() == 'IronPython':
101 msg = "For best results, pass -X:Frames to enable call stack."
102 SetuptoolsWarning.emit(msg)
103 return True
104
105 frames = inspect.getouterframes(run_frame)
106 for frame in frames[2:4]:
107 (caller,) = frame[:1]
108 info = inspect.getframeinfo(caller)
109 caller_module = caller.f_globals.get('__name__', '')
110
111 if caller_module == "setuptools.dist" and info.function == "run_command":
112 # Starting from v61.0.0 setuptools overwrites dist.run_command
113 continue
114
115 return caller_module == 'distutils.dist' and info.function == 'run_commands'
116
117 def do_egg_install(self):
118 easy_install = self.distribution.get_command_class('easy_install')
119
120 cmd = easy_install(
121 self.distribution,
122 args="x",
123 root=self.root,
124 record=self.record,
125 )
126 cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
127 cmd.always_copy_from = '.' # make sure local-dir eggs get installed
128
129 # pick up setup-dir .egg files only: no .egg-info
130 cmd.package_index.scan(glob.glob('*.egg'))
131
132 self.run_command('bdist_egg')
133 args = [self.distribution.get_command_obj('bdist_egg').egg_output]
134
135 if setuptools.bootstrap_install_from:
136 # Bootstrap self-installation of setuptools
137 args.insert(0, setuptools.bootstrap_install_from)
138
139 cmd.args = args
140 cmd.run(show_deprecation=False)
141 setuptools.bootstrap_install_from = None
142
143
144 # XXX Python 3.1 doesn't see _nc if this is inside the class
145 install.sub_commands = [
146 cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc
147 ] + install.new_commands