Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- scripts/myenv/lib/python3.10/site-packages/distutils-precedence.pth +3 -0
- scripts/myenv/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/__pycache__/utils.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/__pycache__/setup.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/setup.py +6 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/__init__.py +242 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/_deprecation_warning.py +7 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/_vendor/__init__.py +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/_vendor/__pycache__/ordered_set.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/_vendor/pyparsing.py +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/archive_util.py +205 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/build_meta.py +290 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/cli-32.exe +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/cli-64.exe +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/cli-arm64.exe +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/cli.exe +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__init__.py +8 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/__init__.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/alias.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_rpm.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/build_py.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/develop.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/easy_install.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/egg_info.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/install.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/install_egg_info.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/install_lib.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/sdist.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/setopt.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/upload.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/upload_docs.cpython-310.pyc +0 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/alias.py +78 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/bdist_egg.py +456 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/bdist_rpm.py +40 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/build_clib.py +101 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/build_ext.py +328 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/build_py.py +242 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/develop.py +193 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/dist_info.py +36 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/easy_install.py +2354 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/egg_info.py +755 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/install.py +132 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/install_egg_info.py +82 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/install_lib.py +148 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/install_scripts.py +69 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/launcher manifest.xml +15 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/py36compat.py +134 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/register.py +18 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/rotate.py +64 -0
- scripts/myenv/lib/python3.10/site-packages/setuptools/command/saveopts.py +22 -0
scripts/myenv/lib/python3.10/site-packages/distutils-precedence.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ea7ffef3fe2a117ee12c68ed6553617f0d7fd2f0590257c25c484959a3b7373
|
3 |
+
size 152
|
scripts/myenv/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/__pycache__/utils.cpython-310.pyc
ADDED
Binary file (3.59 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/__pycache__/setup.cpython-310.pyc
ADDED
Binary file (324 Bytes). View file
|
|
scripts/myenv/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/setup.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import setuptools
|
2 |
+
setuptools.setup(
|
3 |
+
name="my-test-package",
|
4 |
+
version="1.0",
|
5 |
+
zip_safe=True,
|
6 |
+
)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/__init__.py
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Extensions to the 'distutils' for large or complex distributions"""
|
2 |
+
|
3 |
+
from fnmatch import fnmatchcase
|
4 |
+
import functools
|
5 |
+
import os
|
6 |
+
import re
|
7 |
+
|
8 |
+
import _distutils_hack.override # noqa: F401
|
9 |
+
|
10 |
+
import distutils.core
|
11 |
+
from distutils.errors import DistutilsOptionError
|
12 |
+
from distutils.util import convert_path
|
13 |
+
|
14 |
+
from ._deprecation_warning import SetuptoolsDeprecationWarning
|
15 |
+
|
16 |
+
import setuptools.version
|
17 |
+
from setuptools.extension import Extension
|
18 |
+
from setuptools.dist import Distribution
|
19 |
+
from setuptools.depends import Require
|
20 |
+
from . import monkey
|
21 |
+
|
22 |
+
|
23 |
+
__all__ = [
|
24 |
+
'setup',
|
25 |
+
'Distribution',
|
26 |
+
'Command',
|
27 |
+
'Extension',
|
28 |
+
'Require',
|
29 |
+
'SetuptoolsDeprecationWarning',
|
30 |
+
'find_packages',
|
31 |
+
'find_namespace_packages',
|
32 |
+
]
|
33 |
+
|
34 |
+
__version__ = setuptools.version.__version__
|
35 |
+
|
36 |
+
bootstrap_install_from = None
|
37 |
+
|
38 |
+
|
39 |
+
class PackageFinder:
|
40 |
+
"""
|
41 |
+
Generate a list of all Python packages found within a directory
|
42 |
+
"""
|
43 |
+
|
44 |
+
@classmethod
|
45 |
+
def find(cls, where='.', exclude=(), include=('*',)):
|
46 |
+
"""Return a list all Python packages found within directory 'where'
|
47 |
+
|
48 |
+
'where' is the root directory which will be searched for packages. It
|
49 |
+
should be supplied as a "cross-platform" (i.e. URL-style) path; it will
|
50 |
+
be converted to the appropriate local path syntax.
|
51 |
+
|
52 |
+
'exclude' is a sequence of package names to exclude; '*' can be used
|
53 |
+
as a wildcard in the names, such that 'foo.*' will exclude all
|
54 |
+
subpackages of 'foo' (but not 'foo' itself).
|
55 |
+
|
56 |
+
'include' is a sequence of package names to include. If it's
|
57 |
+
specified, only the named packages will be included. If it's not
|
58 |
+
specified, all found packages will be included. 'include' can contain
|
59 |
+
shell style wildcard patterns just like 'exclude'.
|
60 |
+
"""
|
61 |
+
|
62 |
+
return list(
|
63 |
+
cls._find_packages_iter(
|
64 |
+
convert_path(where),
|
65 |
+
cls._build_filter('ez_setup', '*__pycache__', *exclude),
|
66 |
+
cls._build_filter(*include),
|
67 |
+
)
|
68 |
+
)
|
69 |
+
|
70 |
+
@classmethod
|
71 |
+
def _find_packages_iter(cls, where, exclude, include):
|
72 |
+
"""
|
73 |
+
All the packages found in 'where' that pass the 'include' filter, but
|
74 |
+
not the 'exclude' filter.
|
75 |
+
"""
|
76 |
+
for root, dirs, files in os.walk(where, followlinks=True):
|
77 |
+
# Copy dirs to iterate over it, then empty dirs.
|
78 |
+
all_dirs = dirs[:]
|
79 |
+
dirs[:] = []
|
80 |
+
|
81 |
+
for dir in all_dirs:
|
82 |
+
full_path = os.path.join(root, dir)
|
83 |
+
rel_path = os.path.relpath(full_path, where)
|
84 |
+
package = rel_path.replace(os.path.sep, '.')
|
85 |
+
|
86 |
+
# Skip directory trees that are not valid packages
|
87 |
+
if '.' in dir or not cls._looks_like_package(full_path):
|
88 |
+
continue
|
89 |
+
|
90 |
+
# Should this package be included?
|
91 |
+
if include(package) and not exclude(package):
|
92 |
+
yield package
|
93 |
+
|
94 |
+
# Keep searching subdirectories, as there may be more packages
|
95 |
+
# down there, even if the parent was excluded.
|
96 |
+
dirs.append(dir)
|
97 |
+
|
98 |
+
@staticmethod
|
99 |
+
def _looks_like_package(path):
|
100 |
+
"""Does a directory look like a package?"""
|
101 |
+
return os.path.isfile(os.path.join(path, '__init__.py'))
|
102 |
+
|
103 |
+
@staticmethod
|
104 |
+
def _build_filter(*patterns):
|
105 |
+
"""
|
106 |
+
Given a list of patterns, return a callable that will be true only if
|
107 |
+
the input matches at least one of the patterns.
|
108 |
+
"""
|
109 |
+
return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)
|
110 |
+
|
111 |
+
|
112 |
+
class PEP420PackageFinder(PackageFinder):
|
113 |
+
@staticmethod
|
114 |
+
def _looks_like_package(path):
|
115 |
+
return True
|
116 |
+
|
117 |
+
|
118 |
+
find_packages = PackageFinder.find
|
119 |
+
find_namespace_packages = PEP420PackageFinder.find
|
120 |
+
|
121 |
+
|
122 |
+
def _install_setup_requires(attrs):
|
123 |
+
# Note: do not use `setuptools.Distribution` directly, as
|
124 |
+
# our PEP 517 backend patch `distutils.core.Distribution`.
|
125 |
+
class MinimalDistribution(distutils.core.Distribution):
|
126 |
+
"""
|
127 |
+
A minimal version of a distribution for supporting the
|
128 |
+
fetch_build_eggs interface.
|
129 |
+
"""
|
130 |
+
|
131 |
+
def __init__(self, attrs):
|
132 |
+
_incl = 'dependency_links', 'setup_requires'
|
133 |
+
filtered = {k: attrs[k] for k in set(_incl) & set(attrs)}
|
134 |
+
distutils.core.Distribution.__init__(self, filtered)
|
135 |
+
|
136 |
+
def finalize_options(self):
|
137 |
+
"""
|
138 |
+
Disable finalize_options to avoid building the working set.
|
139 |
+
Ref #2158.
|
140 |
+
"""
|
141 |
+
|
142 |
+
dist = MinimalDistribution(attrs)
|
143 |
+
|
144 |
+
# Honor setup.cfg's options.
|
145 |
+
dist.parse_config_files(ignore_option_errors=True)
|
146 |
+
if dist.setup_requires:
|
147 |
+
dist.fetch_build_eggs(dist.setup_requires)
|
148 |
+
|
149 |
+
|
150 |
+
def setup(**attrs):
|
151 |
+
# Make sure we have any requirements needed to interpret 'attrs'.
|
152 |
+
_install_setup_requires(attrs)
|
153 |
+
return distutils.core.setup(**attrs)
|
154 |
+
|
155 |
+
|
156 |
+
setup.__doc__ = distutils.core.setup.__doc__
|
157 |
+
|
158 |
+
|
159 |
+
_Command = monkey.get_unpatched(distutils.core.Command)
|
160 |
+
|
161 |
+
|
162 |
+
class Command(_Command):
|
163 |
+
__doc__ = _Command.__doc__
|
164 |
+
|
165 |
+
command_consumes_arguments = False
|
166 |
+
|
167 |
+
def __init__(self, dist, **kw):
|
168 |
+
"""
|
169 |
+
Construct the command for dist, updating
|
170 |
+
vars(self) with any keyword parameters.
|
171 |
+
"""
|
172 |
+
_Command.__init__(self, dist)
|
173 |
+
vars(self).update(kw)
|
174 |
+
|
175 |
+
def _ensure_stringlike(self, option, what, default=None):
|
176 |
+
val = getattr(self, option)
|
177 |
+
if val is None:
|
178 |
+
setattr(self, option, default)
|
179 |
+
return default
|
180 |
+
elif not isinstance(val, str):
|
181 |
+
raise DistutilsOptionError(
|
182 |
+
"'%s' must be a %s (got `%s`)" % (option, what, val)
|
183 |
+
)
|
184 |
+
return val
|
185 |
+
|
186 |
+
def ensure_string_list(self, option):
|
187 |
+
r"""Ensure that 'option' is a list of strings. If 'option' is
|
188 |
+
currently a string, we split it either on /,\s*/ or /\s+/, so
|
189 |
+
"foo bar baz", "foo,bar,baz", and "foo, bar baz" all become
|
190 |
+
["foo", "bar", "baz"].
|
191 |
+
"""
|
192 |
+
val = getattr(self, option)
|
193 |
+
if val is None:
|
194 |
+
return
|
195 |
+
elif isinstance(val, str):
|
196 |
+
setattr(self, option, re.split(r',\s*|\s+', val))
|
197 |
+
else:
|
198 |
+
if isinstance(val, list):
|
199 |
+
ok = all(isinstance(v, str) for v in val)
|
200 |
+
else:
|
201 |
+
ok = False
|
202 |
+
if not ok:
|
203 |
+
raise DistutilsOptionError(
|
204 |
+
"'%s' must be a list of strings (got %r)" % (option, val)
|
205 |
+
)
|
206 |
+
|
207 |
+
def reinitialize_command(self, command, reinit_subcommands=0, **kw):
|
208 |
+
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
|
209 |
+
vars(cmd).update(kw)
|
210 |
+
return cmd
|
211 |
+
|
212 |
+
|
213 |
+
def _find_all_simple(path):
|
214 |
+
"""
|
215 |
+
Find all files under 'path'
|
216 |
+
"""
|
217 |
+
results = (
|
218 |
+
os.path.join(base, file)
|
219 |
+
for base, dirs, files in os.walk(path, followlinks=True)
|
220 |
+
for file in files
|
221 |
+
)
|
222 |
+
return filter(os.path.isfile, results)
|
223 |
+
|
224 |
+
|
225 |
+
def findall(dir=os.curdir):
|
226 |
+
"""
|
227 |
+
Find all files under 'dir' and return the list of full filenames.
|
228 |
+
Unless dir is '.', return full filenames with dir prepended.
|
229 |
+
"""
|
230 |
+
files = _find_all_simple(dir)
|
231 |
+
if dir == os.curdir:
|
232 |
+
make_rel = functools.partial(os.path.relpath, start=dir)
|
233 |
+
files = map(make_rel, files)
|
234 |
+
return list(files)
|
235 |
+
|
236 |
+
|
237 |
+
class sic(str):
|
238 |
+
"""Treat this string as-is (https://en.wikipedia.org/wiki/Sic)"""
|
239 |
+
|
240 |
+
|
241 |
+
# Apply monkey patches
|
242 |
+
monkey.patch_all()
|
scripts/myenv/lib/python3.10/site-packages/setuptools/_deprecation_warning.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class SetuptoolsDeprecationWarning(Warning):
|
2 |
+
"""
|
3 |
+
Base class for warning deprecations in ``setuptools``
|
4 |
+
|
5 |
+
This class is not derived from ``DeprecationWarning``, and as such is
|
6 |
+
visible by default.
|
7 |
+
"""
|
scripts/myenv/lib/python3.10/site-packages/setuptools/_vendor/__init__.py
ADDED
File without changes
|
scripts/myenv/lib/python3.10/site-packages/setuptools/_vendor/__pycache__/ordered_set.cpython-310.pyc
ADDED
Binary file (16.3 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/_vendor/pyparsing.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/archive_util.py
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Utilities for extracting common archive formats"""
|
2 |
+
|
3 |
+
import zipfile
|
4 |
+
import tarfile
|
5 |
+
import os
|
6 |
+
import shutil
|
7 |
+
import posixpath
|
8 |
+
import contextlib
|
9 |
+
from distutils.errors import DistutilsError
|
10 |
+
|
11 |
+
from pkg_resources import ensure_directory
|
12 |
+
|
13 |
+
__all__ = [
|
14 |
+
"unpack_archive", "unpack_zipfile", "unpack_tarfile", "default_filter",
|
15 |
+
"UnrecognizedFormat", "extraction_drivers", "unpack_directory",
|
16 |
+
]
|
17 |
+
|
18 |
+
|
19 |
+
class UnrecognizedFormat(DistutilsError):
|
20 |
+
"""Couldn't recognize the archive type"""
|
21 |
+
|
22 |
+
|
23 |
+
def default_filter(src, dst):
|
24 |
+
"""The default progress/filter callback; returns True for all files"""
|
25 |
+
return dst
|
26 |
+
|
27 |
+
|
28 |
+
def unpack_archive(
|
29 |
+
filename, extract_dir, progress_filter=default_filter,
|
30 |
+
drivers=None):
|
31 |
+
"""Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``
|
32 |
+
|
33 |
+
`progress_filter` is a function taking two arguments: a source path
|
34 |
+
internal to the archive ('/'-separated), and a filesystem path where it
|
35 |
+
will be extracted. The callback must return the desired extract path
|
36 |
+
(which may be the same as the one passed in), or else ``None`` to skip
|
37 |
+
that file or directory. The callback can thus be used to report on the
|
38 |
+
progress of the extraction, as well as to filter the items extracted or
|
39 |
+
alter their extraction paths.
|
40 |
+
|
41 |
+
`drivers`, if supplied, must be a non-empty sequence of functions with the
|
42 |
+
same signature as this function (minus the `drivers` argument), that raise
|
43 |
+
``UnrecognizedFormat`` if they do not support extracting the designated
|
44 |
+
archive type. The `drivers` are tried in sequence until one is found that
|
45 |
+
does not raise an error, or until all are exhausted (in which case
|
46 |
+
``UnrecognizedFormat`` is raised). If you do not supply a sequence of
|
47 |
+
drivers, the module's ``extraction_drivers`` constant will be used, which
|
48 |
+
means that ``unpack_zipfile`` and ``unpack_tarfile`` will be tried, in that
|
49 |
+
order.
|
50 |
+
"""
|
51 |
+
for driver in drivers or extraction_drivers:
|
52 |
+
try:
|
53 |
+
driver(filename, extract_dir, progress_filter)
|
54 |
+
except UnrecognizedFormat:
|
55 |
+
continue
|
56 |
+
else:
|
57 |
+
return
|
58 |
+
else:
|
59 |
+
raise UnrecognizedFormat(
|
60 |
+
"Not a recognized archive type: %s" % filename
|
61 |
+
)
|
62 |
+
|
63 |
+
|
64 |
+
def unpack_directory(filename, extract_dir, progress_filter=default_filter):
|
65 |
+
""""Unpack" a directory, using the same interface as for archives
|
66 |
+
|
67 |
+
Raises ``UnrecognizedFormat`` if `filename` is not a directory
|
68 |
+
"""
|
69 |
+
if not os.path.isdir(filename):
|
70 |
+
raise UnrecognizedFormat("%s is not a directory" % filename)
|
71 |
+
|
72 |
+
paths = {
|
73 |
+
filename: ('', extract_dir),
|
74 |
+
}
|
75 |
+
for base, dirs, files in os.walk(filename):
|
76 |
+
src, dst = paths[base]
|
77 |
+
for d in dirs:
|
78 |
+
paths[os.path.join(base, d)] = src + d + '/', os.path.join(dst, d)
|
79 |
+
for f in files:
|
80 |
+
target = os.path.join(dst, f)
|
81 |
+
target = progress_filter(src + f, target)
|
82 |
+
if not target:
|
83 |
+
# skip non-files
|
84 |
+
continue
|
85 |
+
ensure_directory(target)
|
86 |
+
f = os.path.join(base, f)
|
87 |
+
shutil.copyfile(f, target)
|
88 |
+
shutil.copystat(f, target)
|
89 |
+
|
90 |
+
|
91 |
+
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
|
92 |
+
"""Unpack zip `filename` to `extract_dir`
|
93 |
+
|
94 |
+
Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
|
95 |
+
by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation
|
96 |
+
of the `progress_filter` argument.
|
97 |
+
"""
|
98 |
+
|
99 |
+
if not zipfile.is_zipfile(filename):
|
100 |
+
raise UnrecognizedFormat("%s is not a zip file" % (filename,))
|
101 |
+
|
102 |
+
with zipfile.ZipFile(filename) as z:
|
103 |
+
for info in z.infolist():
|
104 |
+
name = info.filename
|
105 |
+
|
106 |
+
# don't extract absolute paths or ones with .. in them
|
107 |
+
if name.startswith('/') or '..' in name.split('/'):
|
108 |
+
continue
|
109 |
+
|
110 |
+
target = os.path.join(extract_dir, *name.split('/'))
|
111 |
+
target = progress_filter(name, target)
|
112 |
+
if not target:
|
113 |
+
continue
|
114 |
+
if name.endswith('/'):
|
115 |
+
# directory
|
116 |
+
ensure_directory(target)
|
117 |
+
else:
|
118 |
+
# file
|
119 |
+
ensure_directory(target)
|
120 |
+
data = z.read(info.filename)
|
121 |
+
with open(target, 'wb') as f:
|
122 |
+
f.write(data)
|
123 |
+
unix_attributes = info.external_attr >> 16
|
124 |
+
if unix_attributes:
|
125 |
+
os.chmod(target, unix_attributes)
|
126 |
+
|
127 |
+
|
128 |
+
def _resolve_tar_file_or_dir(tar_obj, tar_member_obj):
|
129 |
+
"""Resolve any links and extract link targets as normal files."""
|
130 |
+
while tar_member_obj is not None and (
|
131 |
+
tar_member_obj.islnk() or tar_member_obj.issym()):
|
132 |
+
linkpath = tar_member_obj.linkname
|
133 |
+
if tar_member_obj.issym():
|
134 |
+
base = posixpath.dirname(tar_member_obj.name)
|
135 |
+
linkpath = posixpath.join(base, linkpath)
|
136 |
+
linkpath = posixpath.normpath(linkpath)
|
137 |
+
tar_member_obj = tar_obj._getmember(linkpath)
|
138 |
+
|
139 |
+
is_file_or_dir = (
|
140 |
+
tar_member_obj is not None and
|
141 |
+
(tar_member_obj.isfile() or tar_member_obj.isdir())
|
142 |
+
)
|
143 |
+
if is_file_or_dir:
|
144 |
+
return tar_member_obj
|
145 |
+
|
146 |
+
raise LookupError('Got unknown file type')
|
147 |
+
|
148 |
+
|
149 |
+
def _iter_open_tar(tar_obj, extract_dir, progress_filter):
|
150 |
+
"""Emit member-destination pairs from a tar archive."""
|
151 |
+
# don't do any chowning!
|
152 |
+
tar_obj.chown = lambda *args: None
|
153 |
+
|
154 |
+
with contextlib.closing(tar_obj):
|
155 |
+
for member in tar_obj:
|
156 |
+
name = member.name
|
157 |
+
# don't extract absolute paths or ones with .. in them
|
158 |
+
if name.startswith('/') or '..' in name.split('/'):
|
159 |
+
continue
|
160 |
+
|
161 |
+
prelim_dst = os.path.join(extract_dir, *name.split('/'))
|
162 |
+
|
163 |
+
try:
|
164 |
+
member = _resolve_tar_file_or_dir(tar_obj, member)
|
165 |
+
except LookupError:
|
166 |
+
continue
|
167 |
+
|
168 |
+
final_dst = progress_filter(name, prelim_dst)
|
169 |
+
if not final_dst:
|
170 |
+
continue
|
171 |
+
|
172 |
+
if final_dst.endswith(os.sep):
|
173 |
+
final_dst = final_dst[:-1]
|
174 |
+
|
175 |
+
yield member, final_dst
|
176 |
+
|
177 |
+
|
178 |
+
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
|
179 |
+
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
|
180 |
+
|
181 |
+
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
|
182 |
+
by ``tarfile.open()``). See ``unpack_archive()`` for an explanation
|
183 |
+
of the `progress_filter` argument.
|
184 |
+
"""
|
185 |
+
try:
|
186 |
+
tarobj = tarfile.open(filename)
|
187 |
+
except tarfile.TarError as e:
|
188 |
+
raise UnrecognizedFormat(
|
189 |
+
"%s is not a compressed or uncompressed tar file" % (filename,)
|
190 |
+
) from e
|
191 |
+
|
192 |
+
for member, final_dst in _iter_open_tar(
|
193 |
+
tarobj, extract_dir, progress_filter,
|
194 |
+
):
|
195 |
+
try:
|
196 |
+
# XXX Ugh
|
197 |
+
tarobj._extract_member(member, final_dst)
|
198 |
+
except tarfile.ExtractError:
|
199 |
+
# chown/chmod/mkfifo/mknode/makedev failed
|
200 |
+
pass
|
201 |
+
|
202 |
+
return True
|
203 |
+
|
204 |
+
|
205 |
+
extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile
|
scripts/myenv/lib/python3.10/site-packages/setuptools/build_meta.py
ADDED
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""A PEP 517 interface to setuptools
|
2 |
+
|
3 |
+
Previously, when a user or a command line tool (let's call it a "frontend")
|
4 |
+
needed to make a request of setuptools to take a certain action, for
|
5 |
+
example, generating a list of installation requirements, the frontend would
|
6 |
+
would call "setup.py egg_info" or "setup.py bdist_wheel" on the command line.
|
7 |
+
|
8 |
+
PEP 517 defines a different method of interfacing with setuptools. Rather
|
9 |
+
than calling "setup.py" directly, the frontend should:
|
10 |
+
|
11 |
+
1. Set the current directory to the directory with a setup.py file
|
12 |
+
2. Import this module into a safe python interpreter (one in which
|
13 |
+
setuptools can potentially set global variables or crash hard).
|
14 |
+
3. Call one of the functions defined in PEP 517.
|
15 |
+
|
16 |
+
What each function does is defined in PEP 517. However, here is a "casual"
|
17 |
+
definition of the functions (this definition should not be relied on for
|
18 |
+
bug reports or API stability):
|
19 |
+
|
20 |
+
- `build_wheel`: build a wheel in the folder and return the basename
|
21 |
+
- `get_requires_for_build_wheel`: get the `setup_requires` to build
|
22 |
+
- `prepare_metadata_for_build_wheel`: get the `install_requires`
|
23 |
+
- `build_sdist`: build an sdist in the folder and return the basename
|
24 |
+
- `get_requires_for_build_sdist`: get the `setup_requires` to build
|
25 |
+
|
26 |
+
Again, this is not a formal definition! Just a "taste" of the module.
|
27 |
+
"""
|
28 |
+
|
29 |
+
import io
|
30 |
+
import os
|
31 |
+
import sys
|
32 |
+
import tokenize
|
33 |
+
import shutil
|
34 |
+
import contextlib
|
35 |
+
import tempfile
|
36 |
+
import warnings
|
37 |
+
|
38 |
+
import setuptools
|
39 |
+
import distutils
|
40 |
+
|
41 |
+
from pkg_resources import parse_requirements
|
42 |
+
|
43 |
+
__all__ = ['get_requires_for_build_sdist',
|
44 |
+
'get_requires_for_build_wheel',
|
45 |
+
'prepare_metadata_for_build_wheel',
|
46 |
+
'build_wheel',
|
47 |
+
'build_sdist',
|
48 |
+
'__legacy__',
|
49 |
+
'SetupRequirementsError']
|
50 |
+
|
51 |
+
|
52 |
+
class SetupRequirementsError(BaseException):
|
53 |
+
def __init__(self, specifiers):
|
54 |
+
self.specifiers = specifiers
|
55 |
+
|
56 |
+
|
57 |
+
class Distribution(setuptools.dist.Distribution):
|
58 |
+
def fetch_build_eggs(self, specifiers):
|
59 |
+
specifier_list = list(map(str, parse_requirements(specifiers)))
|
60 |
+
|
61 |
+
raise SetupRequirementsError(specifier_list)
|
62 |
+
|
63 |
+
@classmethod
|
64 |
+
@contextlib.contextmanager
|
65 |
+
def patch(cls):
|
66 |
+
"""
|
67 |
+
Replace
|
68 |
+
distutils.dist.Distribution with this class
|
69 |
+
for the duration of this context.
|
70 |
+
"""
|
71 |
+
orig = distutils.core.Distribution
|
72 |
+
distutils.core.Distribution = cls
|
73 |
+
try:
|
74 |
+
yield
|
75 |
+
finally:
|
76 |
+
distutils.core.Distribution = orig
|
77 |
+
|
78 |
+
|
79 |
+
@contextlib.contextmanager
|
80 |
+
def no_install_setup_requires():
|
81 |
+
"""Temporarily disable installing setup_requires
|
82 |
+
|
83 |
+
Under PEP 517, the backend reports build dependencies to the frontend,
|
84 |
+
and the frontend is responsible for ensuring they're installed.
|
85 |
+
So setuptools (acting as a backend) should not try to install them.
|
86 |
+
"""
|
87 |
+
orig = setuptools._install_setup_requires
|
88 |
+
setuptools._install_setup_requires = lambda attrs: None
|
89 |
+
try:
|
90 |
+
yield
|
91 |
+
finally:
|
92 |
+
setuptools._install_setup_requires = orig
|
93 |
+
|
94 |
+
|
95 |
+
def _get_immediate_subdirectories(a_dir):
|
96 |
+
return [name for name in os.listdir(a_dir)
|
97 |
+
if os.path.isdir(os.path.join(a_dir, name))]
|
98 |
+
|
99 |
+
|
100 |
+
def _file_with_extension(directory, extension):
|
101 |
+
matching = (
|
102 |
+
f for f in os.listdir(directory)
|
103 |
+
if f.endswith(extension)
|
104 |
+
)
|
105 |
+
try:
|
106 |
+
file, = matching
|
107 |
+
except ValueError:
|
108 |
+
raise ValueError(
|
109 |
+
'No distribution was found. Ensure that `setup.py` '
|
110 |
+
'is not empty and that it calls `setup()`.')
|
111 |
+
return file
|
112 |
+
|
113 |
+
|
114 |
+
def _open_setup_script(setup_script):
|
115 |
+
if not os.path.exists(setup_script):
|
116 |
+
# Supply a default setup.py
|
117 |
+
return io.StringIO(u"from setuptools import setup; setup()")
|
118 |
+
|
119 |
+
return getattr(tokenize, 'open', open)(setup_script)
|
120 |
+
|
121 |
+
|
122 |
+
@contextlib.contextmanager
|
123 |
+
def suppress_known_deprecation():
|
124 |
+
with warnings.catch_warnings():
|
125 |
+
warnings.filterwarnings('ignore', 'setup.py install is deprecated')
|
126 |
+
yield
|
127 |
+
|
128 |
+
|
129 |
+
class _BuildMetaBackend(object):
|
130 |
+
|
131 |
+
def _fix_config(self, config_settings):
|
132 |
+
config_settings = config_settings or {}
|
133 |
+
config_settings.setdefault('--global-option', [])
|
134 |
+
return config_settings
|
135 |
+
|
136 |
+
def _get_build_requires(self, config_settings, requirements):
|
137 |
+
config_settings = self._fix_config(config_settings)
|
138 |
+
|
139 |
+
sys.argv = sys.argv[:1] + ['egg_info'] + \
|
140 |
+
config_settings["--global-option"]
|
141 |
+
try:
|
142 |
+
with Distribution.patch():
|
143 |
+
self.run_setup()
|
144 |
+
except SetupRequirementsError as e:
|
145 |
+
requirements += e.specifiers
|
146 |
+
|
147 |
+
return requirements
|
148 |
+
|
149 |
+
def run_setup(self, setup_script='setup.py'):
|
150 |
+
# Note that we can reuse our build directory between calls
|
151 |
+
# Correctness comes first, then optimization later
|
152 |
+
__file__ = setup_script
|
153 |
+
__name__ = '__main__'
|
154 |
+
|
155 |
+
with _open_setup_script(__file__) as f:
|
156 |
+
code = f.read().replace(r'\r\n', r'\n')
|
157 |
+
|
158 |
+
exec(compile(code, __file__, 'exec'), locals())
|
159 |
+
|
160 |
+
def get_requires_for_build_wheel(self, config_settings=None):
|
161 |
+
config_settings = self._fix_config(config_settings)
|
162 |
+
return self._get_build_requires(
|
163 |
+
config_settings, requirements=['wheel'])
|
164 |
+
|
165 |
+
def get_requires_for_build_sdist(self, config_settings=None):
|
166 |
+
config_settings = self._fix_config(config_settings)
|
167 |
+
return self._get_build_requires(config_settings, requirements=[])
|
168 |
+
|
169 |
+
def prepare_metadata_for_build_wheel(self, metadata_directory,
|
170 |
+
config_settings=None):
|
171 |
+
sys.argv = sys.argv[:1] + [
|
172 |
+
'dist_info', '--egg-base', metadata_directory]
|
173 |
+
with no_install_setup_requires():
|
174 |
+
self.run_setup()
|
175 |
+
|
176 |
+
dist_info_directory = metadata_directory
|
177 |
+
while True:
|
178 |
+
dist_infos = [f for f in os.listdir(dist_info_directory)
|
179 |
+
if f.endswith('.dist-info')]
|
180 |
+
|
181 |
+
if (
|
182 |
+
len(dist_infos) == 0 and
|
183 |
+
len(_get_immediate_subdirectories(dist_info_directory)) == 1
|
184 |
+
):
|
185 |
+
|
186 |
+
dist_info_directory = os.path.join(
|
187 |
+
dist_info_directory, os.listdir(dist_info_directory)[0])
|
188 |
+
continue
|
189 |
+
|
190 |
+
assert len(dist_infos) == 1
|
191 |
+
break
|
192 |
+
|
193 |
+
# PEP 517 requires that the .dist-info directory be placed in the
|
194 |
+
# metadata_directory. To comply, we MUST copy the directory to the root
|
195 |
+
if dist_info_directory != metadata_directory:
|
196 |
+
shutil.move(
|
197 |
+
os.path.join(dist_info_directory, dist_infos[0]),
|
198 |
+
metadata_directory)
|
199 |
+
shutil.rmtree(dist_info_directory, ignore_errors=True)
|
200 |
+
|
201 |
+
return dist_infos[0]
|
202 |
+
|
203 |
+
def _build_with_temp_dir(self, setup_command, result_extension,
|
204 |
+
result_directory, config_settings):
|
205 |
+
config_settings = self._fix_config(config_settings)
|
206 |
+
result_directory = os.path.abspath(result_directory)
|
207 |
+
|
208 |
+
# Build in a temporary directory, then copy to the target.
|
209 |
+
os.makedirs(result_directory, exist_ok=True)
|
210 |
+
with tempfile.TemporaryDirectory(dir=result_directory) as tmp_dist_dir:
|
211 |
+
sys.argv = (sys.argv[:1] + setup_command +
|
212 |
+
['--dist-dir', tmp_dist_dir] +
|
213 |
+
config_settings["--global-option"])
|
214 |
+
with no_install_setup_requires():
|
215 |
+
self.run_setup()
|
216 |
+
|
217 |
+
result_basename = _file_with_extension(
|
218 |
+
tmp_dist_dir, result_extension)
|
219 |
+
result_path = os.path.join(result_directory, result_basename)
|
220 |
+
if os.path.exists(result_path):
|
221 |
+
# os.rename will fail overwriting on non-Unix.
|
222 |
+
os.remove(result_path)
|
223 |
+
os.rename(os.path.join(tmp_dist_dir, result_basename), result_path)
|
224 |
+
|
225 |
+
return result_basename
|
226 |
+
|
227 |
+
def build_wheel(self, wheel_directory, config_settings=None,
|
228 |
+
metadata_directory=None):
|
229 |
+
with suppress_known_deprecation():
|
230 |
+
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
|
231 |
+
wheel_directory, config_settings)
|
232 |
+
|
233 |
+
def build_sdist(self, sdist_directory, config_settings=None):
|
234 |
+
return self._build_with_temp_dir(['sdist', '--formats', 'gztar'],
|
235 |
+
'.tar.gz', sdist_directory,
|
236 |
+
config_settings)
|
237 |
+
|
238 |
+
|
239 |
+
class _BuildMetaLegacyBackend(_BuildMetaBackend):
|
240 |
+
"""Compatibility backend for setuptools
|
241 |
+
|
242 |
+
This is a version of setuptools.build_meta that endeavors
|
243 |
+
to maintain backwards
|
244 |
+
compatibility with pre-PEP 517 modes of invocation. It
|
245 |
+
exists as a temporary
|
246 |
+
bridge between the old packaging mechanism and the new
|
247 |
+
packaging mechanism,
|
248 |
+
and will eventually be removed.
|
249 |
+
"""
|
250 |
+
def run_setup(self, setup_script='setup.py'):
|
251 |
+
# In order to maintain compatibility with scripts assuming that
|
252 |
+
# the setup.py script is in a directory on the PYTHONPATH, inject
|
253 |
+
# '' into sys.path. (pypa/setuptools#1642)
|
254 |
+
sys_path = list(sys.path) # Save the original path
|
255 |
+
|
256 |
+
script_dir = os.path.dirname(os.path.abspath(setup_script))
|
257 |
+
if script_dir not in sys.path:
|
258 |
+
sys.path.insert(0, script_dir)
|
259 |
+
|
260 |
+
# Some setup.py scripts (e.g. in pygame and numpy) use sys.argv[0] to
|
261 |
+
# get the directory of the source code. They expect it to refer to the
|
262 |
+
# setup.py script.
|
263 |
+
sys_argv_0 = sys.argv[0]
|
264 |
+
sys.argv[0] = setup_script
|
265 |
+
|
266 |
+
try:
|
267 |
+
super(_BuildMetaLegacyBackend,
|
268 |
+
self).run_setup(setup_script=setup_script)
|
269 |
+
finally:
|
270 |
+
# While PEP 517 frontends should be calling each hook in a fresh
|
271 |
+
# subprocess according to the standard (and thus it should not be
|
272 |
+
# strictly necessary to restore the old sys.path), we'll restore
|
273 |
+
# the original path so that the path manipulation does not persist
|
274 |
+
# within the hook after run_setup is called.
|
275 |
+
sys.path[:] = sys_path
|
276 |
+
sys.argv[0] = sys_argv_0
|
277 |
+
|
278 |
+
|
279 |
+
# The primary backend
|
280 |
+
_BACKEND = _BuildMetaBackend()
|
281 |
+
|
282 |
+
get_requires_for_build_wheel = _BACKEND.get_requires_for_build_wheel
|
283 |
+
get_requires_for_build_sdist = _BACKEND.get_requires_for_build_sdist
|
284 |
+
prepare_metadata_for_build_wheel = _BACKEND.prepare_metadata_for_build_wheel
|
285 |
+
build_wheel = _BACKEND.build_wheel
|
286 |
+
build_sdist = _BACKEND.build_sdist
|
287 |
+
|
288 |
+
|
289 |
+
# The legacy backend
|
290 |
+
__legacy__ = _BuildMetaLegacyBackend()
|
scripts/myenv/lib/python3.10/site-packages/setuptools/cli-32.exe
ADDED
Binary file (65.5 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/cli-64.exe
ADDED
Binary file (74.8 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/cli-arm64.exe
ADDED
Binary file (137 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/cli.exe
ADDED
Binary file (65.5 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__init__.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.command.bdist import bdist
|
2 |
+
import sys
|
3 |
+
|
4 |
+
if 'egg' not in bdist.format_commands:
|
5 |
+
bdist.format_command['egg'] = ('bdist_egg', "Python .egg file")
|
6 |
+
bdist.format_commands.append('egg')
|
7 |
+
|
8 |
+
del bdist, sys
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (382 Bytes). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/alias.cpython-310.pyc
ADDED
Binary file (2.38 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-310.pyc
ADDED
Binary file (13.1 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_rpm.cpython-310.pyc
ADDED
Binary file (1.6 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/build_py.cpython-310.pyc
ADDED
Binary file (8.27 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/develop.cpython-310.pyc
ADDED
Binary file (6.16 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/easy_install.cpython-310.pyc
ADDED
Binary file (65.2 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/egg_info.cpython-310.pyc
ADDED
Binary file (22.8 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/install.cpython-310.pyc
ADDED
Binary file (4.21 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/install_egg_info.cpython-310.pyc
ADDED
Binary file (2.93 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/install_lib.cpython-310.pyc
ADDED
Binary file (5.15 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/sdist.cpython-310.pyc
ADDED
Binary file (6.96 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/setopt.cpython-310.pyc
ADDED
Binary file (4.7 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/upload.cpython-310.pyc
ADDED
Binary file (821 Bytes). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/__pycache__/upload_docs.cpython-310.pyc
ADDED
Binary file (6.19 kB). View file
|
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/alias.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.errors import DistutilsOptionError
|
2 |
+
|
3 |
+
from setuptools.command.setopt import edit_config, option_base, config_file
|
4 |
+
|
5 |
+
|
6 |
+
def shquote(arg):
|
7 |
+
"""Quote an argument for later parsing by shlex.split()"""
|
8 |
+
for c in '"', "'", "\\", "#":
|
9 |
+
if c in arg:
|
10 |
+
return repr(arg)
|
11 |
+
if arg.split() != [arg]:
|
12 |
+
return repr(arg)
|
13 |
+
return arg
|
14 |
+
|
15 |
+
|
16 |
+
class alias(option_base):
|
17 |
+
"""Define a shortcut that invokes one or more commands"""
|
18 |
+
|
19 |
+
description = "define a shortcut to invoke one or more commands"
|
20 |
+
command_consumes_arguments = True
|
21 |
+
|
22 |
+
user_options = [
|
23 |
+
('remove', 'r', 'remove (unset) the alias'),
|
24 |
+
] + option_base.user_options
|
25 |
+
|
26 |
+
boolean_options = option_base.boolean_options + ['remove']
|
27 |
+
|
28 |
+
def initialize_options(self):
|
29 |
+
option_base.initialize_options(self)
|
30 |
+
self.args = None
|
31 |
+
self.remove = None
|
32 |
+
|
33 |
+
def finalize_options(self):
|
34 |
+
option_base.finalize_options(self)
|
35 |
+
if self.remove and len(self.args) != 1:
|
36 |
+
raise DistutilsOptionError(
|
37 |
+
"Must specify exactly one argument (the alias name) when "
|
38 |
+
"using --remove"
|
39 |
+
)
|
40 |
+
|
41 |
+
def run(self):
|
42 |
+
aliases = self.distribution.get_option_dict('aliases')
|
43 |
+
|
44 |
+
if not self.args:
|
45 |
+
print("Command Aliases")
|
46 |
+
print("---------------")
|
47 |
+
for alias in aliases:
|
48 |
+
print("setup.py alias", format_alias(alias, aliases))
|
49 |
+
return
|
50 |
+
|
51 |
+
elif len(self.args) == 1:
|
52 |
+
alias, = self.args
|
53 |
+
if self.remove:
|
54 |
+
command = None
|
55 |
+
elif alias in aliases:
|
56 |
+
print("setup.py alias", format_alias(alias, aliases))
|
57 |
+
return
|
58 |
+
else:
|
59 |
+
print("No alias definition found for %r" % alias)
|
60 |
+
return
|
61 |
+
else:
|
62 |
+
alias = self.args[0]
|
63 |
+
command = ' '.join(map(shquote, self.args[1:]))
|
64 |
+
|
65 |
+
edit_config(self.filename, {'aliases': {alias: command}}, self.dry_run)
|
66 |
+
|
67 |
+
|
68 |
+
def format_alias(name, aliases):
|
69 |
+
source, command = aliases[name]
|
70 |
+
if source == config_file('global'):
|
71 |
+
source = '--global-config '
|
72 |
+
elif source == config_file('user'):
|
73 |
+
source = '--user-config '
|
74 |
+
elif source == config_file('local'):
|
75 |
+
source = ''
|
76 |
+
else:
|
77 |
+
source = '--filename=%r' % source
|
78 |
+
return source + name + ' ' + command
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/bdist_egg.py
ADDED
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""setuptools.command.bdist_egg
|
2 |
+
|
3 |
+
Build .egg distributions"""
|
4 |
+
|
5 |
+
from distutils.dir_util import remove_tree, mkpath
|
6 |
+
from distutils import log
|
7 |
+
from types import CodeType
|
8 |
+
import sys
|
9 |
+
import os
|
10 |
+
import re
|
11 |
+
import textwrap
|
12 |
+
import marshal
|
13 |
+
|
14 |
+
from pkg_resources import get_build_platform, Distribution, ensure_directory
|
15 |
+
from setuptools.extension import Library
|
16 |
+
from setuptools import Command
|
17 |
+
|
18 |
+
from sysconfig import get_path, get_python_version
|
19 |
+
|
20 |
+
|
21 |
+
def _get_purelib():
|
22 |
+
return get_path("purelib")
|
23 |
+
|
24 |
+
|
25 |
+
def strip_module(filename):
|
26 |
+
if '.' in filename:
|
27 |
+
filename = os.path.splitext(filename)[0]
|
28 |
+
if filename.endswith('module'):
|
29 |
+
filename = filename[:-6]
|
30 |
+
return filename
|
31 |
+
|
32 |
+
|
33 |
+
def sorted_walk(dir):
|
34 |
+
"""Do os.walk in a reproducible way,
|
35 |
+
independent of indeterministic filesystem readdir order
|
36 |
+
"""
|
37 |
+
for base, dirs, files in os.walk(dir):
|
38 |
+
dirs.sort()
|
39 |
+
files.sort()
|
40 |
+
yield base, dirs, files
|
41 |
+
|
42 |
+
|
43 |
+
def write_stub(resource, pyfile):
|
44 |
+
_stub_template = textwrap.dedent("""
|
45 |
+
def __bootstrap__():
|
46 |
+
global __bootstrap__, __loader__, __file__
|
47 |
+
import sys, pkg_resources, importlib.util
|
48 |
+
__file__ = pkg_resources.resource_filename(__name__, %r)
|
49 |
+
__loader__ = None; del __bootstrap__, __loader__
|
50 |
+
spec = importlib.util.spec_from_file_location(__name__,__file__)
|
51 |
+
mod = importlib.util.module_from_spec(spec)
|
52 |
+
spec.loader.exec_module(mod)
|
53 |
+
__bootstrap__()
|
54 |
+
""").lstrip()
|
55 |
+
with open(pyfile, 'w') as f:
|
56 |
+
f.write(_stub_template % resource)
|
57 |
+
|
58 |
+
|
59 |
+
class bdist_egg(Command):
|
60 |
+
description = "create an \"egg\" distribution"
|
61 |
+
|
62 |
+
user_options = [
|
63 |
+
('bdist-dir=', 'b',
|
64 |
+
"temporary directory for creating the distribution"),
|
65 |
+
('plat-name=', 'p', "platform name to embed in generated filenames "
|
66 |
+
"(default: %s)" % get_build_platform()),
|
67 |
+
('exclude-source-files', None,
|
68 |
+
"remove all .py files from the generated egg"),
|
69 |
+
('keep-temp', 'k',
|
70 |
+
"keep the pseudo-installation tree around after " +
|
71 |
+
"creating the distribution archive"),
|
72 |
+
('dist-dir=', 'd',
|
73 |
+
"directory to put final built distributions in"),
|
74 |
+
('skip-build', None,
|
75 |
+
"skip rebuilding everything (for testing/debugging)"),
|
76 |
+
]
|
77 |
+
|
78 |
+
boolean_options = [
|
79 |
+
'keep-temp', 'skip-build', 'exclude-source-files'
|
80 |
+
]
|
81 |
+
|
82 |
+
def initialize_options(self):
|
83 |
+
self.bdist_dir = None
|
84 |
+
self.plat_name = None
|
85 |
+
self.keep_temp = 0
|
86 |
+
self.dist_dir = None
|
87 |
+
self.skip_build = 0
|
88 |
+
self.egg_output = None
|
89 |
+
self.exclude_source_files = None
|
90 |
+
|
91 |
+
def finalize_options(self):
|
92 |
+
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
|
93 |
+
self.egg_info = ei_cmd.egg_info
|
94 |
+
|
95 |
+
if self.bdist_dir is None:
|
96 |
+
bdist_base = self.get_finalized_command('bdist').bdist_base
|
97 |
+
self.bdist_dir = os.path.join(bdist_base, 'egg')
|
98 |
+
|
99 |
+
if self.plat_name is None:
|
100 |
+
self.plat_name = get_build_platform()
|
101 |
+
|
102 |
+
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
103 |
+
|
104 |
+
if self.egg_output is None:
|
105 |
+
|
106 |
+
# Compute filename of the output egg
|
107 |
+
basename = Distribution(
|
108 |
+
None, None, ei_cmd.egg_name, ei_cmd.egg_version,
|
109 |
+
get_python_version(),
|
110 |
+
self.distribution.has_ext_modules() and self.plat_name
|
111 |
+
).egg_name()
|
112 |
+
|
113 |
+
self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
|
114 |
+
|
115 |
+
def do_install_data(self):
|
116 |
+
# Hack for packages that install data to install's --install-lib
|
117 |
+
self.get_finalized_command('install').install_lib = self.bdist_dir
|
118 |
+
|
119 |
+
site_packages = os.path.normcase(os.path.realpath(_get_purelib()))
|
120 |
+
old, self.distribution.data_files = self.distribution.data_files, []
|
121 |
+
|
122 |
+
for item in old:
|
123 |
+
if isinstance(item, tuple) and len(item) == 2:
|
124 |
+
if os.path.isabs(item[0]):
|
125 |
+
realpath = os.path.realpath(item[0])
|
126 |
+
normalized = os.path.normcase(realpath)
|
127 |
+
if normalized == site_packages or normalized.startswith(
|
128 |
+
site_packages + os.sep
|
129 |
+
):
|
130 |
+
item = realpath[len(site_packages) + 1:], item[1]
|
131 |
+
# XXX else: raise ???
|
132 |
+
self.distribution.data_files.append(item)
|
133 |
+
|
134 |
+
try:
|
135 |
+
log.info("installing package data to %s", self.bdist_dir)
|
136 |
+
self.call_command('install_data', force=0, root=None)
|
137 |
+
finally:
|
138 |
+
self.distribution.data_files = old
|
139 |
+
|
140 |
+
def get_outputs(self):
|
141 |
+
return [self.egg_output]
|
142 |
+
|
143 |
+
def call_command(self, cmdname, **kw):
|
144 |
+
"""Invoke reinitialized command `cmdname` with keyword args"""
|
145 |
+
for dirname in INSTALL_DIRECTORY_ATTRS:
|
146 |
+
kw.setdefault(dirname, self.bdist_dir)
|
147 |
+
kw.setdefault('skip_build', self.skip_build)
|
148 |
+
kw.setdefault('dry_run', self.dry_run)
|
149 |
+
cmd = self.reinitialize_command(cmdname, **kw)
|
150 |
+
self.run_command(cmdname)
|
151 |
+
return cmd
|
152 |
+
|
153 |
+
def run(self): # noqa: C901 # is too complex (14) # FIXME
|
154 |
+
# Generate metadata first
|
155 |
+
self.run_command("egg_info")
|
156 |
+
# We run install_lib before install_data, because some data hacks
|
157 |
+
# pull their data path from the install_lib command.
|
158 |
+
log.info("installing library code to %s", self.bdist_dir)
|
159 |
+
instcmd = self.get_finalized_command('install')
|
160 |
+
old_root = instcmd.root
|
161 |
+
instcmd.root = None
|
162 |
+
if self.distribution.has_c_libraries() and not self.skip_build:
|
163 |
+
self.run_command('build_clib')
|
164 |
+
cmd = self.call_command('install_lib', warn_dir=0)
|
165 |
+
instcmd.root = old_root
|
166 |
+
|
167 |
+
all_outputs, ext_outputs = self.get_ext_outputs()
|
168 |
+
self.stubs = []
|
169 |
+
to_compile = []
|
170 |
+
for (p, ext_name) in enumerate(ext_outputs):
|
171 |
+
filename, ext = os.path.splitext(ext_name)
|
172 |
+
pyfile = os.path.join(self.bdist_dir, strip_module(filename) +
|
173 |
+
'.py')
|
174 |
+
self.stubs.append(pyfile)
|
175 |
+
log.info("creating stub loader for %s", ext_name)
|
176 |
+
if not self.dry_run:
|
177 |
+
write_stub(os.path.basename(ext_name), pyfile)
|
178 |
+
to_compile.append(pyfile)
|
179 |
+
ext_outputs[p] = ext_name.replace(os.sep, '/')
|
180 |
+
|
181 |
+
if to_compile:
|
182 |
+
cmd.byte_compile(to_compile)
|
183 |
+
if self.distribution.data_files:
|
184 |
+
self.do_install_data()
|
185 |
+
|
186 |
+
# Make the EGG-INFO directory
|
187 |
+
archive_root = self.bdist_dir
|
188 |
+
egg_info = os.path.join(archive_root, 'EGG-INFO')
|
189 |
+
self.mkpath(egg_info)
|
190 |
+
if self.distribution.scripts:
|
191 |
+
script_dir = os.path.join(egg_info, 'scripts')
|
192 |
+
log.info("installing scripts to %s", script_dir)
|
193 |
+
self.call_command('install_scripts', install_dir=script_dir,
|
194 |
+
no_ep=1)
|
195 |
+
|
196 |
+
self.copy_metadata_to(egg_info)
|
197 |
+
native_libs = os.path.join(egg_info, "native_libs.txt")
|
198 |
+
if all_outputs:
|
199 |
+
log.info("writing %s", native_libs)
|
200 |
+
if not self.dry_run:
|
201 |
+
ensure_directory(native_libs)
|
202 |
+
libs_file = open(native_libs, 'wt')
|
203 |
+
libs_file.write('\n'.join(all_outputs))
|
204 |
+
libs_file.write('\n')
|
205 |
+
libs_file.close()
|
206 |
+
elif os.path.isfile(native_libs):
|
207 |
+
log.info("removing %s", native_libs)
|
208 |
+
if not self.dry_run:
|
209 |
+
os.unlink(native_libs)
|
210 |
+
|
211 |
+
write_safety_flag(
|
212 |
+
os.path.join(archive_root, 'EGG-INFO'), self.zip_safe()
|
213 |
+
)
|
214 |
+
|
215 |
+
if os.path.exists(os.path.join(self.egg_info, 'depends.txt')):
|
216 |
+
log.warn(
|
217 |
+
"WARNING: 'depends.txt' will not be used by setuptools 0.6!\n"
|
218 |
+
"Use the install_requires/extras_require setup() args instead."
|
219 |
+
)
|
220 |
+
|
221 |
+
if self.exclude_source_files:
|
222 |
+
self.zap_pyfiles()
|
223 |
+
|
224 |
+
# Make the archive
|
225 |
+
make_zipfile(self.egg_output, archive_root, verbose=self.verbose,
|
226 |
+
dry_run=self.dry_run, mode=self.gen_header())
|
227 |
+
if not self.keep_temp:
|
228 |
+
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
229 |
+
|
230 |
+
# Add to 'Distribution.dist_files' so that the "upload" command works
|
231 |
+
getattr(self.distribution, 'dist_files', []).append(
|
232 |
+
('bdist_egg', get_python_version(), self.egg_output))
|
233 |
+
|
234 |
+
def zap_pyfiles(self):
|
235 |
+
log.info("Removing .py files from temporary directory")
|
236 |
+
for base, dirs, files in walk_egg(self.bdist_dir):
|
237 |
+
for name in files:
|
238 |
+
path = os.path.join(base, name)
|
239 |
+
|
240 |
+
if name.endswith('.py'):
|
241 |
+
log.debug("Deleting %s", path)
|
242 |
+
os.unlink(path)
|
243 |
+
|
244 |
+
if base.endswith('__pycache__'):
|
245 |
+
path_old = path
|
246 |
+
|
247 |
+
pattern = r'(?P<name>.+)\.(?P<magic>[^.]+)\.pyc'
|
248 |
+
m = re.match(pattern, name)
|
249 |
+
path_new = os.path.join(
|
250 |
+
base, os.pardir, m.group('name') + '.pyc')
|
251 |
+
log.info(
|
252 |
+
"Renaming file from [%s] to [%s]"
|
253 |
+
% (path_old, path_new))
|
254 |
+
try:
|
255 |
+
os.remove(path_new)
|
256 |
+
except OSError:
|
257 |
+
pass
|
258 |
+
os.rename(path_old, path_new)
|
259 |
+
|
260 |
+
def zip_safe(self):
|
261 |
+
safe = getattr(self.distribution, 'zip_safe', None)
|
262 |
+
if safe is not None:
|
263 |
+
return safe
|
264 |
+
log.warn("zip_safe flag not set; analyzing archive contents...")
|
265 |
+
return analyze_egg(self.bdist_dir, self.stubs)
|
266 |
+
|
267 |
+
def gen_header(self):
|
268 |
+
return 'w'
|
269 |
+
|
270 |
+
def copy_metadata_to(self, target_dir):
|
271 |
+
"Copy metadata (egg info) to the target_dir"
|
272 |
+
# normalize the path (so that a forward-slash in egg_info will
|
273 |
+
# match using startswith below)
|
274 |
+
norm_egg_info = os.path.normpath(self.egg_info)
|
275 |
+
prefix = os.path.join(norm_egg_info, '')
|
276 |
+
for path in self.ei_cmd.filelist.files:
|
277 |
+
if path.startswith(prefix):
|
278 |
+
target = os.path.join(target_dir, path[len(prefix):])
|
279 |
+
ensure_directory(target)
|
280 |
+
self.copy_file(path, target)
|
281 |
+
|
282 |
+
def get_ext_outputs(self):
|
283 |
+
"""Get a list of relative paths to C extensions in the output distro"""
|
284 |
+
|
285 |
+
all_outputs = []
|
286 |
+
ext_outputs = []
|
287 |
+
|
288 |
+
paths = {self.bdist_dir: ''}
|
289 |
+
for base, dirs, files in sorted_walk(self.bdist_dir):
|
290 |
+
for filename in files:
|
291 |
+
if os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS:
|
292 |
+
all_outputs.append(paths[base] + filename)
|
293 |
+
for filename in dirs:
|
294 |
+
paths[os.path.join(base, filename)] = (paths[base] +
|
295 |
+
filename + '/')
|
296 |
+
|
297 |
+
if self.distribution.has_ext_modules():
|
298 |
+
build_cmd = self.get_finalized_command('build_ext')
|
299 |
+
for ext in build_cmd.extensions:
|
300 |
+
if isinstance(ext, Library):
|
301 |
+
continue
|
302 |
+
fullname = build_cmd.get_ext_fullname(ext.name)
|
303 |
+
filename = build_cmd.get_ext_filename(fullname)
|
304 |
+
if not os.path.basename(filename).startswith('dl-'):
|
305 |
+
if os.path.exists(os.path.join(self.bdist_dir, filename)):
|
306 |
+
ext_outputs.append(filename)
|
307 |
+
|
308 |
+
return all_outputs, ext_outputs
|
309 |
+
|
310 |
+
|
311 |
+
NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split())
|
312 |
+
|
313 |
+
|
314 |
+
def walk_egg(egg_dir):
|
315 |
+
"""Walk an unpacked egg's contents, skipping the metadata directory"""
|
316 |
+
walker = sorted_walk(egg_dir)
|
317 |
+
base, dirs, files = next(walker)
|
318 |
+
if 'EGG-INFO' in dirs:
|
319 |
+
dirs.remove('EGG-INFO')
|
320 |
+
yield base, dirs, files
|
321 |
+
for bdf in walker:
|
322 |
+
yield bdf
|
323 |
+
|
324 |
+
|
325 |
+
def analyze_egg(egg_dir, stubs):
|
326 |
+
# check for existing flag in EGG-INFO
|
327 |
+
for flag, fn in safety_flags.items():
|
328 |
+
if os.path.exists(os.path.join(egg_dir, 'EGG-INFO', fn)):
|
329 |
+
return flag
|
330 |
+
if not can_scan():
|
331 |
+
return False
|
332 |
+
safe = True
|
333 |
+
for base, dirs, files in walk_egg(egg_dir):
|
334 |
+
for name in files:
|
335 |
+
if name.endswith('.py') or name.endswith('.pyw'):
|
336 |
+
continue
|
337 |
+
elif name.endswith('.pyc') or name.endswith('.pyo'):
|
338 |
+
# always scan, even if we already know we're not safe
|
339 |
+
safe = scan_module(egg_dir, base, name, stubs) and safe
|
340 |
+
return safe
|
341 |
+
|
342 |
+
|
343 |
+
def write_safety_flag(egg_dir, safe):
|
344 |
+
# Write or remove zip safety flag file(s)
|
345 |
+
for flag, fn in safety_flags.items():
|
346 |
+
fn = os.path.join(egg_dir, fn)
|
347 |
+
if os.path.exists(fn):
|
348 |
+
if safe is None or bool(safe) != flag:
|
349 |
+
os.unlink(fn)
|
350 |
+
elif safe is not None and bool(safe) == flag:
|
351 |
+
f = open(fn, 'wt')
|
352 |
+
f.write('\n')
|
353 |
+
f.close()
|
354 |
+
|
355 |
+
|
356 |
+
safety_flags = {
|
357 |
+
True: 'zip-safe',
|
358 |
+
False: 'not-zip-safe',
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
def scan_module(egg_dir, base, name, stubs):
|
363 |
+
"""Check whether module possibly uses unsafe-for-zipfile stuff"""
|
364 |
+
|
365 |
+
filename = os.path.join(base, name)
|
366 |
+
if filename[:-1] in stubs:
|
367 |
+
return True # Extension module
|
368 |
+
pkg = base[len(egg_dir) + 1:].replace(os.sep, '.')
|
369 |
+
module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0]
|
370 |
+
if sys.version_info < (3, 7):
|
371 |
+
skip = 12 # skip magic & date & file size
|
372 |
+
else:
|
373 |
+
skip = 16 # skip magic & reserved? & date & file size
|
374 |
+
f = open(filename, 'rb')
|
375 |
+
f.read(skip)
|
376 |
+
code = marshal.load(f)
|
377 |
+
f.close()
|
378 |
+
safe = True
|
379 |
+
symbols = dict.fromkeys(iter_symbols(code))
|
380 |
+
for bad in ['__file__', '__path__']:
|
381 |
+
if bad in symbols:
|
382 |
+
log.warn("%s: module references %s", module, bad)
|
383 |
+
safe = False
|
384 |
+
if 'inspect' in symbols:
|
385 |
+
for bad in [
|
386 |
+
'getsource', 'getabsfile', 'getsourcefile', 'getfile'
|
387 |
+
'getsourcelines', 'findsource', 'getcomments', 'getframeinfo',
|
388 |
+
'getinnerframes', 'getouterframes', 'stack', 'trace'
|
389 |
+
]:
|
390 |
+
if bad in symbols:
|
391 |
+
log.warn("%s: module MAY be using inspect.%s", module, bad)
|
392 |
+
safe = False
|
393 |
+
return safe
|
394 |
+
|
395 |
+
|
396 |
+
def iter_symbols(code):
|
397 |
+
"""Yield names and strings used by `code` and its nested code objects"""
|
398 |
+
for name in code.co_names:
|
399 |
+
yield name
|
400 |
+
for const in code.co_consts:
|
401 |
+
if isinstance(const, str):
|
402 |
+
yield const
|
403 |
+
elif isinstance(const, CodeType):
|
404 |
+
for name in iter_symbols(const):
|
405 |
+
yield name
|
406 |
+
|
407 |
+
|
408 |
+
def can_scan():
|
409 |
+
if not sys.platform.startswith('java') and sys.platform != 'cli':
|
410 |
+
# CPython, PyPy, etc.
|
411 |
+
return True
|
412 |
+
log.warn("Unable to analyze compiled code on this platform.")
|
413 |
+
log.warn("Please ask the author to include a 'zip_safe'"
|
414 |
+
" setting (either True or False) in the package's setup.py")
|
415 |
+
|
416 |
+
|
417 |
+
# Attribute names of options for commands that might need to be convinced to
|
418 |
+
# install to the egg build directory
|
419 |
+
|
420 |
+
INSTALL_DIRECTORY_ATTRS = [
|
421 |
+
'install_lib', 'install_dir', 'install_data', 'install_base'
|
422 |
+
]
|
423 |
+
|
424 |
+
|
425 |
+
def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=True,
|
426 |
+
mode='w'):
|
427 |
+
"""Create a zip file from all the files under 'base_dir'. The output
|
428 |
+
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
|
429 |
+
Python module (if available) or the InfoZIP "zip" utility (if installed
|
430 |
+
and found on the default search path). If neither tool is available,
|
431 |
+
raises DistutilsExecError. Returns the name of the output zip file.
|
432 |
+
"""
|
433 |
+
import zipfile
|
434 |
+
|
435 |
+
mkpath(os.path.dirname(zip_filename), dry_run=dry_run)
|
436 |
+
log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir)
|
437 |
+
|
438 |
+
def visit(z, dirname, names):
|
439 |
+
for name in names:
|
440 |
+
path = os.path.normpath(os.path.join(dirname, name))
|
441 |
+
if os.path.isfile(path):
|
442 |
+
p = path[len(base_dir) + 1:]
|
443 |
+
if not dry_run:
|
444 |
+
z.write(path, p)
|
445 |
+
log.debug("adding '%s'", p)
|
446 |
+
|
447 |
+
compression = zipfile.ZIP_DEFLATED if compress else zipfile.ZIP_STORED
|
448 |
+
if not dry_run:
|
449 |
+
z = zipfile.ZipFile(zip_filename, mode, compression=compression)
|
450 |
+
for dirname, dirs, files in sorted_walk(base_dir):
|
451 |
+
visit(z, dirname, files)
|
452 |
+
z.close()
|
453 |
+
else:
|
454 |
+
for dirname, dirs, files in sorted_walk(base_dir):
|
455 |
+
visit(None, dirname, files)
|
456 |
+
return zip_filename
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/bdist_rpm.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import distutils.command.bdist_rpm as orig
|
2 |
+
import warnings
|
3 |
+
|
4 |
+
from setuptools import SetuptoolsDeprecationWarning
|
5 |
+
|
6 |
+
|
7 |
+
class bdist_rpm(orig.bdist_rpm):
|
8 |
+
"""
|
9 |
+
Override the default bdist_rpm behavior to do the following:
|
10 |
+
|
11 |
+
1. Run egg_info to ensure the name and version are properly calculated.
|
12 |
+
2. Always run 'install' using --single-version-externally-managed to
|
13 |
+
disable eggs in RPM distributions.
|
14 |
+
"""
|
15 |
+
|
16 |
+
def run(self):
|
17 |
+
warnings.warn(
|
18 |
+
"bdist_rpm is deprecated and will be removed in a future "
|
19 |
+
"version. Use bdist_wheel (wheel packages) instead.",
|
20 |
+
SetuptoolsDeprecationWarning,
|
21 |
+
)
|
22 |
+
|
23 |
+
# ensure distro name is up-to-date
|
24 |
+
self.run_command('egg_info')
|
25 |
+
|
26 |
+
orig.bdist_rpm.run(self)
|
27 |
+
|
28 |
+
def _make_spec_file(self):
|
29 |
+
spec = orig.bdist_rpm._make_spec_file(self)
|
30 |
+
spec = [
|
31 |
+
line.replace(
|
32 |
+
"setup.py install ",
|
33 |
+
"setup.py install --single-version-externally-managed "
|
34 |
+
).replace(
|
35 |
+
"%setup",
|
36 |
+
"%setup -n %{name}-%{unmangled_version}"
|
37 |
+
)
|
38 |
+
for line in spec
|
39 |
+
]
|
40 |
+
return spec
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/build_clib.py
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import distutils.command.build_clib as orig
|
2 |
+
from distutils.errors import DistutilsSetupError
|
3 |
+
from distutils import log
|
4 |
+
from setuptools.dep_util import newer_pairwise_group
|
5 |
+
|
6 |
+
|
7 |
+
class build_clib(orig.build_clib):
|
8 |
+
"""
|
9 |
+
Override the default build_clib behaviour to do the following:
|
10 |
+
|
11 |
+
1. Implement a rudimentary timestamp-based dependency system
|
12 |
+
so 'compile()' doesn't run every time.
|
13 |
+
2. Add more keys to the 'build_info' dictionary:
|
14 |
+
* obj_deps - specify dependencies for each object compiled.
|
15 |
+
this should be a dictionary mapping a key
|
16 |
+
with the source filename to a list of
|
17 |
+
dependencies. Use an empty string for global
|
18 |
+
dependencies.
|
19 |
+
* cflags - specify a list of additional flags to pass to
|
20 |
+
the compiler.
|
21 |
+
"""
|
22 |
+
|
23 |
+
def build_libraries(self, libraries):
|
24 |
+
for (lib_name, build_info) in libraries:
|
25 |
+
sources = build_info.get('sources')
|
26 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
27 |
+
raise DistutilsSetupError(
|
28 |
+
"in 'libraries' option (library '%s'), "
|
29 |
+
"'sources' must be present and must be "
|
30 |
+
"a list of source filenames" % lib_name)
|
31 |
+
sources = list(sources)
|
32 |
+
|
33 |
+
log.info("building '%s' library", lib_name)
|
34 |
+
|
35 |
+
# Make sure everything is the correct type.
|
36 |
+
# obj_deps should be a dictionary of keys as sources
|
37 |
+
# and a list/tuple of files that are its dependencies.
|
38 |
+
obj_deps = build_info.get('obj_deps', dict())
|
39 |
+
if not isinstance(obj_deps, dict):
|
40 |
+
raise DistutilsSetupError(
|
41 |
+
"in 'libraries' option (library '%s'), "
|
42 |
+
"'obj_deps' must be a dictionary of "
|
43 |
+
"type 'source: list'" % lib_name)
|
44 |
+
dependencies = []
|
45 |
+
|
46 |
+
# Get the global dependencies that are specified by the '' key.
|
47 |
+
# These will go into every source's dependency list.
|
48 |
+
global_deps = obj_deps.get('', list())
|
49 |
+
if not isinstance(global_deps, (list, tuple)):
|
50 |
+
raise DistutilsSetupError(
|
51 |
+
"in 'libraries' option (library '%s'), "
|
52 |
+
"'obj_deps' must be a dictionary of "
|
53 |
+
"type 'source: list'" % lib_name)
|
54 |
+
|
55 |
+
# Build the list to be used by newer_pairwise_group
|
56 |
+
# each source will be auto-added to its dependencies.
|
57 |
+
for source in sources:
|
58 |
+
src_deps = [source]
|
59 |
+
src_deps.extend(global_deps)
|
60 |
+
extra_deps = obj_deps.get(source, list())
|
61 |
+
if not isinstance(extra_deps, (list, tuple)):
|
62 |
+
raise DistutilsSetupError(
|
63 |
+
"in 'libraries' option (library '%s'), "
|
64 |
+
"'obj_deps' must be a dictionary of "
|
65 |
+
"type 'source: list'" % lib_name)
|
66 |
+
src_deps.extend(extra_deps)
|
67 |
+
dependencies.append(src_deps)
|
68 |
+
|
69 |
+
expected_objects = self.compiler.object_filenames(
|
70 |
+
sources,
|
71 |
+
output_dir=self.build_temp,
|
72 |
+
)
|
73 |
+
|
74 |
+
if (
|
75 |
+
newer_pairwise_group(dependencies, expected_objects)
|
76 |
+
!= ([], [])
|
77 |
+
):
|
78 |
+
# First, compile the source code to object files in the library
|
79 |
+
# directory. (This should probably change to putting object
|
80 |
+
# files in a temporary build directory.)
|
81 |
+
macros = build_info.get('macros')
|
82 |
+
include_dirs = build_info.get('include_dirs')
|
83 |
+
cflags = build_info.get('cflags')
|
84 |
+
self.compiler.compile(
|
85 |
+
sources,
|
86 |
+
output_dir=self.build_temp,
|
87 |
+
macros=macros,
|
88 |
+
include_dirs=include_dirs,
|
89 |
+
extra_postargs=cflags,
|
90 |
+
debug=self.debug
|
91 |
+
)
|
92 |
+
|
93 |
+
# Now "link" the object files together into a static library.
|
94 |
+
# (On Unix at least, this isn't really linking -- it just
|
95 |
+
# builds an archive. Whatever.)
|
96 |
+
self.compiler.create_static_lib(
|
97 |
+
expected_objects,
|
98 |
+
lib_name,
|
99 |
+
output_dir=self.build_clib,
|
100 |
+
debug=self.debug
|
101 |
+
)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/build_ext.py
ADDED
@@ -0,0 +1,328 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import itertools
|
4 |
+
from importlib.machinery import EXTENSION_SUFFIXES
|
5 |
+
from distutils.command.build_ext import build_ext as _du_build_ext
|
6 |
+
from distutils.file_util import copy_file
|
7 |
+
from distutils.ccompiler import new_compiler
|
8 |
+
from distutils.sysconfig import customize_compiler, get_config_var
|
9 |
+
from distutils.errors import DistutilsError
|
10 |
+
from distutils import log
|
11 |
+
|
12 |
+
from setuptools.extension import Library
|
13 |
+
|
14 |
+
try:
|
15 |
+
# Attempt to use Cython for building extensions, if available
|
16 |
+
from Cython.Distutils.build_ext import build_ext as _build_ext
|
17 |
+
# Additionally, assert that the compiler module will load
|
18 |
+
# also. Ref #1229.
|
19 |
+
__import__('Cython.Compiler.Main')
|
20 |
+
except ImportError:
|
21 |
+
_build_ext = _du_build_ext
|
22 |
+
|
23 |
+
# make sure _config_vars is initialized
|
24 |
+
get_config_var("LDSHARED")
|
25 |
+
from distutils.sysconfig import _config_vars as _CONFIG_VARS # noqa
|
26 |
+
|
27 |
+
|
28 |
+
def _customize_compiler_for_shlib(compiler):
|
29 |
+
if sys.platform == "darwin":
|
30 |
+
# building .dylib requires additional compiler flags on OSX; here we
|
31 |
+
# temporarily substitute the pyconfig.h variables so that distutils'
|
32 |
+
# 'customize_compiler' uses them before we build the shared libraries.
|
33 |
+
tmp = _CONFIG_VARS.copy()
|
34 |
+
try:
|
35 |
+
# XXX Help! I don't have any idea whether these are right...
|
36 |
+
_CONFIG_VARS['LDSHARED'] = (
|
37 |
+
"gcc -Wl,-x -dynamiclib -undefined dynamic_lookup")
|
38 |
+
_CONFIG_VARS['CCSHARED'] = " -dynamiclib"
|
39 |
+
_CONFIG_VARS['SO'] = ".dylib"
|
40 |
+
customize_compiler(compiler)
|
41 |
+
finally:
|
42 |
+
_CONFIG_VARS.clear()
|
43 |
+
_CONFIG_VARS.update(tmp)
|
44 |
+
else:
|
45 |
+
customize_compiler(compiler)
|
46 |
+
|
47 |
+
|
48 |
+
have_rtld = False
|
49 |
+
use_stubs = False
|
50 |
+
libtype = 'shared'
|
51 |
+
|
52 |
+
if sys.platform == "darwin":
|
53 |
+
use_stubs = True
|
54 |
+
elif os.name != 'nt':
|
55 |
+
try:
|
56 |
+
import dl
|
57 |
+
use_stubs = have_rtld = hasattr(dl, 'RTLD_NOW')
|
58 |
+
except ImportError:
|
59 |
+
pass
|
60 |
+
|
61 |
+
|
62 |
+
def if_dl(s):
|
63 |
+
return s if have_rtld else ''
|
64 |
+
|
65 |
+
|
66 |
+
def get_abi3_suffix():
|
67 |
+
"""Return the file extension for an abi3-compliant Extension()"""
|
68 |
+
for suffix in EXTENSION_SUFFIXES:
|
69 |
+
if '.abi3' in suffix: # Unix
|
70 |
+
return suffix
|
71 |
+
elif suffix == '.pyd': # Windows
|
72 |
+
return suffix
|
73 |
+
|
74 |
+
|
75 |
+
class build_ext(_build_ext):
|
76 |
+
def run(self):
|
77 |
+
"""Build extensions in build directory, then copy if --inplace"""
|
78 |
+
old_inplace, self.inplace = self.inplace, 0
|
79 |
+
_build_ext.run(self)
|
80 |
+
self.inplace = old_inplace
|
81 |
+
if old_inplace:
|
82 |
+
self.copy_extensions_to_source()
|
83 |
+
|
84 |
+
def copy_extensions_to_source(self):
|
85 |
+
build_py = self.get_finalized_command('build_py')
|
86 |
+
for ext in self.extensions:
|
87 |
+
fullname = self.get_ext_fullname(ext.name)
|
88 |
+
filename = self.get_ext_filename(fullname)
|
89 |
+
modpath = fullname.split('.')
|
90 |
+
package = '.'.join(modpath[:-1])
|
91 |
+
package_dir = build_py.get_package_dir(package)
|
92 |
+
dest_filename = os.path.join(package_dir,
|
93 |
+
os.path.basename(filename))
|
94 |
+
src_filename = os.path.join(self.build_lib, filename)
|
95 |
+
|
96 |
+
# Always copy, even if source is older than destination, to ensure
|
97 |
+
# that the right extensions for the current Python/platform are
|
98 |
+
# used.
|
99 |
+
copy_file(
|
100 |
+
src_filename, dest_filename, verbose=self.verbose,
|
101 |
+
dry_run=self.dry_run
|
102 |
+
)
|
103 |
+
if ext._needs_stub:
|
104 |
+
self.write_stub(package_dir or os.curdir, ext, True)
|
105 |
+
|
106 |
+
def get_ext_filename(self, fullname):
|
107 |
+
so_ext = os.getenv('SETUPTOOLS_EXT_SUFFIX')
|
108 |
+
if so_ext:
|
109 |
+
filename = os.path.join(*fullname.split('.')) + so_ext
|
110 |
+
else:
|
111 |
+
filename = _build_ext.get_ext_filename(self, fullname)
|
112 |
+
so_ext = get_config_var('EXT_SUFFIX')
|
113 |
+
|
114 |
+
if fullname in self.ext_map:
|
115 |
+
ext = self.ext_map[fullname]
|
116 |
+
use_abi3 = getattr(ext, 'py_limited_api') and get_abi3_suffix()
|
117 |
+
if use_abi3:
|
118 |
+
filename = filename[:-len(so_ext)]
|
119 |
+
so_ext = get_abi3_suffix()
|
120 |
+
filename = filename + so_ext
|
121 |
+
if isinstance(ext, Library):
|
122 |
+
fn, ext = os.path.splitext(filename)
|
123 |
+
return self.shlib_compiler.library_filename(fn, libtype)
|
124 |
+
elif use_stubs and ext._links_to_dynamic:
|
125 |
+
d, fn = os.path.split(filename)
|
126 |
+
return os.path.join(d, 'dl-' + fn)
|
127 |
+
return filename
|
128 |
+
|
129 |
+
def initialize_options(self):
|
130 |
+
_build_ext.initialize_options(self)
|
131 |
+
self.shlib_compiler = None
|
132 |
+
self.shlibs = []
|
133 |
+
self.ext_map = {}
|
134 |
+
|
135 |
+
def finalize_options(self):
|
136 |
+
_build_ext.finalize_options(self)
|
137 |
+
self.extensions = self.extensions or []
|
138 |
+
self.check_extensions_list(self.extensions)
|
139 |
+
self.shlibs = [ext for ext in self.extensions
|
140 |
+
if isinstance(ext, Library)]
|
141 |
+
if self.shlibs:
|
142 |
+
self.setup_shlib_compiler()
|
143 |
+
for ext in self.extensions:
|
144 |
+
ext._full_name = self.get_ext_fullname(ext.name)
|
145 |
+
for ext in self.extensions:
|
146 |
+
fullname = ext._full_name
|
147 |
+
self.ext_map[fullname] = ext
|
148 |
+
|
149 |
+
# distutils 3.1 will also ask for module names
|
150 |
+
# XXX what to do with conflicts?
|
151 |
+
self.ext_map[fullname.split('.')[-1]] = ext
|
152 |
+
|
153 |
+
ltd = self.shlibs and self.links_to_dynamic(ext) or False
|
154 |
+
ns = ltd and use_stubs and not isinstance(ext, Library)
|
155 |
+
ext._links_to_dynamic = ltd
|
156 |
+
ext._needs_stub = ns
|
157 |
+
filename = ext._file_name = self.get_ext_filename(fullname)
|
158 |
+
libdir = os.path.dirname(os.path.join(self.build_lib, filename))
|
159 |
+
if ltd and libdir not in ext.library_dirs:
|
160 |
+
ext.library_dirs.append(libdir)
|
161 |
+
if ltd and use_stubs and os.curdir not in ext.runtime_library_dirs:
|
162 |
+
ext.runtime_library_dirs.append(os.curdir)
|
163 |
+
|
164 |
+
def setup_shlib_compiler(self):
|
165 |
+
compiler = self.shlib_compiler = new_compiler(
|
166 |
+
compiler=self.compiler, dry_run=self.dry_run, force=self.force
|
167 |
+
)
|
168 |
+
_customize_compiler_for_shlib(compiler)
|
169 |
+
|
170 |
+
if self.include_dirs is not None:
|
171 |
+
compiler.set_include_dirs(self.include_dirs)
|
172 |
+
if self.define is not None:
|
173 |
+
# 'define' option is a list of (name,value) tuples
|
174 |
+
for (name, value) in self.define:
|
175 |
+
compiler.define_macro(name, value)
|
176 |
+
if self.undef is not None:
|
177 |
+
for macro in self.undef:
|
178 |
+
compiler.undefine_macro(macro)
|
179 |
+
if self.libraries is not None:
|
180 |
+
compiler.set_libraries(self.libraries)
|
181 |
+
if self.library_dirs is not None:
|
182 |
+
compiler.set_library_dirs(self.library_dirs)
|
183 |
+
if self.rpath is not None:
|
184 |
+
compiler.set_runtime_library_dirs(self.rpath)
|
185 |
+
if self.link_objects is not None:
|
186 |
+
compiler.set_link_objects(self.link_objects)
|
187 |
+
|
188 |
+
# hack so distutils' build_extension() builds a library instead
|
189 |
+
compiler.link_shared_object = link_shared_object.__get__(compiler)
|
190 |
+
|
191 |
+
def get_export_symbols(self, ext):
|
192 |
+
if isinstance(ext, Library):
|
193 |
+
return ext.export_symbols
|
194 |
+
return _build_ext.get_export_symbols(self, ext)
|
195 |
+
|
196 |
+
def build_extension(self, ext):
|
197 |
+
ext._convert_pyx_sources_to_lang()
|
198 |
+
_compiler = self.compiler
|
199 |
+
try:
|
200 |
+
if isinstance(ext, Library):
|
201 |
+
self.compiler = self.shlib_compiler
|
202 |
+
_build_ext.build_extension(self, ext)
|
203 |
+
if ext._needs_stub:
|
204 |
+
cmd = self.get_finalized_command('build_py').build_lib
|
205 |
+
self.write_stub(cmd, ext)
|
206 |
+
finally:
|
207 |
+
self.compiler = _compiler
|
208 |
+
|
209 |
+
def links_to_dynamic(self, ext):
|
210 |
+
"""Return true if 'ext' links to a dynamic lib in the same package"""
|
211 |
+
# XXX this should check to ensure the lib is actually being built
|
212 |
+
# XXX as dynamic, and not just using a locally-found version or a
|
213 |
+
# XXX static-compiled version
|
214 |
+
libnames = dict.fromkeys([lib._full_name for lib in self.shlibs])
|
215 |
+
pkg = '.'.join(ext._full_name.split('.')[:-1] + [''])
|
216 |
+
return any(pkg + libname in libnames for libname in ext.libraries)
|
217 |
+
|
218 |
+
def get_outputs(self):
|
219 |
+
return _build_ext.get_outputs(self) + self.__get_stubs_outputs()
|
220 |
+
|
221 |
+
def __get_stubs_outputs(self):
|
222 |
+
# assemble the base name for each extension that needs a stub
|
223 |
+
ns_ext_bases = (
|
224 |
+
os.path.join(self.build_lib, *ext._full_name.split('.'))
|
225 |
+
for ext in self.extensions
|
226 |
+
if ext._needs_stub
|
227 |
+
)
|
228 |
+
# pair each base with the extension
|
229 |
+
pairs = itertools.product(ns_ext_bases, self.__get_output_extensions())
|
230 |
+
return list(base + fnext for base, fnext in pairs)
|
231 |
+
|
232 |
+
def __get_output_extensions(self):
|
233 |
+
yield '.py'
|
234 |
+
yield '.pyc'
|
235 |
+
if self.get_finalized_command('build_py').optimize:
|
236 |
+
yield '.pyo'
|
237 |
+
|
238 |
+
def write_stub(self, output_dir, ext, compile=False):
|
239 |
+
log.info("writing stub loader for %s to %s", ext._full_name,
|
240 |
+
output_dir)
|
241 |
+
stub_file = (os.path.join(output_dir, *ext._full_name.split('.')) +
|
242 |
+
'.py')
|
243 |
+
if compile and os.path.exists(stub_file):
|
244 |
+
raise DistutilsError(stub_file + " already exists! Please delete.")
|
245 |
+
if not self.dry_run:
|
246 |
+
f = open(stub_file, 'w')
|
247 |
+
f.write(
|
248 |
+
'\n'.join([
|
249 |
+
"def __bootstrap__():",
|
250 |
+
" global __bootstrap__, __file__, __loader__",
|
251 |
+
" import sys, os, pkg_resources, importlib.util" +
|
252 |
+
if_dl(", dl"),
|
253 |
+
" __file__ = pkg_resources.resource_filename"
|
254 |
+
"(__name__,%r)"
|
255 |
+
% os.path.basename(ext._file_name),
|
256 |
+
" del __bootstrap__",
|
257 |
+
" if '__loader__' in globals():",
|
258 |
+
" del __loader__",
|
259 |
+
if_dl(" old_flags = sys.getdlopenflags()"),
|
260 |
+
" old_dir = os.getcwd()",
|
261 |
+
" try:",
|
262 |
+
" os.chdir(os.path.dirname(__file__))",
|
263 |
+
if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"),
|
264 |
+
" spec = importlib.util.spec_from_file_location(",
|
265 |
+
" __name__, __file__)",
|
266 |
+
" mod = importlib.util.module_from_spec(spec)",
|
267 |
+
" spec.loader.exec_module(mod)",
|
268 |
+
" finally:",
|
269 |
+
if_dl(" sys.setdlopenflags(old_flags)"),
|
270 |
+
" os.chdir(old_dir)",
|
271 |
+
"__bootstrap__()",
|
272 |
+
"" # terminal \n
|
273 |
+
])
|
274 |
+
)
|
275 |
+
f.close()
|
276 |
+
if compile:
|
277 |
+
from distutils.util import byte_compile
|
278 |
+
|
279 |
+
byte_compile([stub_file], optimize=0,
|
280 |
+
force=True, dry_run=self.dry_run)
|
281 |
+
optimize = self.get_finalized_command('install_lib').optimize
|
282 |
+
if optimize > 0:
|
283 |
+
byte_compile([stub_file], optimize=optimize,
|
284 |
+
force=True, dry_run=self.dry_run)
|
285 |
+
if os.path.exists(stub_file) and not self.dry_run:
|
286 |
+
os.unlink(stub_file)
|
287 |
+
|
288 |
+
|
289 |
+
if use_stubs or os.name == 'nt':
|
290 |
+
# Build shared libraries
|
291 |
+
#
|
292 |
+
def link_shared_object(
|
293 |
+
self, objects, output_libname, output_dir=None, libraries=None,
|
294 |
+
library_dirs=None, runtime_library_dirs=None, export_symbols=None,
|
295 |
+
debug=0, extra_preargs=None, extra_postargs=None, build_temp=None,
|
296 |
+
target_lang=None):
|
297 |
+
self.link(
|
298 |
+
self.SHARED_LIBRARY, objects, output_libname,
|
299 |
+
output_dir, libraries, library_dirs, runtime_library_dirs,
|
300 |
+
export_symbols, debug, extra_preargs, extra_postargs,
|
301 |
+
build_temp, target_lang
|
302 |
+
)
|
303 |
+
else:
|
304 |
+
# Build static libraries everywhere else
|
305 |
+
libtype = 'static'
|
306 |
+
|
307 |
+
def link_shared_object(
|
308 |
+
self, objects, output_libname, output_dir=None, libraries=None,
|
309 |
+
library_dirs=None, runtime_library_dirs=None, export_symbols=None,
|
310 |
+
debug=0, extra_preargs=None, extra_postargs=None, build_temp=None,
|
311 |
+
target_lang=None):
|
312 |
+
# XXX we need to either disallow these attrs on Library instances,
|
313 |
+
# or warn/abort here if set, or something...
|
314 |
+
# libraries=None, library_dirs=None, runtime_library_dirs=None,
|
315 |
+
# export_symbols=None, extra_preargs=None, extra_postargs=None,
|
316 |
+
# build_temp=None
|
317 |
+
|
318 |
+
assert output_dir is None # distutils build_ext doesn't pass this
|
319 |
+
output_dir, filename = os.path.split(output_libname)
|
320 |
+
basename, ext = os.path.splitext(filename)
|
321 |
+
if self.library_filename("x").startswith('lib'):
|
322 |
+
# strip 'lib' prefix; this is kludgy if some platform uses
|
323 |
+
# a different prefix
|
324 |
+
basename = basename[3:]
|
325 |
+
|
326 |
+
self.create_static_lib(
|
327 |
+
objects, basename, output_dir, debug, target_lang
|
328 |
+
)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/build_py.py
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from glob import glob
|
2 |
+
from distutils.util import convert_path
|
3 |
+
import distutils.command.build_py as orig
|
4 |
+
import os
|
5 |
+
import fnmatch
|
6 |
+
import textwrap
|
7 |
+
import io
|
8 |
+
import distutils.errors
|
9 |
+
import itertools
|
10 |
+
import stat
|
11 |
+
from setuptools.extern.more_itertools import unique_everseen
|
12 |
+
|
13 |
+
|
14 |
+
def make_writable(target):
|
15 |
+
os.chmod(target, os.stat(target).st_mode | stat.S_IWRITE)
|
16 |
+
|
17 |
+
|
18 |
+
class build_py(orig.build_py):
|
19 |
+
"""Enhanced 'build_py' command that includes data files with packages
|
20 |
+
|
21 |
+
The data files are specified via a 'package_data' argument to 'setup()'.
|
22 |
+
See 'setuptools.dist.Distribution' for more details.
|
23 |
+
|
24 |
+
Also, this version of the 'build_py' command allows you to specify both
|
25 |
+
'py_modules' and 'packages' in the same setup operation.
|
26 |
+
"""
|
27 |
+
|
28 |
+
def finalize_options(self):
|
29 |
+
orig.build_py.finalize_options(self)
|
30 |
+
self.package_data = self.distribution.package_data
|
31 |
+
self.exclude_package_data = self.distribution.exclude_package_data or {}
|
32 |
+
if 'data_files' in self.__dict__:
|
33 |
+
del self.__dict__['data_files']
|
34 |
+
self.__updated_files = []
|
35 |
+
|
36 |
+
def run(self):
|
37 |
+
"""Build modules, packages, and copy data files to build directory"""
|
38 |
+
if not self.py_modules and not self.packages:
|
39 |
+
return
|
40 |
+
|
41 |
+
if self.py_modules:
|
42 |
+
self.build_modules()
|
43 |
+
|
44 |
+
if self.packages:
|
45 |
+
self.build_packages()
|
46 |
+
self.build_package_data()
|
47 |
+
|
48 |
+
# Only compile actual .py files, using our base class' idea of what our
|
49 |
+
# output files are.
|
50 |
+
self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0))
|
51 |
+
|
52 |
+
def __getattr__(self, attr):
|
53 |
+
"lazily compute data files"
|
54 |
+
if attr == 'data_files':
|
55 |
+
self.data_files = self._get_data_files()
|
56 |
+
return self.data_files
|
57 |
+
return orig.build_py.__getattr__(self, attr)
|
58 |
+
|
59 |
+
def build_module(self, module, module_file, package):
|
60 |
+
outfile, copied = orig.build_py.build_module(self, module, module_file, package)
|
61 |
+
if copied:
|
62 |
+
self.__updated_files.append(outfile)
|
63 |
+
return outfile, copied
|
64 |
+
|
65 |
+
def _get_data_files(self):
|
66 |
+
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
|
67 |
+
self.analyze_manifest()
|
68 |
+
return list(map(self._get_pkg_data_files, self.packages or ()))
|
69 |
+
|
70 |
+
def get_data_files_without_manifest(self):
|
71 |
+
"""
|
72 |
+
Generate list of ``(package,src_dir,build_dir,filenames)`` tuples,
|
73 |
+
but without triggering any attempt to analyze or build the manifest.
|
74 |
+
"""
|
75 |
+
# Prevent eventual errors from unset `manifest_files`
|
76 |
+
# (that would otherwise be set by `analyze_manifest`)
|
77 |
+
self.__dict__.setdefault('manifest_files', {})
|
78 |
+
return list(map(self._get_pkg_data_files, self.packages or ()))
|
79 |
+
|
80 |
+
def _get_pkg_data_files(self, package):
|
81 |
+
# Locate package source directory
|
82 |
+
src_dir = self.get_package_dir(package)
|
83 |
+
|
84 |
+
# Compute package build directory
|
85 |
+
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
|
86 |
+
|
87 |
+
# Strip directory from globbed filenames
|
88 |
+
filenames = [
|
89 |
+
os.path.relpath(file, src_dir)
|
90 |
+
for file in self.find_data_files(package, src_dir)
|
91 |
+
]
|
92 |
+
return package, src_dir, build_dir, filenames
|
93 |
+
|
94 |
+
def find_data_files(self, package, src_dir):
|
95 |
+
"""Return filenames for package's data files in 'src_dir'"""
|
96 |
+
patterns = self._get_platform_patterns(
|
97 |
+
self.package_data,
|
98 |
+
package,
|
99 |
+
src_dir,
|
100 |
+
)
|
101 |
+
globs_expanded = map(glob, patterns)
|
102 |
+
# flatten the expanded globs into an iterable of matches
|
103 |
+
globs_matches = itertools.chain.from_iterable(globs_expanded)
|
104 |
+
glob_files = filter(os.path.isfile, globs_matches)
|
105 |
+
files = itertools.chain(
|
106 |
+
self.manifest_files.get(package, []),
|
107 |
+
glob_files,
|
108 |
+
)
|
109 |
+
return self.exclude_data_files(package, src_dir, files)
|
110 |
+
|
111 |
+
def build_package_data(self):
|
112 |
+
"""Copy data files into build directory"""
|
113 |
+
for package, src_dir, build_dir, filenames in self.data_files:
|
114 |
+
for filename in filenames:
|
115 |
+
target = os.path.join(build_dir, filename)
|
116 |
+
self.mkpath(os.path.dirname(target))
|
117 |
+
srcfile = os.path.join(src_dir, filename)
|
118 |
+
outf, copied = self.copy_file(srcfile, target)
|
119 |
+
make_writable(target)
|
120 |
+
srcfile = os.path.abspath(srcfile)
|
121 |
+
|
122 |
+
def analyze_manifest(self):
|
123 |
+
self.manifest_files = mf = {}
|
124 |
+
if not self.distribution.include_package_data:
|
125 |
+
return
|
126 |
+
src_dirs = {}
|
127 |
+
for package in self.packages or ():
|
128 |
+
# Locate package source directory
|
129 |
+
src_dirs[assert_relative(self.get_package_dir(package))] = package
|
130 |
+
|
131 |
+
self.run_command('egg_info')
|
132 |
+
ei_cmd = self.get_finalized_command('egg_info')
|
133 |
+
for path in ei_cmd.filelist.files:
|
134 |
+
d, f = os.path.split(assert_relative(path))
|
135 |
+
prev = None
|
136 |
+
oldf = f
|
137 |
+
while d and d != prev and d not in src_dirs:
|
138 |
+
prev = d
|
139 |
+
d, df = os.path.split(d)
|
140 |
+
f = os.path.join(df, f)
|
141 |
+
if d in src_dirs:
|
142 |
+
if path.endswith('.py') and f == oldf:
|
143 |
+
continue # it's a module, not data
|
144 |
+
mf.setdefault(src_dirs[d], []).append(path)
|
145 |
+
|
146 |
+
def get_data_files(self):
|
147 |
+
pass # Lazily compute data files in _get_data_files() function.
|
148 |
+
|
149 |
+
def check_package(self, package, package_dir):
|
150 |
+
"""Check namespace packages' __init__ for declare_namespace"""
|
151 |
+
try:
|
152 |
+
return self.packages_checked[package]
|
153 |
+
except KeyError:
|
154 |
+
pass
|
155 |
+
|
156 |
+
init_py = orig.build_py.check_package(self, package, package_dir)
|
157 |
+
self.packages_checked[package] = init_py
|
158 |
+
|
159 |
+
if not init_py or not self.distribution.namespace_packages:
|
160 |
+
return init_py
|
161 |
+
|
162 |
+
for pkg in self.distribution.namespace_packages:
|
163 |
+
if pkg == package or pkg.startswith(package + '.'):
|
164 |
+
break
|
165 |
+
else:
|
166 |
+
return init_py
|
167 |
+
|
168 |
+
with io.open(init_py, 'rb') as f:
|
169 |
+
contents = f.read()
|
170 |
+
if b'declare_namespace' not in contents:
|
171 |
+
raise distutils.errors.DistutilsError(
|
172 |
+
"Namespace package problem: %s is a namespace package, but "
|
173 |
+
"its\n__init__.py does not call declare_namespace()! Please "
|
174 |
+
'fix it.\n(See the setuptools manual under '
|
175 |
+
'"Namespace Packages" for details.)\n"' % (package,)
|
176 |
+
)
|
177 |
+
return init_py
|
178 |
+
|
179 |
+
def initialize_options(self):
|
180 |
+
self.packages_checked = {}
|
181 |
+
orig.build_py.initialize_options(self)
|
182 |
+
|
183 |
+
def get_package_dir(self, package):
|
184 |
+
res = orig.build_py.get_package_dir(self, package)
|
185 |
+
if self.distribution.src_root is not None:
|
186 |
+
return os.path.join(self.distribution.src_root, res)
|
187 |
+
return res
|
188 |
+
|
189 |
+
def exclude_data_files(self, package, src_dir, files):
|
190 |
+
"""Filter filenames for package's data files in 'src_dir'"""
|
191 |
+
files = list(files)
|
192 |
+
patterns = self._get_platform_patterns(
|
193 |
+
self.exclude_package_data,
|
194 |
+
package,
|
195 |
+
src_dir,
|
196 |
+
)
|
197 |
+
match_groups = (fnmatch.filter(files, pattern) for pattern in patterns)
|
198 |
+
# flatten the groups of matches into an iterable of matches
|
199 |
+
matches = itertools.chain.from_iterable(match_groups)
|
200 |
+
bad = set(matches)
|
201 |
+
keepers = (fn for fn in files if fn not in bad)
|
202 |
+
# ditch dupes
|
203 |
+
return list(unique_everseen(keepers))
|
204 |
+
|
205 |
+
@staticmethod
|
206 |
+
def _get_platform_patterns(spec, package, src_dir):
|
207 |
+
"""
|
208 |
+
yield platform-specific path patterns (suitable for glob
|
209 |
+
or fn_match) from a glob-based spec (such as
|
210 |
+
self.package_data or self.exclude_package_data)
|
211 |
+
matching package in src_dir.
|
212 |
+
"""
|
213 |
+
raw_patterns = itertools.chain(
|
214 |
+
spec.get('', []),
|
215 |
+
spec.get(package, []),
|
216 |
+
)
|
217 |
+
return (
|
218 |
+
# Each pattern has to be converted to a platform-specific path
|
219 |
+
os.path.join(src_dir, convert_path(pattern))
|
220 |
+
for pattern in raw_patterns
|
221 |
+
)
|
222 |
+
|
223 |
+
|
224 |
+
def assert_relative(path):
|
225 |
+
if not os.path.isabs(path):
|
226 |
+
return path
|
227 |
+
from distutils.errors import DistutilsSetupError
|
228 |
+
|
229 |
+
msg = (
|
230 |
+
textwrap.dedent(
|
231 |
+
"""
|
232 |
+
Error: setup script specifies an absolute path:
|
233 |
+
|
234 |
+
%s
|
235 |
+
|
236 |
+
setup() arguments must *always* be /-separated paths relative to the
|
237 |
+
setup.py directory, *never* absolute paths.
|
238 |
+
"""
|
239 |
+
).lstrip()
|
240 |
+
% path
|
241 |
+
)
|
242 |
+
raise DistutilsSetupError(msg)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/develop.py
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.util import convert_path
|
2 |
+
from distutils import log
|
3 |
+
from distutils.errors import DistutilsError, DistutilsOptionError
|
4 |
+
import os
|
5 |
+
import glob
|
6 |
+
import io
|
7 |
+
|
8 |
+
import pkg_resources
|
9 |
+
from setuptools.command.easy_install import easy_install
|
10 |
+
from setuptools import namespaces
|
11 |
+
import setuptools
|
12 |
+
|
13 |
+
|
14 |
+
class develop(namespaces.DevelopInstaller, easy_install):
|
15 |
+
"""Set up package for development"""
|
16 |
+
|
17 |
+
description = "install package in 'development mode'"
|
18 |
+
|
19 |
+
user_options = easy_install.user_options + [
|
20 |
+
("uninstall", "u", "Uninstall this source package"),
|
21 |
+
("egg-path=", None, "Set the path to be used in the .egg-link file"),
|
22 |
+
]
|
23 |
+
|
24 |
+
boolean_options = easy_install.boolean_options + ['uninstall']
|
25 |
+
|
26 |
+
command_consumes_arguments = False # override base
|
27 |
+
|
28 |
+
def run(self):
|
29 |
+
if self.uninstall:
|
30 |
+
self.multi_version = True
|
31 |
+
self.uninstall_link()
|
32 |
+
self.uninstall_namespaces()
|
33 |
+
else:
|
34 |
+
self.install_for_development()
|
35 |
+
self.warn_deprecated_options()
|
36 |
+
|
37 |
+
def initialize_options(self):
|
38 |
+
self.uninstall = None
|
39 |
+
self.egg_path = None
|
40 |
+
easy_install.initialize_options(self)
|
41 |
+
self.setup_path = None
|
42 |
+
self.always_copy_from = '.' # always copy eggs installed in curdir
|
43 |
+
|
44 |
+
def finalize_options(self):
|
45 |
+
ei = self.get_finalized_command("egg_info")
|
46 |
+
if ei.broken_egg_info:
|
47 |
+
template = "Please rename %r to %r before using 'develop'"
|
48 |
+
args = ei.egg_info, ei.broken_egg_info
|
49 |
+
raise DistutilsError(template % args)
|
50 |
+
self.args = [ei.egg_name]
|
51 |
+
|
52 |
+
easy_install.finalize_options(self)
|
53 |
+
self.expand_basedirs()
|
54 |
+
self.expand_dirs()
|
55 |
+
# pick up setup-dir .egg files only: no .egg-info
|
56 |
+
self.package_index.scan(glob.glob('*.egg'))
|
57 |
+
|
58 |
+
egg_link_fn = ei.egg_name + '.egg-link'
|
59 |
+
self.egg_link = os.path.join(self.install_dir, egg_link_fn)
|
60 |
+
self.egg_base = ei.egg_base
|
61 |
+
if self.egg_path is None:
|
62 |
+
self.egg_path = os.path.abspath(ei.egg_base)
|
63 |
+
|
64 |
+
target = pkg_resources.normalize_path(self.egg_base)
|
65 |
+
egg_path = pkg_resources.normalize_path(
|
66 |
+
os.path.join(self.install_dir, self.egg_path)
|
67 |
+
)
|
68 |
+
if egg_path != target:
|
69 |
+
raise DistutilsOptionError(
|
70 |
+
"--egg-path must be a relative path from the install"
|
71 |
+
" directory to " + target
|
72 |
+
)
|
73 |
+
|
74 |
+
# Make a distribution for the package's source
|
75 |
+
self.dist = pkg_resources.Distribution(
|
76 |
+
target,
|
77 |
+
pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)),
|
78 |
+
project_name=ei.egg_name,
|
79 |
+
)
|
80 |
+
|
81 |
+
self.setup_path = self._resolve_setup_path(
|
82 |
+
self.egg_base,
|
83 |
+
self.install_dir,
|
84 |
+
self.egg_path,
|
85 |
+
)
|
86 |
+
|
87 |
+
@staticmethod
|
88 |
+
def _resolve_setup_path(egg_base, install_dir, egg_path):
|
89 |
+
"""
|
90 |
+
Generate a path from egg_base back to '.' where the
|
91 |
+
setup script resides and ensure that path points to the
|
92 |
+
setup path from $install_dir/$egg_path.
|
93 |
+
"""
|
94 |
+
path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
|
95 |
+
if path_to_setup != os.curdir:
|
96 |
+
path_to_setup = '../' * (path_to_setup.count('/') + 1)
|
97 |
+
resolved = pkg_resources.normalize_path(
|
98 |
+
os.path.join(install_dir, egg_path, path_to_setup)
|
99 |
+
)
|
100 |
+
if resolved != pkg_resources.normalize_path(os.curdir):
|
101 |
+
raise DistutilsOptionError(
|
102 |
+
"Can't get a consistent path to setup script from"
|
103 |
+
" installation directory",
|
104 |
+
resolved,
|
105 |
+
pkg_resources.normalize_path(os.curdir),
|
106 |
+
)
|
107 |
+
return path_to_setup
|
108 |
+
|
109 |
+
def install_for_development(self):
|
110 |
+
self.run_command('egg_info')
|
111 |
+
|
112 |
+
# Build extensions in-place
|
113 |
+
self.reinitialize_command('build_ext', inplace=1)
|
114 |
+
self.run_command('build_ext')
|
115 |
+
|
116 |
+
if setuptools.bootstrap_install_from:
|
117 |
+
self.easy_install(setuptools.bootstrap_install_from)
|
118 |
+
setuptools.bootstrap_install_from = None
|
119 |
+
|
120 |
+
self.install_namespaces()
|
121 |
+
|
122 |
+
# create an .egg-link in the installation dir, pointing to our egg
|
123 |
+
log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
|
124 |
+
if not self.dry_run:
|
125 |
+
with open(self.egg_link, "w") as f:
|
126 |
+
f.write(self.egg_path + "\n" + self.setup_path)
|
127 |
+
# postprocess the installed distro, fixing up .pth, installing scripts,
|
128 |
+
# and handling requirements
|
129 |
+
self.process_distribution(None, self.dist, not self.no_deps)
|
130 |
+
|
131 |
+
def uninstall_link(self):
|
132 |
+
if os.path.exists(self.egg_link):
|
133 |
+
log.info("Removing %s (link to %s)", self.egg_link, self.egg_base)
|
134 |
+
egg_link_file = open(self.egg_link)
|
135 |
+
contents = [line.rstrip() for line in egg_link_file]
|
136 |
+
egg_link_file.close()
|
137 |
+
if contents not in ([self.egg_path], [self.egg_path, self.setup_path]):
|
138 |
+
log.warn("Link points to %s: uninstall aborted", contents)
|
139 |
+
return
|
140 |
+
if not self.dry_run:
|
141 |
+
os.unlink(self.egg_link)
|
142 |
+
if not self.dry_run:
|
143 |
+
self.update_pth(self.dist) # remove any .pth link to us
|
144 |
+
if self.distribution.scripts:
|
145 |
+
# XXX should also check for entry point scripts!
|
146 |
+
log.warn("Note: you must uninstall or replace scripts manually!")
|
147 |
+
|
148 |
+
def install_egg_scripts(self, dist):
|
149 |
+
if dist is not self.dist:
|
150 |
+
# Installing a dependency, so fall back to normal behavior
|
151 |
+
return easy_install.install_egg_scripts(self, dist)
|
152 |
+
|
153 |
+
# create wrapper scripts in the script dir, pointing to dist.scripts
|
154 |
+
|
155 |
+
# new-style...
|
156 |
+
self.install_wrapper_scripts(dist)
|
157 |
+
|
158 |
+
# ...and old-style
|
159 |
+
for script_name in self.distribution.scripts or []:
|
160 |
+
script_path = os.path.abspath(convert_path(script_name))
|
161 |
+
script_name = os.path.basename(script_path)
|
162 |
+
with io.open(script_path) as strm:
|
163 |
+
script_text = strm.read()
|
164 |
+
self.install_script(dist, script_name, script_text, script_path)
|
165 |
+
|
166 |
+
def install_wrapper_scripts(self, dist):
|
167 |
+
dist = VersionlessRequirement(dist)
|
168 |
+
return easy_install.install_wrapper_scripts(self, dist)
|
169 |
+
|
170 |
+
|
171 |
+
class VersionlessRequirement:
|
172 |
+
"""
|
173 |
+
Adapt a pkg_resources.Distribution to simply return the project
|
174 |
+
name as the 'requirement' so that scripts will work across
|
175 |
+
multiple versions.
|
176 |
+
|
177 |
+
>>> from pkg_resources import Distribution
|
178 |
+
>>> dist = Distribution(project_name='foo', version='1.0')
|
179 |
+
>>> str(dist.as_requirement())
|
180 |
+
'foo==1.0'
|
181 |
+
>>> adapted_dist = VersionlessRequirement(dist)
|
182 |
+
>>> str(adapted_dist.as_requirement())
|
183 |
+
'foo'
|
184 |
+
"""
|
185 |
+
|
186 |
+
def __init__(self, dist):
|
187 |
+
self.__dist = dist
|
188 |
+
|
189 |
+
def __getattr__(self, name):
|
190 |
+
return getattr(self.__dist, name)
|
191 |
+
|
192 |
+
def as_requirement(self):
|
193 |
+
return self.project_name
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/dist_info.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Create a dist_info directory
|
3 |
+
As defined in the wheel specification
|
4 |
+
"""
|
5 |
+
|
6 |
+
import os
|
7 |
+
|
8 |
+
from distutils.core import Command
|
9 |
+
from distutils import log
|
10 |
+
|
11 |
+
|
12 |
+
class dist_info(Command):
|
13 |
+
|
14 |
+
description = 'create a .dist-info directory'
|
15 |
+
|
16 |
+
user_options = [
|
17 |
+
('egg-base=', 'e', "directory containing .egg-info directories"
|
18 |
+
" (default: top of the source tree)"),
|
19 |
+
]
|
20 |
+
|
21 |
+
def initialize_options(self):
|
22 |
+
self.egg_base = None
|
23 |
+
|
24 |
+
def finalize_options(self):
|
25 |
+
pass
|
26 |
+
|
27 |
+
def run(self):
|
28 |
+
egg_info = self.get_finalized_command('egg_info')
|
29 |
+
egg_info.egg_base = self.egg_base
|
30 |
+
egg_info.finalize_options()
|
31 |
+
egg_info.run()
|
32 |
+
dist_info_dir = egg_info.egg_info[:-len('.egg-info')] + '.dist-info'
|
33 |
+
log.info("creating '{}'".format(os.path.abspath(dist_info_dir)))
|
34 |
+
|
35 |
+
bdist_wheel = self.get_finalized_command('bdist_wheel')
|
36 |
+
bdist_wheel.egg2dist(egg_info.egg_info, dist_info_dir)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/easy_install.py
ADDED
@@ -0,0 +1,2354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Easy Install
|
3 |
+
------------
|
4 |
+
|
5 |
+
A tool for doing automatic download/extract/build of distutils-based Python
|
6 |
+
packages. For detailed documentation, see the accompanying EasyInstall.txt
|
7 |
+
file, or visit the `EasyInstall home page`__.
|
8 |
+
|
9 |
+
__ https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
|
10 |
+
|
11 |
+
"""
|
12 |
+
|
13 |
+
from glob import glob
|
14 |
+
from distutils.util import get_platform
|
15 |
+
from distutils.util import convert_path, subst_vars
|
16 |
+
from distutils.errors import (
|
17 |
+
DistutilsArgError, DistutilsOptionError,
|
18 |
+
DistutilsError, DistutilsPlatformError,
|
19 |
+
)
|
20 |
+
from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS
|
21 |
+
from distutils import log, dir_util
|
22 |
+
from distutils.command.build_scripts import first_line_re
|
23 |
+
from distutils.spawn import find_executable
|
24 |
+
import sys
|
25 |
+
import os
|
26 |
+
import zipimport
|
27 |
+
import shutil
|
28 |
+
import tempfile
|
29 |
+
import zipfile
|
30 |
+
import re
|
31 |
+
import stat
|
32 |
+
import random
|
33 |
+
import textwrap
|
34 |
+
import warnings
|
35 |
+
import site
|
36 |
+
import struct
|
37 |
+
import contextlib
|
38 |
+
import subprocess
|
39 |
+
import shlex
|
40 |
+
import io
|
41 |
+
import configparser
|
42 |
+
|
43 |
+
|
44 |
+
from sysconfig import get_config_vars, get_path
|
45 |
+
|
46 |
+
from setuptools import SetuptoolsDeprecationWarning
|
47 |
+
|
48 |
+
from setuptools import Command
|
49 |
+
from setuptools.sandbox import run_setup
|
50 |
+
from setuptools.command import setopt
|
51 |
+
from setuptools.archive_util import unpack_archive
|
52 |
+
from setuptools.package_index import (
|
53 |
+
PackageIndex, parse_requirement_arg, URL_SCHEME,
|
54 |
+
)
|
55 |
+
from setuptools.command import bdist_egg, egg_info
|
56 |
+
from setuptools.wheel import Wheel
|
57 |
+
from pkg_resources import (
|
58 |
+
yield_lines, normalize_path, resource_string, ensure_directory,
|
59 |
+
get_distribution, find_distributions, Environment, Requirement,
|
60 |
+
Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound,
|
61 |
+
VersionConflict, DEVELOP_DIST,
|
62 |
+
)
|
63 |
+
import pkg_resources
|
64 |
+
|
65 |
+
# Turn on PEP440Warnings
|
66 |
+
warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
|
67 |
+
|
68 |
+
__all__ = [
|
69 |
+
'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
|
70 |
+
'get_exe_prefixes',
|
71 |
+
]
|
72 |
+
|
73 |
+
|
74 |
+
def is_64bit():
|
75 |
+
return struct.calcsize("P") == 8
|
76 |
+
|
77 |
+
|
78 |
+
def samefile(p1, p2):
|
79 |
+
"""
|
80 |
+
Determine if two paths reference the same file.
|
81 |
+
|
82 |
+
Augments os.path.samefile to work on Windows and
|
83 |
+
suppresses errors if the path doesn't exist.
|
84 |
+
"""
|
85 |
+
both_exist = os.path.exists(p1) and os.path.exists(p2)
|
86 |
+
use_samefile = hasattr(os.path, 'samefile') and both_exist
|
87 |
+
if use_samefile:
|
88 |
+
return os.path.samefile(p1, p2)
|
89 |
+
norm_p1 = os.path.normpath(os.path.normcase(p1))
|
90 |
+
norm_p2 = os.path.normpath(os.path.normcase(p2))
|
91 |
+
return norm_p1 == norm_p2
|
92 |
+
|
93 |
+
|
94 |
+
def _to_bytes(s):
|
95 |
+
return s.encode('utf8')
|
96 |
+
|
97 |
+
|
98 |
+
def isascii(s):
|
99 |
+
try:
|
100 |
+
s.encode('ascii')
|
101 |
+
return True
|
102 |
+
except UnicodeError:
|
103 |
+
return False
|
104 |
+
|
105 |
+
|
106 |
+
def _one_liner(text):
|
107 |
+
return textwrap.dedent(text).strip().replace('\n', '; ')
|
108 |
+
|
109 |
+
|
110 |
+
class easy_install(Command):
|
111 |
+
"""Manage a download/build/install process"""
|
112 |
+
description = "Find/get/install Python packages"
|
113 |
+
command_consumes_arguments = True
|
114 |
+
|
115 |
+
user_options = [
|
116 |
+
('prefix=', None, "installation prefix"),
|
117 |
+
("zip-ok", "z", "install package as a zipfile"),
|
118 |
+
("multi-version", "m", "make apps have to require() a version"),
|
119 |
+
("upgrade", "U", "force upgrade (searches PyPI for latest versions)"),
|
120 |
+
("install-dir=", "d", "install package to DIR"),
|
121 |
+
("script-dir=", "s", "install scripts to DIR"),
|
122 |
+
("exclude-scripts", "x", "Don't install scripts"),
|
123 |
+
("always-copy", "a", "Copy all needed packages to install dir"),
|
124 |
+
("index-url=", "i", "base URL of Python Package Index"),
|
125 |
+
("find-links=", "f", "additional URL(s) to search for packages"),
|
126 |
+
("build-directory=", "b",
|
127 |
+
"download/extract/build in DIR; keep the results"),
|
128 |
+
('optimize=', 'O',
|
129 |
+
"also compile with optimization: -O1 for \"python -O\", "
|
130 |
+
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
|
131 |
+
('record=', None,
|
132 |
+
"filename in which to record list of installed files"),
|
133 |
+
('always-unzip', 'Z', "don't install as a zipfile, no matter what"),
|
134 |
+
('site-dirs=', 'S', "list of directories where .pth files work"),
|
135 |
+
('editable', 'e', "Install specified packages in editable form"),
|
136 |
+
('no-deps', 'N', "don't install dependencies"),
|
137 |
+
('allow-hosts=', 'H', "pattern(s) that hostnames must match"),
|
138 |
+
('local-snapshots-ok', 'l',
|
139 |
+
"allow building eggs from local checkouts"),
|
140 |
+
('version', None, "print version information and exit"),
|
141 |
+
('install-layout=', None, "installation layout to choose (known values: deb)"),
|
142 |
+
('force-installation-into-system-dir', '0', "force installation into /usr"),
|
143 |
+
('no-find-links', None,
|
144 |
+
"Don't load find-links defined in packages being installed"),
|
145 |
+
('user', None, "install in user site-package '%s'" % site.USER_SITE)
|
146 |
+
]
|
147 |
+
boolean_options = [
|
148 |
+
'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy',
|
149 |
+
'editable',
|
150 |
+
'no-deps', 'local-snapshots-ok', 'version', 'force-installation-into-system-dir'
|
151 |
+
'user'
|
152 |
+
]
|
153 |
+
|
154 |
+
negative_opt = {'always-unzip': 'zip-ok'}
|
155 |
+
create_index = PackageIndex
|
156 |
+
|
157 |
+
def initialize_options(self):
|
158 |
+
warnings.warn(
|
159 |
+
"easy_install command is deprecated. "
|
160 |
+
"Use build and pip and other standards-based tools.",
|
161 |
+
EasyInstallDeprecationWarning,
|
162 |
+
)
|
163 |
+
|
164 |
+
# the --user option seems to be an opt-in one,
|
165 |
+
# so the default should be False.
|
166 |
+
self.user = 0
|
167 |
+
self.zip_ok = self.local_snapshots_ok = None
|
168 |
+
self.install_dir = self.script_dir = self.exclude_scripts = None
|
169 |
+
self.index_url = None
|
170 |
+
self.find_links = None
|
171 |
+
self.build_directory = None
|
172 |
+
self.args = None
|
173 |
+
self.optimize = self.record = None
|
174 |
+
self.upgrade = self.always_copy = self.multi_version = None
|
175 |
+
self.editable = self.no_deps = self.allow_hosts = None
|
176 |
+
self.root = self.prefix = self.no_report = None
|
177 |
+
self.version = None
|
178 |
+
self.install_purelib = None # for pure module distributions
|
179 |
+
self.install_platlib = None # non-pure (dists w/ extensions)
|
180 |
+
self.install_headers = None # for C/C++ headers
|
181 |
+
self.install_lib = None # set to either purelib or platlib
|
182 |
+
self.install_scripts = None
|
183 |
+
self.install_data = None
|
184 |
+
self.install_base = None
|
185 |
+
self.install_platbase = None
|
186 |
+
if site.ENABLE_USER_SITE:
|
187 |
+
self.install_userbase = site.USER_BASE
|
188 |
+
self.install_usersite = site.USER_SITE
|
189 |
+
else:
|
190 |
+
self.install_userbase = None
|
191 |
+
self.install_usersite = None
|
192 |
+
self.no_find_links = None
|
193 |
+
|
194 |
+
# Options not specifiable via command line
|
195 |
+
self.package_index = None
|
196 |
+
self.pth_file = self.always_copy_from = None
|
197 |
+
self.site_dirs = None
|
198 |
+
self.installed_projects = {}
|
199 |
+
# enable custom installation, known values: deb
|
200 |
+
self.install_layout = None
|
201 |
+
self.force_installation_into_system_dir = None
|
202 |
+
self.multiarch = None
|
203 |
+
|
204 |
+
# Always read easy_install options, even if we are subclassed, or have
|
205 |
+
# an independent instance created. This ensures that defaults will
|
206 |
+
# always come from the standard configuration file(s)' "easy_install"
|
207 |
+
# section, even if this is a "develop" or "install" command, or some
|
208 |
+
# other embedding.
|
209 |
+
self._dry_run = None
|
210 |
+
self.verbose = self.distribution.verbose
|
211 |
+
self.distribution._set_command_options(
|
212 |
+
self, self.distribution.get_option_dict('easy_install')
|
213 |
+
)
|
214 |
+
|
215 |
+
def delete_blockers(self, blockers):
|
216 |
+
extant_blockers = (
|
217 |
+
filename for filename in blockers
|
218 |
+
if os.path.exists(filename) or os.path.islink(filename)
|
219 |
+
)
|
220 |
+
list(map(self._delete_path, extant_blockers))
|
221 |
+
|
222 |
+
def _delete_path(self, path):
|
223 |
+
log.info("Deleting %s", path)
|
224 |
+
if self.dry_run:
|
225 |
+
return
|
226 |
+
|
227 |
+
is_tree = os.path.isdir(path) and not os.path.islink(path)
|
228 |
+
remover = rmtree if is_tree else os.unlink
|
229 |
+
remover(path)
|
230 |
+
|
231 |
+
@staticmethod
|
232 |
+
def _render_version():
|
233 |
+
"""
|
234 |
+
Render the Setuptools version and installation details, then exit.
|
235 |
+
"""
|
236 |
+
ver = '{}.{}'.format(*sys.version_info)
|
237 |
+
dist = get_distribution('setuptools')
|
238 |
+
tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})'
|
239 |
+
print(tmpl.format(**locals()))
|
240 |
+
raise SystemExit()
|
241 |
+
|
242 |
+
def finalize_options(self): # noqa: C901 # is too complex (25) # FIXME
|
243 |
+
self.version and self._render_version()
|
244 |
+
|
245 |
+
py_version = sys.version.split()[0]
|
246 |
+
prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix')
|
247 |
+
|
248 |
+
self.config_vars = {
|
249 |
+
'dist_name': self.distribution.get_name(),
|
250 |
+
'dist_version': self.distribution.get_version(),
|
251 |
+
'dist_fullname': self.distribution.get_fullname(),
|
252 |
+
'py_version': py_version,
|
253 |
+
'py_version_short': py_version[0:3],
|
254 |
+
'py_version_nodot': py_version[0] + py_version[2],
|
255 |
+
'sys_prefix': prefix,
|
256 |
+
'prefix': prefix,
|
257 |
+
'sys_exec_prefix': exec_prefix,
|
258 |
+
'exec_prefix': exec_prefix,
|
259 |
+
# Only python 3.2+ has abiflags
|
260 |
+
'abiflags': getattr(sys, 'abiflags', ''),
|
261 |
+
}
|
262 |
+
|
263 |
+
if site.ENABLE_USER_SITE:
|
264 |
+
self.config_vars['userbase'] = self.install_userbase
|
265 |
+
self.config_vars['usersite'] = self.install_usersite
|
266 |
+
|
267 |
+
elif self.user:
|
268 |
+
log.warn("WARNING: The user site-packages directory is disabled.")
|
269 |
+
|
270 |
+
self._fix_install_dir_for_user_site()
|
271 |
+
|
272 |
+
self.expand_basedirs()
|
273 |
+
self.expand_dirs()
|
274 |
+
|
275 |
+
if self.install_layout:
|
276 |
+
if not self.install_layout.lower() in ['deb']:
|
277 |
+
raise DistutilsOptionError("unknown value for --install-layout")
|
278 |
+
self.install_layout = self.install_layout.lower()
|
279 |
+
|
280 |
+
import sysconfig
|
281 |
+
if sys.version_info[:2] >= (3, 3):
|
282 |
+
self.multiarch = sysconfig.get_config_var('MULTIARCH')
|
283 |
+
|
284 |
+
self._expand(
|
285 |
+
'install_dir', 'script_dir', 'build_directory',
|
286 |
+
'site_dirs',
|
287 |
+
)
|
288 |
+
# If a non-default installation directory was specified, default the
|
289 |
+
# script directory to match it.
|
290 |
+
if self.script_dir is None:
|
291 |
+
self.script_dir = self.install_dir
|
292 |
+
|
293 |
+
if self.no_find_links is None:
|
294 |
+
self.no_find_links = False
|
295 |
+
|
296 |
+
# Let install_dir get set by install_lib command, which in turn
|
297 |
+
# gets its info from the install command, and takes into account
|
298 |
+
# --prefix and --home and all that other crud.
|
299 |
+
self.set_undefined_options(
|
300 |
+
'install_lib', ('install_dir', 'install_dir')
|
301 |
+
)
|
302 |
+
# Likewise, set default script_dir from 'install_scripts.install_dir'
|
303 |
+
self.set_undefined_options(
|
304 |
+
'install_scripts', ('install_dir', 'script_dir')
|
305 |
+
)
|
306 |
+
|
307 |
+
if self.user and self.install_purelib:
|
308 |
+
self.install_dir = self.install_purelib
|
309 |
+
self.script_dir = self.install_scripts
|
310 |
+
|
311 |
+
if self.prefix == '/usr' and not self.force_installation_into_system_dir:
|
312 |
+
raise DistutilsOptionError("""installation into /usr
|
313 |
+
|
314 |
+
Trying to install into the system managed parts of the file system. Please
|
315 |
+
consider to install to another location, or use the option
|
316 |
+
--force-installation-into-system-dir to overwrite this warning.
|
317 |
+
""")
|
318 |
+
|
319 |
+
# default --record from the install command
|
320 |
+
self.set_undefined_options('install', ('record', 'record'))
|
321 |
+
# Should this be moved to the if statement below? It's not used
|
322 |
+
# elsewhere
|
323 |
+
normpath = map(normalize_path, sys.path)
|
324 |
+
self.all_site_dirs = get_site_dirs()
|
325 |
+
if self.site_dirs is not None:
|
326 |
+
site_dirs = [
|
327 |
+
os.path.expanduser(s.strip()) for s in
|
328 |
+
self.site_dirs.split(',')
|
329 |
+
]
|
330 |
+
for d in site_dirs:
|
331 |
+
if not os.path.isdir(d):
|
332 |
+
log.warn("%s (in --site-dirs) does not exist", d)
|
333 |
+
elif normalize_path(d) not in normpath:
|
334 |
+
raise DistutilsOptionError(
|
335 |
+
d + " (in --site-dirs) is not on sys.path"
|
336 |
+
)
|
337 |
+
else:
|
338 |
+
self.all_site_dirs.append(normalize_path(d))
|
339 |
+
if not self.editable:
|
340 |
+
self.check_site_dir()
|
341 |
+
self.index_url = self.index_url or "https://pypi.org/simple/"
|
342 |
+
self.shadow_path = self.all_site_dirs[:]
|
343 |
+
for path_item in self.install_dir, normalize_path(self.script_dir):
|
344 |
+
if path_item not in self.shadow_path:
|
345 |
+
self.shadow_path.insert(0, path_item)
|
346 |
+
|
347 |
+
if self.allow_hosts is not None:
|
348 |
+
hosts = [s.strip() for s in self.allow_hosts.split(',')]
|
349 |
+
else:
|
350 |
+
hosts = ['*']
|
351 |
+
if self.package_index is None:
|
352 |
+
self.package_index = self.create_index(
|
353 |
+
self.index_url, search_path=self.shadow_path, hosts=hosts,
|
354 |
+
)
|
355 |
+
self.local_index = Environment(self.shadow_path + sys.path)
|
356 |
+
|
357 |
+
if self.find_links is not None:
|
358 |
+
if isinstance(self.find_links, str):
|
359 |
+
self.find_links = self.find_links.split()
|
360 |
+
else:
|
361 |
+
self.find_links = []
|
362 |
+
if self.local_snapshots_ok:
|
363 |
+
self.package_index.scan_egg_links(self.shadow_path + sys.path)
|
364 |
+
if not self.no_find_links:
|
365 |
+
self.package_index.add_find_links(self.find_links)
|
366 |
+
self.set_undefined_options('install_lib', ('optimize', 'optimize'))
|
367 |
+
if not isinstance(self.optimize, int):
|
368 |
+
try:
|
369 |
+
self.optimize = int(self.optimize)
|
370 |
+
if not (0 <= self.optimize <= 2):
|
371 |
+
raise ValueError
|
372 |
+
except ValueError as e:
|
373 |
+
raise DistutilsOptionError(
|
374 |
+
"--optimize must be 0, 1, or 2"
|
375 |
+
) from e
|
376 |
+
|
377 |
+
if self.editable and not self.build_directory:
|
378 |
+
raise DistutilsArgError(
|
379 |
+
"Must specify a build directory (-b) when using --editable"
|
380 |
+
)
|
381 |
+
if not self.args:
|
382 |
+
raise DistutilsArgError(
|
383 |
+
"No urls, filenames, or requirements specified (see --help)")
|
384 |
+
|
385 |
+
self.outputs = []
|
386 |
+
|
387 |
+
def _fix_install_dir_for_user_site(self):
|
388 |
+
"""
|
389 |
+
Fix the install_dir if "--user" was used.
|
390 |
+
"""
|
391 |
+
if not self.user or not site.ENABLE_USER_SITE:
|
392 |
+
return
|
393 |
+
|
394 |
+
self.create_home_path()
|
395 |
+
if self.install_userbase is None:
|
396 |
+
msg = "User base directory is not specified"
|
397 |
+
raise DistutilsPlatformError(msg)
|
398 |
+
self.install_base = self.install_platbase = self.install_userbase
|
399 |
+
scheme_name = os.name.replace('posix', 'unix') + '_user'
|
400 |
+
self.select_scheme(scheme_name)
|
401 |
+
|
402 |
+
def _expand_attrs(self, attrs):
|
403 |
+
for attr in attrs:
|
404 |
+
val = getattr(self, attr)
|
405 |
+
if val is not None:
|
406 |
+
if os.name == 'posix' or os.name == 'nt':
|
407 |
+
val = os.path.expanduser(val)
|
408 |
+
val = subst_vars(val, self.config_vars)
|
409 |
+
setattr(self, attr, val)
|
410 |
+
|
411 |
+
def expand_basedirs(self):
|
412 |
+
"""Calls `os.path.expanduser` on install_base, install_platbase and
|
413 |
+
root."""
|
414 |
+
self._expand_attrs(['install_base', 'install_platbase', 'root'])
|
415 |
+
|
416 |
+
def expand_dirs(self):
|
417 |
+
"""Calls `os.path.expanduser` on install dirs."""
|
418 |
+
dirs = [
|
419 |
+
'install_purelib',
|
420 |
+
'install_platlib',
|
421 |
+
'install_lib',
|
422 |
+
'install_headers',
|
423 |
+
'install_scripts',
|
424 |
+
'install_data',
|
425 |
+
]
|
426 |
+
self._expand_attrs(dirs)
|
427 |
+
|
428 |
+
def run(self, show_deprecation=True):
|
429 |
+
if show_deprecation:
|
430 |
+
self.announce(
|
431 |
+
"WARNING: The easy_install command is deprecated "
|
432 |
+
"and will be removed in a future version.",
|
433 |
+
log.WARN,
|
434 |
+
)
|
435 |
+
if self.verbose != self.distribution.verbose:
|
436 |
+
log.set_verbosity(self.verbose)
|
437 |
+
try:
|
438 |
+
for spec in self.args:
|
439 |
+
self.easy_install(spec, not self.no_deps)
|
440 |
+
if self.record:
|
441 |
+
outputs = list(sorted(self.outputs))
|
442 |
+
if self.root: # strip any package prefix
|
443 |
+
root_len = len(self.root)
|
444 |
+
for counter in range(len(outputs)):
|
445 |
+
outputs[counter] = outputs[counter][root_len:]
|
446 |
+
from distutils import file_util
|
447 |
+
|
448 |
+
self.execute(
|
449 |
+
file_util.write_file, (self.record, outputs),
|
450 |
+
"writing list of installed files to '%s'" %
|
451 |
+
self.record
|
452 |
+
)
|
453 |
+
self.warn_deprecated_options()
|
454 |
+
finally:
|
455 |
+
log.set_verbosity(self.distribution.verbose)
|
456 |
+
|
457 |
+
def pseudo_tempname(self):
|
458 |
+
"""Return a pseudo-tempname base in the install directory.
|
459 |
+
This code is intentionally naive; if a malicious party can write to
|
460 |
+
the target directory you're already in deep doodoo.
|
461 |
+
"""
|
462 |
+
try:
|
463 |
+
pid = os.getpid()
|
464 |
+
except Exception:
|
465 |
+
pid = random.randint(0, sys.maxsize)
|
466 |
+
return os.path.join(self.install_dir, "test-easy-install-%s" % pid)
|
467 |
+
|
468 |
+
def warn_deprecated_options(self):
|
469 |
+
pass
|
470 |
+
|
471 |
+
def check_site_dir(self): # noqa: C901 # is too complex (12) # FIXME
|
472 |
+
"""Verify that self.install_dir is .pth-capable dir, if needed"""
|
473 |
+
|
474 |
+
instdir = normalize_path(self.install_dir)
|
475 |
+
pth_file = os.path.join(instdir, 'easy-install.pth')
|
476 |
+
|
477 |
+
if not os.path.exists(instdir):
|
478 |
+
try:
|
479 |
+
os.makedirs(instdir)
|
480 |
+
except (OSError, IOError):
|
481 |
+
self.cant_write_to_target()
|
482 |
+
|
483 |
+
# Is it a configured, PYTHONPATH, implicit, or explicit site dir?
|
484 |
+
is_site_dir = instdir in self.all_site_dirs
|
485 |
+
|
486 |
+
if not is_site_dir and not self.multi_version:
|
487 |
+
# No? Then directly test whether it does .pth file processing
|
488 |
+
is_site_dir = self.check_pth_processing()
|
489 |
+
else:
|
490 |
+
# make sure we can write to target dir
|
491 |
+
testfile = self.pseudo_tempname() + '.write-test'
|
492 |
+
test_exists = os.path.exists(testfile)
|
493 |
+
try:
|
494 |
+
if test_exists:
|
495 |
+
os.unlink(testfile)
|
496 |
+
open(testfile, 'w').close()
|
497 |
+
os.unlink(testfile)
|
498 |
+
except (OSError, IOError):
|
499 |
+
self.cant_write_to_target()
|
500 |
+
|
501 |
+
if not is_site_dir and not self.multi_version:
|
502 |
+
# Can't install non-multi to non-site dir with easy_install
|
503 |
+
pythonpath = os.environ.get('PYTHONPATH', '')
|
504 |
+
log.warn(self.__no_default_msg, self.install_dir, pythonpath)
|
505 |
+
|
506 |
+
if is_site_dir:
|
507 |
+
if self.pth_file is None:
|
508 |
+
self.pth_file = PthDistributions(pth_file, self.all_site_dirs)
|
509 |
+
else:
|
510 |
+
self.pth_file = None
|
511 |
+
|
512 |
+
if self.multi_version and not os.path.exists(pth_file):
|
513 |
+
self.pth_file = None # don't create a .pth file
|
514 |
+
self.install_dir = instdir
|
515 |
+
|
516 |
+
__cant_write_msg = textwrap.dedent("""
|
517 |
+
can't create or remove files in install directory
|
518 |
+
|
519 |
+
The following error occurred while trying to add or remove files in the
|
520 |
+
installation directory:
|
521 |
+
|
522 |
+
%s
|
523 |
+
|
524 |
+
The installation directory you specified (via --install-dir, --prefix, or
|
525 |
+
the distutils default setting) was:
|
526 |
+
|
527 |
+
%s
|
528 |
+
""").lstrip() # noqa
|
529 |
+
|
530 |
+
__not_exists_id = textwrap.dedent("""
|
531 |
+
This directory does not currently exist. Please create it and try again, or
|
532 |
+
choose a different installation directory (using the -d or --install-dir
|
533 |
+
option).
|
534 |
+
""").lstrip() # noqa
|
535 |
+
|
536 |
+
__access_msg = textwrap.dedent("""
|
537 |
+
Perhaps your account does not have write access to this directory? If the
|
538 |
+
installation directory is a system-owned directory, you may need to sign in
|
539 |
+
as the administrator or "root" account. If you do not have administrative
|
540 |
+
access to this machine, you may wish to choose a different installation
|
541 |
+
directory, preferably one that is listed in your PYTHONPATH environment
|
542 |
+
variable.
|
543 |
+
|
544 |
+
For information on other options, you may wish to consult the
|
545 |
+
documentation at:
|
546 |
+
|
547 |
+
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
|
548 |
+
|
549 |
+
Please make the appropriate changes for your system and try again.
|
550 |
+
""").lstrip() # noqa
|
551 |
+
|
552 |
+
def cant_write_to_target(self):
|
553 |
+
msg = self.__cant_write_msg % (sys.exc_info()[1], self.install_dir,)
|
554 |
+
|
555 |
+
if not os.path.exists(self.install_dir):
|
556 |
+
msg += '\n' + self.__not_exists_id
|
557 |
+
else:
|
558 |
+
msg += '\n' + self.__access_msg
|
559 |
+
raise DistutilsError(msg)
|
560 |
+
|
561 |
+
def check_pth_processing(self):
|
562 |
+
"""Empirically verify whether .pth files are supported in inst. dir"""
|
563 |
+
instdir = self.install_dir
|
564 |
+
log.info("Checking .pth file support in %s", instdir)
|
565 |
+
pth_file = self.pseudo_tempname() + ".pth"
|
566 |
+
ok_file = pth_file + '.ok'
|
567 |
+
ok_exists = os.path.exists(ok_file)
|
568 |
+
tmpl = _one_liner("""
|
569 |
+
import os
|
570 |
+
f = open({ok_file!r}, 'w')
|
571 |
+
f.write('OK')
|
572 |
+
f.close()
|
573 |
+
""") + '\n'
|
574 |
+
try:
|
575 |
+
if ok_exists:
|
576 |
+
os.unlink(ok_file)
|
577 |
+
dirname = os.path.dirname(ok_file)
|
578 |
+
os.makedirs(dirname, exist_ok=True)
|
579 |
+
f = open(pth_file, 'w')
|
580 |
+
except (OSError, IOError):
|
581 |
+
self.cant_write_to_target()
|
582 |
+
else:
|
583 |
+
try:
|
584 |
+
f.write(tmpl.format(**locals()))
|
585 |
+
f.close()
|
586 |
+
f = None
|
587 |
+
executable = sys.executable
|
588 |
+
if os.name == 'nt':
|
589 |
+
dirname, basename = os.path.split(executable)
|
590 |
+
alt = os.path.join(dirname, 'pythonw.exe')
|
591 |
+
use_alt = (
|
592 |
+
basename.lower() == 'python.exe' and
|
593 |
+
os.path.exists(alt)
|
594 |
+
)
|
595 |
+
if use_alt:
|
596 |
+
# use pythonw.exe to avoid opening a console window
|
597 |
+
executable = alt
|
598 |
+
|
599 |
+
from distutils.spawn import spawn
|
600 |
+
|
601 |
+
spawn([executable, '-E', '-c', 'pass'], 0)
|
602 |
+
|
603 |
+
if os.path.exists(ok_file):
|
604 |
+
log.info(
|
605 |
+
"TEST PASSED: %s appears to support .pth files",
|
606 |
+
instdir
|
607 |
+
)
|
608 |
+
return True
|
609 |
+
finally:
|
610 |
+
if f:
|
611 |
+
f.close()
|
612 |
+
if os.path.exists(ok_file):
|
613 |
+
os.unlink(ok_file)
|
614 |
+
if os.path.exists(pth_file):
|
615 |
+
os.unlink(pth_file)
|
616 |
+
if not self.multi_version:
|
617 |
+
log.warn("TEST FAILED: %s does NOT support .pth files", instdir)
|
618 |
+
return False
|
619 |
+
|
620 |
+
def install_egg_scripts(self, dist):
|
621 |
+
"""Write all the scripts for `dist`, unless scripts are excluded"""
|
622 |
+
if not self.exclude_scripts and dist.metadata_isdir('scripts'):
|
623 |
+
for script_name in dist.metadata_listdir('scripts'):
|
624 |
+
if dist.metadata_isdir('scripts/' + script_name):
|
625 |
+
# The "script" is a directory, likely a Python 3
|
626 |
+
# __pycache__ directory, so skip it.
|
627 |
+
continue
|
628 |
+
self.install_script(
|
629 |
+
dist, script_name,
|
630 |
+
dist.get_metadata('scripts/' + script_name)
|
631 |
+
)
|
632 |
+
self.install_wrapper_scripts(dist)
|
633 |
+
|
634 |
+
def add_output(self, path):
|
635 |
+
if os.path.isdir(path):
|
636 |
+
for base, dirs, files in os.walk(path):
|
637 |
+
for filename in files:
|
638 |
+
self.outputs.append(os.path.join(base, filename))
|
639 |
+
else:
|
640 |
+
self.outputs.append(path)
|
641 |
+
|
642 |
+
def not_editable(self, spec):
|
643 |
+
if self.editable:
|
644 |
+
raise DistutilsArgError(
|
645 |
+
"Invalid argument %r: you can't use filenames or URLs "
|
646 |
+
"with --editable (except via the --find-links option)."
|
647 |
+
% (spec,)
|
648 |
+
)
|
649 |
+
|
650 |
+
def check_editable(self, spec):
|
651 |
+
if not self.editable:
|
652 |
+
return
|
653 |
+
|
654 |
+
if os.path.exists(os.path.join(self.build_directory, spec.key)):
|
655 |
+
raise DistutilsArgError(
|
656 |
+
"%r already exists in %s; can't do a checkout there" %
|
657 |
+
(spec.key, self.build_directory)
|
658 |
+
)
|
659 |
+
|
660 |
+
@contextlib.contextmanager
|
661 |
+
def _tmpdir(self):
|
662 |
+
tmpdir = tempfile.mkdtemp(prefix=u"easy_install-")
|
663 |
+
try:
|
664 |
+
# cast to str as workaround for #709 and #710 and #712
|
665 |
+
yield str(tmpdir)
|
666 |
+
finally:
|
667 |
+
os.path.exists(tmpdir) and rmtree(tmpdir)
|
668 |
+
|
669 |
+
def easy_install(self, spec, deps=False):
|
670 |
+
with self._tmpdir() as tmpdir:
|
671 |
+
if not isinstance(spec, Requirement):
|
672 |
+
if URL_SCHEME(spec):
|
673 |
+
# It's a url, download it to tmpdir and process
|
674 |
+
self.not_editable(spec)
|
675 |
+
dl = self.package_index.download(spec, tmpdir)
|
676 |
+
return self.install_item(None, dl, tmpdir, deps, True)
|
677 |
+
|
678 |
+
elif os.path.exists(spec):
|
679 |
+
# Existing file or directory, just process it directly
|
680 |
+
self.not_editable(spec)
|
681 |
+
return self.install_item(None, spec, tmpdir, deps, True)
|
682 |
+
else:
|
683 |
+
spec = parse_requirement_arg(spec)
|
684 |
+
|
685 |
+
self.check_editable(spec)
|
686 |
+
dist = self.package_index.fetch_distribution(
|
687 |
+
spec, tmpdir, self.upgrade, self.editable,
|
688 |
+
not self.always_copy, self.local_index
|
689 |
+
)
|
690 |
+
if dist is None:
|
691 |
+
msg = "Could not find suitable distribution for %r" % spec
|
692 |
+
if self.always_copy:
|
693 |
+
msg += " (--always-copy skips system and development eggs)"
|
694 |
+
raise DistutilsError(msg)
|
695 |
+
elif dist.precedence == DEVELOP_DIST:
|
696 |
+
# .egg-info dists don't need installing, just process deps
|
697 |
+
self.process_distribution(spec, dist, deps, "Using")
|
698 |
+
return dist
|
699 |
+
else:
|
700 |
+
return self.install_item(spec, dist.location, tmpdir, deps)
|
701 |
+
|
702 |
+
def install_item(self, spec, download, tmpdir, deps, install_needed=False):
|
703 |
+
|
704 |
+
# Installation is also needed if file in tmpdir or is not an egg
|
705 |
+
install_needed = install_needed or self.always_copy
|
706 |
+
install_needed = install_needed or os.path.dirname(download) == tmpdir
|
707 |
+
install_needed = install_needed or not download.endswith('.egg')
|
708 |
+
install_needed = install_needed or (
|
709 |
+
self.always_copy_from is not None and
|
710 |
+
os.path.dirname(normalize_path(download)) ==
|
711 |
+
normalize_path(self.always_copy_from)
|
712 |
+
)
|
713 |
+
|
714 |
+
if spec and not install_needed:
|
715 |
+
# at this point, we know it's a local .egg, we just don't know if
|
716 |
+
# it's already installed.
|
717 |
+
for dist in self.local_index[spec.project_name]:
|
718 |
+
if dist.location == download:
|
719 |
+
break
|
720 |
+
else:
|
721 |
+
install_needed = True # it's not in the local index
|
722 |
+
|
723 |
+
log.info("Processing %s", os.path.basename(download))
|
724 |
+
|
725 |
+
if install_needed:
|
726 |
+
dists = self.install_eggs(spec, download, tmpdir)
|
727 |
+
for dist in dists:
|
728 |
+
self.process_distribution(spec, dist, deps)
|
729 |
+
else:
|
730 |
+
dists = [self.egg_distribution(download)]
|
731 |
+
self.process_distribution(spec, dists[0], deps, "Using")
|
732 |
+
|
733 |
+
if spec is not None:
|
734 |
+
for dist in dists:
|
735 |
+
if dist in spec:
|
736 |
+
return dist
|
737 |
+
|
738 |
+
def select_scheme(self, name):
|
739 |
+
"""Sets the install directories by applying the install schemes."""
|
740 |
+
# it's the caller's problem if they supply a bad name!
|
741 |
+
scheme = INSTALL_SCHEMES[name]
|
742 |
+
for key in SCHEME_KEYS:
|
743 |
+
attrname = 'install_' + key
|
744 |
+
if getattr(self, attrname) is None:
|
745 |
+
setattr(self, attrname, scheme[key])
|
746 |
+
|
747 |
+
# FIXME: 'easy_install.process_distribution' is too complex (12)
|
748 |
+
def process_distribution( # noqa: C901
|
749 |
+
self, requirement, dist, deps=True, *info,
|
750 |
+
):
|
751 |
+
self.update_pth(dist)
|
752 |
+
self.package_index.add(dist)
|
753 |
+
if dist in self.local_index[dist.key]:
|
754 |
+
self.local_index.remove(dist)
|
755 |
+
self.local_index.add(dist)
|
756 |
+
self.install_egg_scripts(dist)
|
757 |
+
self.installed_projects[dist.key] = dist
|
758 |
+
log.info(self.installation_report(requirement, dist, *info))
|
759 |
+
if (dist.has_metadata('dependency_links.txt') and
|
760 |
+
not self.no_find_links):
|
761 |
+
self.package_index.add_find_links(
|
762 |
+
dist.get_metadata_lines('dependency_links.txt')
|
763 |
+
)
|
764 |
+
if not deps and not self.always_copy:
|
765 |
+
return
|
766 |
+
elif requirement is not None and dist.key != requirement.key:
|
767 |
+
log.warn("Skipping dependencies for %s", dist)
|
768 |
+
return # XXX this is not the distribution we were looking for
|
769 |
+
elif requirement is None or dist not in requirement:
|
770 |
+
# if we wound up with a different version, resolve what we've got
|
771 |
+
distreq = dist.as_requirement()
|
772 |
+
requirement = Requirement(str(distreq))
|
773 |
+
log.info("Processing dependencies for %s", requirement)
|
774 |
+
try:
|
775 |
+
distros = WorkingSet([]).resolve(
|
776 |
+
[requirement], self.local_index, self.easy_install
|
777 |
+
)
|
778 |
+
except DistributionNotFound as e:
|
779 |
+
raise DistutilsError(str(e)) from e
|
780 |
+
except VersionConflict as e:
|
781 |
+
raise DistutilsError(e.report()) from e
|
782 |
+
if self.always_copy or self.always_copy_from:
|
783 |
+
# Force all the relevant distros to be copied or activated
|
784 |
+
for dist in distros:
|
785 |
+
if dist.key not in self.installed_projects:
|
786 |
+
self.easy_install(dist.as_requirement())
|
787 |
+
log.info("Finished processing dependencies for %s", requirement)
|
788 |
+
|
789 |
+
def should_unzip(self, dist):
|
790 |
+
if self.zip_ok is not None:
|
791 |
+
return not self.zip_ok
|
792 |
+
if dist.has_metadata('not-zip-safe'):
|
793 |
+
return True
|
794 |
+
if not dist.has_metadata('zip-safe'):
|
795 |
+
return True
|
796 |
+
return False
|
797 |
+
|
798 |
+
def maybe_move(self, spec, dist_filename, setup_base):
|
799 |
+
dst = os.path.join(self.build_directory, spec.key)
|
800 |
+
if os.path.exists(dst):
|
801 |
+
msg = (
|
802 |
+
"%r already exists in %s; build directory %s will not be kept"
|
803 |
+
)
|
804 |
+
log.warn(msg, spec.key, self.build_directory, setup_base)
|
805 |
+
return setup_base
|
806 |
+
if os.path.isdir(dist_filename):
|
807 |
+
setup_base = dist_filename
|
808 |
+
else:
|
809 |
+
if os.path.dirname(dist_filename) == setup_base:
|
810 |
+
os.unlink(dist_filename) # get it out of the tmp dir
|
811 |
+
contents = os.listdir(setup_base)
|
812 |
+
if len(contents) == 1:
|
813 |
+
dist_filename = os.path.join(setup_base, contents[0])
|
814 |
+
if os.path.isdir(dist_filename):
|
815 |
+
# if the only thing there is a directory, move it instead
|
816 |
+
setup_base = dist_filename
|
817 |
+
ensure_directory(dst)
|
818 |
+
shutil.move(setup_base, dst)
|
819 |
+
return dst
|
820 |
+
|
821 |
+
def install_wrapper_scripts(self, dist):
|
822 |
+
if self.exclude_scripts:
|
823 |
+
return
|
824 |
+
for args in ScriptWriter.best().get_args(dist):
|
825 |
+
self.write_script(*args)
|
826 |
+
|
827 |
+
def install_script(self, dist, script_name, script_text, dev_path=None):
|
828 |
+
"""Generate a legacy script wrapper and install it"""
|
829 |
+
spec = str(dist.as_requirement())
|
830 |
+
is_script = is_python_script(script_text, script_name)
|
831 |
+
|
832 |
+
if is_script:
|
833 |
+
body = self._load_template(dev_path) % locals()
|
834 |
+
script_text = ScriptWriter.get_header(script_text) + body
|
835 |
+
self.write_script(script_name, _to_bytes(script_text), 'b')
|
836 |
+
|
837 |
+
@staticmethod
|
838 |
+
def _load_template(dev_path):
|
839 |
+
"""
|
840 |
+
There are a couple of template scripts in the package. This
|
841 |
+
function loads one of them and prepares it for use.
|
842 |
+
"""
|
843 |
+
# See https://github.com/pypa/setuptools/issues/134 for info
|
844 |
+
# on script file naming and downstream issues with SVR4
|
845 |
+
name = 'script.tmpl'
|
846 |
+
if dev_path:
|
847 |
+
name = name.replace('.tmpl', ' (dev).tmpl')
|
848 |
+
|
849 |
+
raw_bytes = resource_string('setuptools', name)
|
850 |
+
return raw_bytes.decode('utf-8')
|
851 |
+
|
852 |
+
def write_script(self, script_name, contents, mode="t", blockers=()):
|
853 |
+
"""Write an executable file to the scripts directory"""
|
854 |
+
self.delete_blockers( # clean up old .py/.pyw w/o a script
|
855 |
+
[os.path.join(self.script_dir, x) for x in blockers]
|
856 |
+
)
|
857 |
+
log.info("Installing %s script to %s", script_name, self.script_dir)
|
858 |
+
target = os.path.join(self.script_dir, script_name)
|
859 |
+
self.add_output(target)
|
860 |
+
|
861 |
+
if self.dry_run:
|
862 |
+
return
|
863 |
+
|
864 |
+
mask = current_umask()
|
865 |
+
ensure_directory(target)
|
866 |
+
if os.path.exists(target):
|
867 |
+
os.unlink(target)
|
868 |
+
with open(target, "w" + mode) as f:
|
869 |
+
f.write(contents)
|
870 |
+
chmod(target, 0o777 - mask)
|
871 |
+
|
872 |
+
def install_eggs(self, spec, dist_filename, tmpdir):
|
873 |
+
# .egg dirs or files are already built, so just return them
|
874 |
+
installer_map = {
|
875 |
+
'.egg': self.install_egg,
|
876 |
+
'.exe': self.install_exe,
|
877 |
+
'.whl': self.install_wheel,
|
878 |
+
}
|
879 |
+
try:
|
880 |
+
install_dist = installer_map[
|
881 |
+
dist_filename.lower()[-4:]
|
882 |
+
]
|
883 |
+
except KeyError:
|
884 |
+
pass
|
885 |
+
else:
|
886 |
+
return [install_dist(dist_filename, tmpdir)]
|
887 |
+
|
888 |
+
# Anything else, try to extract and build
|
889 |
+
setup_base = tmpdir
|
890 |
+
if os.path.isfile(dist_filename) and not dist_filename.endswith('.py'):
|
891 |
+
unpack_archive(dist_filename, tmpdir, self.unpack_progress)
|
892 |
+
elif os.path.isdir(dist_filename):
|
893 |
+
setup_base = os.path.abspath(dist_filename)
|
894 |
+
|
895 |
+
if (setup_base.startswith(tmpdir) # something we downloaded
|
896 |
+
and self.build_directory and spec is not None):
|
897 |
+
setup_base = self.maybe_move(spec, dist_filename, setup_base)
|
898 |
+
|
899 |
+
# Find the setup.py file
|
900 |
+
setup_script = os.path.join(setup_base, 'setup.py')
|
901 |
+
|
902 |
+
if not os.path.exists(setup_script):
|
903 |
+
setups = glob(os.path.join(setup_base, '*', 'setup.py'))
|
904 |
+
if not setups:
|
905 |
+
raise DistutilsError(
|
906 |
+
"Couldn't find a setup script in %s" %
|
907 |
+
os.path.abspath(dist_filename)
|
908 |
+
)
|
909 |
+
if len(setups) > 1:
|
910 |
+
raise DistutilsError(
|
911 |
+
"Multiple setup scripts in %s" %
|
912 |
+
os.path.abspath(dist_filename)
|
913 |
+
)
|
914 |
+
setup_script = setups[0]
|
915 |
+
|
916 |
+
# Now run it, and return the result
|
917 |
+
if self.editable:
|
918 |
+
log.info(self.report_editable(spec, setup_script))
|
919 |
+
return []
|
920 |
+
else:
|
921 |
+
return self.build_and_install(setup_script, setup_base)
|
922 |
+
|
923 |
+
def egg_distribution(self, egg_path):
|
924 |
+
if os.path.isdir(egg_path):
|
925 |
+
metadata = PathMetadata(egg_path, os.path.join(egg_path,
|
926 |
+
'EGG-INFO'))
|
927 |
+
else:
|
928 |
+
metadata = EggMetadata(zipimport.zipimporter(egg_path))
|
929 |
+
return Distribution.from_filename(egg_path, metadata=metadata)
|
930 |
+
|
931 |
+
# FIXME: 'easy_install.install_egg' is too complex (11)
|
932 |
+
def install_egg(self, egg_path, tmpdir): # noqa: C901
|
933 |
+
destination = os.path.join(
|
934 |
+
self.install_dir,
|
935 |
+
os.path.basename(egg_path),
|
936 |
+
)
|
937 |
+
destination = os.path.abspath(destination)
|
938 |
+
if not self.dry_run:
|
939 |
+
ensure_directory(destination)
|
940 |
+
|
941 |
+
dist = self.egg_distribution(egg_path)
|
942 |
+
if not samefile(egg_path, destination):
|
943 |
+
if os.path.isdir(destination) and not os.path.islink(destination):
|
944 |
+
dir_util.remove_tree(destination, dry_run=self.dry_run)
|
945 |
+
elif os.path.exists(destination):
|
946 |
+
self.execute(
|
947 |
+
os.unlink,
|
948 |
+
(destination,),
|
949 |
+
"Removing " + destination,
|
950 |
+
)
|
951 |
+
try:
|
952 |
+
new_dist_is_zipped = False
|
953 |
+
if os.path.isdir(egg_path):
|
954 |
+
if egg_path.startswith(tmpdir):
|
955 |
+
f, m = shutil.move, "Moving"
|
956 |
+
else:
|
957 |
+
f, m = shutil.copytree, "Copying"
|
958 |
+
elif self.should_unzip(dist):
|
959 |
+
self.mkpath(destination)
|
960 |
+
f, m = self.unpack_and_compile, "Extracting"
|
961 |
+
else:
|
962 |
+
new_dist_is_zipped = True
|
963 |
+
if egg_path.startswith(tmpdir):
|
964 |
+
f, m = shutil.move, "Moving"
|
965 |
+
else:
|
966 |
+
f, m = shutil.copy2, "Copying"
|
967 |
+
self.execute(
|
968 |
+
f,
|
969 |
+
(egg_path, destination),
|
970 |
+
(m + " %s to %s") % (
|
971 |
+
os.path.basename(egg_path),
|
972 |
+
os.path.dirname(destination)
|
973 |
+
),
|
974 |
+
)
|
975 |
+
update_dist_caches(
|
976 |
+
destination,
|
977 |
+
fix_zipimporter_caches=new_dist_is_zipped,
|
978 |
+
)
|
979 |
+
except Exception:
|
980 |
+
update_dist_caches(destination, fix_zipimporter_caches=False)
|
981 |
+
raise
|
982 |
+
|
983 |
+
self.add_output(destination)
|
984 |
+
return self.egg_distribution(destination)
|
985 |
+
|
986 |
+
def install_exe(self, dist_filename, tmpdir):
|
987 |
+
# See if it's valid, get data
|
988 |
+
cfg = extract_wininst_cfg(dist_filename)
|
989 |
+
if cfg is None:
|
990 |
+
raise DistutilsError(
|
991 |
+
"%s is not a valid distutils Windows .exe" % dist_filename
|
992 |
+
)
|
993 |
+
# Create a dummy distribution object until we build the real distro
|
994 |
+
dist = Distribution(
|
995 |
+
None,
|
996 |
+
project_name=cfg.get('metadata', 'name'),
|
997 |
+
version=cfg.get('metadata', 'version'), platform=get_platform(),
|
998 |
+
)
|
999 |
+
|
1000 |
+
# Convert the .exe to an unpacked egg
|
1001 |
+
egg_path = os.path.join(tmpdir, dist.egg_name() + '.egg')
|
1002 |
+
dist.location = egg_path
|
1003 |
+
egg_tmp = egg_path + '.tmp'
|
1004 |
+
_egg_info = os.path.join(egg_tmp, 'EGG-INFO')
|
1005 |
+
pkg_inf = os.path.join(_egg_info, 'PKG-INFO')
|
1006 |
+
ensure_directory(pkg_inf) # make sure EGG-INFO dir exists
|
1007 |
+
dist._provider = PathMetadata(egg_tmp, _egg_info) # XXX
|
1008 |
+
self.exe_to_egg(dist_filename, egg_tmp)
|
1009 |
+
|
1010 |
+
# Write EGG-INFO/PKG-INFO
|
1011 |
+
if not os.path.exists(pkg_inf):
|
1012 |
+
f = open(pkg_inf, 'w')
|
1013 |
+
f.write('Metadata-Version: 1.0\n')
|
1014 |
+
for k, v in cfg.items('metadata'):
|
1015 |
+
if k != 'target_version':
|
1016 |
+
f.write('%s: %s\n' % (k.replace('_', '-').title(), v))
|
1017 |
+
f.close()
|
1018 |
+
script_dir = os.path.join(_egg_info, 'scripts')
|
1019 |
+
# delete entry-point scripts to avoid duping
|
1020 |
+
self.delete_blockers([
|
1021 |
+
os.path.join(script_dir, args[0])
|
1022 |
+
for args in ScriptWriter.get_args(dist)
|
1023 |
+
])
|
1024 |
+
# Build .egg file from tmpdir
|
1025 |
+
bdist_egg.make_zipfile(
|
1026 |
+
egg_path, egg_tmp, verbose=self.verbose, dry_run=self.dry_run,
|
1027 |
+
)
|
1028 |
+
# install the .egg
|
1029 |
+
return self.install_egg(egg_path, tmpdir)
|
1030 |
+
|
1031 |
+
# FIXME: 'easy_install.exe_to_egg' is too complex (12)
|
1032 |
+
def exe_to_egg(self, dist_filename, egg_tmp): # noqa: C901
|
1033 |
+
"""Extract a bdist_wininst to the directories an egg would use"""
|
1034 |
+
# Check for .pth file and set up prefix translations
|
1035 |
+
prefixes = get_exe_prefixes(dist_filename)
|
1036 |
+
to_compile = []
|
1037 |
+
native_libs = []
|
1038 |
+
top_level = {}
|
1039 |
+
|
1040 |
+
def process(src, dst):
|
1041 |
+
s = src.lower()
|
1042 |
+
for old, new in prefixes:
|
1043 |
+
if s.startswith(old):
|
1044 |
+
src = new + src[len(old):]
|
1045 |
+
parts = src.split('/')
|
1046 |
+
dst = os.path.join(egg_tmp, *parts)
|
1047 |
+
dl = dst.lower()
|
1048 |
+
if dl.endswith('.pyd') or dl.endswith('.dll'):
|
1049 |
+
parts[-1] = bdist_egg.strip_module(parts[-1])
|
1050 |
+
top_level[os.path.splitext(parts[0])[0]] = 1
|
1051 |
+
native_libs.append(src)
|
1052 |
+
elif dl.endswith('.py') and old != 'SCRIPTS/':
|
1053 |
+
top_level[os.path.splitext(parts[0])[0]] = 1
|
1054 |
+
to_compile.append(dst)
|
1055 |
+
return dst
|
1056 |
+
if not src.endswith('.pth'):
|
1057 |
+
log.warn("WARNING: can't process %s", src)
|
1058 |
+
return None
|
1059 |
+
|
1060 |
+
# extract, tracking .pyd/.dll->native_libs and .py -> to_compile
|
1061 |
+
unpack_archive(dist_filename, egg_tmp, process)
|
1062 |
+
stubs = []
|
1063 |
+
for res in native_libs:
|
1064 |
+
if res.lower().endswith('.pyd'): # create stubs for .pyd's
|
1065 |
+
parts = res.split('/')
|
1066 |
+
resource = parts[-1]
|
1067 |
+
parts[-1] = bdist_egg.strip_module(parts[-1]) + '.py'
|
1068 |
+
pyfile = os.path.join(egg_tmp, *parts)
|
1069 |
+
to_compile.append(pyfile)
|
1070 |
+
stubs.append(pyfile)
|
1071 |
+
bdist_egg.write_stub(resource, pyfile)
|
1072 |
+
self.byte_compile(to_compile) # compile .py's
|
1073 |
+
bdist_egg.write_safety_flag(
|
1074 |
+
os.path.join(egg_tmp, 'EGG-INFO'),
|
1075 |
+
bdist_egg.analyze_egg(egg_tmp, stubs)) # write zip-safety flag
|
1076 |
+
|
1077 |
+
for name in 'top_level', 'native_libs':
|
1078 |
+
if locals()[name]:
|
1079 |
+
txt = os.path.join(egg_tmp, 'EGG-INFO', name + '.txt')
|
1080 |
+
if not os.path.exists(txt):
|
1081 |
+
f = open(txt, 'w')
|
1082 |
+
f.write('\n'.join(locals()[name]) + '\n')
|
1083 |
+
f.close()
|
1084 |
+
|
1085 |
+
def install_wheel(self, wheel_path, tmpdir):
|
1086 |
+
wheel = Wheel(wheel_path)
|
1087 |
+
assert wheel.is_compatible()
|
1088 |
+
destination = os.path.join(self.install_dir, wheel.egg_name())
|
1089 |
+
destination = os.path.abspath(destination)
|
1090 |
+
if not self.dry_run:
|
1091 |
+
ensure_directory(destination)
|
1092 |
+
if os.path.isdir(destination) and not os.path.islink(destination):
|
1093 |
+
dir_util.remove_tree(destination, dry_run=self.dry_run)
|
1094 |
+
elif os.path.exists(destination):
|
1095 |
+
self.execute(
|
1096 |
+
os.unlink,
|
1097 |
+
(destination,),
|
1098 |
+
"Removing " + destination,
|
1099 |
+
)
|
1100 |
+
try:
|
1101 |
+
self.execute(
|
1102 |
+
wheel.install_as_egg,
|
1103 |
+
(destination,),
|
1104 |
+
("Installing %s to %s") % (
|
1105 |
+
os.path.basename(wheel_path),
|
1106 |
+
os.path.dirname(destination)
|
1107 |
+
),
|
1108 |
+
)
|
1109 |
+
finally:
|
1110 |
+
update_dist_caches(destination, fix_zipimporter_caches=False)
|
1111 |
+
self.add_output(destination)
|
1112 |
+
return self.egg_distribution(destination)
|
1113 |
+
|
1114 |
+
__mv_warning = textwrap.dedent("""
|
1115 |
+
Because this distribution was installed --multi-version, before you can
|
1116 |
+
import modules from this package in an application, you will need to
|
1117 |
+
'import pkg_resources' and then use a 'require()' call similar to one of
|
1118 |
+
these examples, in order to select the desired version:
|
1119 |
+
|
1120 |
+
pkg_resources.require("%(name)s") # latest installed version
|
1121 |
+
pkg_resources.require("%(name)s==%(version)s") # this exact version
|
1122 |
+
pkg_resources.require("%(name)s>=%(version)s") # this version or higher
|
1123 |
+
""").lstrip() # noqa
|
1124 |
+
|
1125 |
+
__id_warning = textwrap.dedent("""
|
1126 |
+
Note also that the installation directory must be on sys.path at runtime for
|
1127 |
+
this to work. (e.g. by being the application's script directory, by being on
|
1128 |
+
PYTHONPATH, or by being added to sys.path by your code.)
|
1129 |
+
""") # noqa
|
1130 |
+
|
1131 |
+
def installation_report(self, req, dist, what="Installed"):
|
1132 |
+
"""Helpful installation message for display to package users"""
|
1133 |
+
msg = "\n%(what)s %(eggloc)s%(extras)s"
|
1134 |
+
if self.multi_version and not self.no_report:
|
1135 |
+
msg += '\n' + self.__mv_warning
|
1136 |
+
if self.install_dir not in map(normalize_path, sys.path):
|
1137 |
+
msg += '\n' + self.__id_warning
|
1138 |
+
|
1139 |
+
eggloc = dist.location
|
1140 |
+
name = dist.project_name
|
1141 |
+
version = dist.version
|
1142 |
+
extras = '' # TODO: self.report_extras(req, dist)
|
1143 |
+
return msg % locals()
|
1144 |
+
|
1145 |
+
__editable_msg = textwrap.dedent("""
|
1146 |
+
Extracted editable version of %(spec)s to %(dirname)s
|
1147 |
+
|
1148 |
+
If it uses setuptools in its setup script, you can activate it in
|
1149 |
+
"development" mode by going to that directory and running::
|
1150 |
+
|
1151 |
+
%(python)s setup.py develop
|
1152 |
+
|
1153 |
+
See the setuptools documentation for the "develop" command for more info.
|
1154 |
+
""").lstrip() # noqa
|
1155 |
+
|
1156 |
+
def report_editable(self, spec, setup_script):
|
1157 |
+
dirname = os.path.dirname(setup_script)
|
1158 |
+
python = sys.executable
|
1159 |
+
return '\n' + self.__editable_msg % locals()
|
1160 |
+
|
1161 |
+
def run_setup(self, setup_script, setup_base, args):
|
1162 |
+
sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
|
1163 |
+
sys.modules.setdefault('distutils.command.egg_info', egg_info)
|
1164 |
+
|
1165 |
+
args = list(args)
|
1166 |
+
if self.verbose > 2:
|
1167 |
+
v = 'v' * (self.verbose - 1)
|
1168 |
+
args.insert(0, '-' + v)
|
1169 |
+
elif self.verbose < 2:
|
1170 |
+
args.insert(0, '-q')
|
1171 |
+
if self.dry_run:
|
1172 |
+
args.insert(0, '-n')
|
1173 |
+
log.info(
|
1174 |
+
"Running %s %s", setup_script[len(setup_base) + 1:], ' '.join(args)
|
1175 |
+
)
|
1176 |
+
try:
|
1177 |
+
run_setup(setup_script, args)
|
1178 |
+
except SystemExit as v:
|
1179 |
+
raise DistutilsError(
|
1180 |
+
"Setup script exited with %s" % (v.args[0],)
|
1181 |
+
) from v
|
1182 |
+
|
1183 |
+
def build_and_install(self, setup_script, setup_base):
|
1184 |
+
args = ['bdist_egg', '--dist-dir']
|
1185 |
+
|
1186 |
+
dist_dir = tempfile.mkdtemp(
|
1187 |
+
prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script)
|
1188 |
+
)
|
1189 |
+
try:
|
1190 |
+
self._set_fetcher_options(os.path.dirname(setup_script))
|
1191 |
+
args.append(dist_dir)
|
1192 |
+
|
1193 |
+
self.run_setup(setup_script, setup_base, args)
|
1194 |
+
all_eggs = Environment([dist_dir])
|
1195 |
+
eggs = []
|
1196 |
+
for key in all_eggs:
|
1197 |
+
for dist in all_eggs[key]:
|
1198 |
+
eggs.append(self.install_egg(dist.location, setup_base))
|
1199 |
+
if not eggs and not self.dry_run:
|
1200 |
+
log.warn("No eggs found in %s (setup script problem?)",
|
1201 |
+
dist_dir)
|
1202 |
+
return eggs
|
1203 |
+
finally:
|
1204 |
+
rmtree(dist_dir)
|
1205 |
+
log.set_verbosity(self.verbose) # restore our log verbosity
|
1206 |
+
|
1207 |
+
def _set_fetcher_options(self, base):
|
1208 |
+
"""
|
1209 |
+
When easy_install is about to run bdist_egg on a source dist, that
|
1210 |
+
source dist might have 'setup_requires' directives, requiring
|
1211 |
+
additional fetching. Ensure the fetcher options given to easy_install
|
1212 |
+
are available to that command as well.
|
1213 |
+
"""
|
1214 |
+
# find the fetch options from easy_install and write them out
|
1215 |
+
# to the setup.cfg file.
|
1216 |
+
ei_opts = self.distribution.get_option_dict('easy_install').copy()
|
1217 |
+
fetch_directives = (
|
1218 |
+
'find_links', 'site_dirs', 'index_url', 'optimize', 'allow_hosts',
|
1219 |
+
)
|
1220 |
+
fetch_options = {}
|
1221 |
+
for key, val in ei_opts.items():
|
1222 |
+
if key not in fetch_directives:
|
1223 |
+
continue
|
1224 |
+
fetch_options[key] = val[1]
|
1225 |
+
# create a settings dictionary suitable for `edit_config`
|
1226 |
+
settings = dict(easy_install=fetch_options)
|
1227 |
+
cfg_filename = os.path.join(base, 'setup.cfg')
|
1228 |
+
setopt.edit_config(cfg_filename, settings)
|
1229 |
+
|
1230 |
+
def update_pth(self, dist): # noqa: C901 # is too complex (11) # FIXME
|
1231 |
+
if self.pth_file is None:
|
1232 |
+
return
|
1233 |
+
|
1234 |
+
for d in self.pth_file[dist.key]: # drop old entries
|
1235 |
+
if not self.multi_version and d.location == dist.location:
|
1236 |
+
continue
|
1237 |
+
|
1238 |
+
log.info("Removing %s from easy-install.pth file", d)
|
1239 |
+
self.pth_file.remove(d)
|
1240 |
+
if d.location in self.shadow_path:
|
1241 |
+
self.shadow_path.remove(d.location)
|
1242 |
+
|
1243 |
+
if not self.multi_version:
|
1244 |
+
if dist.location in self.pth_file.paths:
|
1245 |
+
log.info(
|
1246 |
+
"%s is already the active version in easy-install.pth",
|
1247 |
+
dist,
|
1248 |
+
)
|
1249 |
+
else:
|
1250 |
+
log.info("Adding %s to easy-install.pth file", dist)
|
1251 |
+
self.pth_file.add(dist) # add new entry
|
1252 |
+
if dist.location not in self.shadow_path:
|
1253 |
+
self.shadow_path.append(dist.location)
|
1254 |
+
|
1255 |
+
if self.dry_run:
|
1256 |
+
return
|
1257 |
+
|
1258 |
+
self.pth_file.save()
|
1259 |
+
|
1260 |
+
if dist.key != 'setuptools':
|
1261 |
+
return
|
1262 |
+
|
1263 |
+
# Ensure that setuptools itself never becomes unavailable!
|
1264 |
+
# XXX should this check for latest version?
|
1265 |
+
filename = os.path.join(self.install_dir, 'setuptools.pth')
|
1266 |
+
if os.path.islink(filename):
|
1267 |
+
os.unlink(filename)
|
1268 |
+
with open(filename, 'wt') as f:
|
1269 |
+
f.write(self.pth_file.make_relative(dist.location) + '\n')
|
1270 |
+
|
1271 |
+
def unpack_progress(self, src, dst):
|
1272 |
+
# Progress filter for unpacking
|
1273 |
+
log.debug("Unpacking %s to %s", src, dst)
|
1274 |
+
return dst # only unpack-and-compile skips files for dry run
|
1275 |
+
|
1276 |
+
def unpack_and_compile(self, egg_path, destination):
|
1277 |
+
to_compile = []
|
1278 |
+
to_chmod = []
|
1279 |
+
|
1280 |
+
def pf(src, dst):
|
1281 |
+
if dst.endswith('.py') and not src.startswith('EGG-INFO/'):
|
1282 |
+
to_compile.append(dst)
|
1283 |
+
elif dst.endswith('.dll') or dst.endswith('.so'):
|
1284 |
+
to_chmod.append(dst)
|
1285 |
+
self.unpack_progress(src, dst)
|
1286 |
+
return not self.dry_run and dst or None
|
1287 |
+
|
1288 |
+
unpack_archive(egg_path, destination, pf)
|
1289 |
+
self.byte_compile(to_compile)
|
1290 |
+
if not self.dry_run:
|
1291 |
+
for f in to_chmod:
|
1292 |
+
mode = ((os.stat(f)[stat.ST_MODE]) | 0o555) & 0o7755
|
1293 |
+
chmod(f, mode)
|
1294 |
+
|
1295 |
+
def byte_compile(self, to_compile):
|
1296 |
+
if sys.dont_write_bytecode:
|
1297 |
+
return
|
1298 |
+
|
1299 |
+
from distutils.util import byte_compile
|
1300 |
+
|
1301 |
+
try:
|
1302 |
+
# try to make the byte compile messages quieter
|
1303 |
+
log.set_verbosity(self.verbose - 1)
|
1304 |
+
|
1305 |
+
byte_compile(to_compile, optimize=0, force=1, dry_run=self.dry_run)
|
1306 |
+
if self.optimize:
|
1307 |
+
byte_compile(
|
1308 |
+
to_compile, optimize=self.optimize, force=1,
|
1309 |
+
dry_run=self.dry_run,
|
1310 |
+
)
|
1311 |
+
finally:
|
1312 |
+
log.set_verbosity(self.verbose) # restore original verbosity
|
1313 |
+
|
1314 |
+
__no_default_msg = textwrap.dedent("""
|
1315 |
+
bad install directory or PYTHONPATH
|
1316 |
+
|
1317 |
+
You are attempting to install a package to a directory that is not
|
1318 |
+
on PYTHONPATH and which Python does not read ".pth" files from. The
|
1319 |
+
installation directory you specified (via --install-dir, --prefix, or
|
1320 |
+
the distutils default setting) was:
|
1321 |
+
|
1322 |
+
%s
|
1323 |
+
|
1324 |
+
and your PYTHONPATH environment variable currently contains:
|
1325 |
+
|
1326 |
+
%r
|
1327 |
+
|
1328 |
+
Here are some of your options for correcting the problem:
|
1329 |
+
|
1330 |
+
* You can choose a different installation directory, i.e., one that is
|
1331 |
+
on PYTHONPATH or supports .pth files
|
1332 |
+
|
1333 |
+
* You can add the installation directory to the PYTHONPATH environment
|
1334 |
+
variable. (It must then also be on PYTHONPATH whenever you run
|
1335 |
+
Python and want to use the package(s) you are installing.)
|
1336 |
+
|
1337 |
+
* You can set up the installation directory to support ".pth" files by
|
1338 |
+
using one of the approaches described here:
|
1339 |
+
|
1340 |
+
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations
|
1341 |
+
|
1342 |
+
|
1343 |
+
Please make the appropriate changes for your system and try again.
|
1344 |
+
""").strip()
|
1345 |
+
|
1346 |
+
def create_home_path(self):
|
1347 |
+
"""Create directories under ~."""
|
1348 |
+
if not self.user:
|
1349 |
+
return
|
1350 |
+
home = convert_path(os.path.expanduser("~"))
|
1351 |
+
for name, path in self.config_vars.items():
|
1352 |
+
if path.startswith(home) and not os.path.isdir(path):
|
1353 |
+
self.debug_print("os.makedirs('%s', 0o700)" % path)
|
1354 |
+
os.makedirs(path, 0o700)
|
1355 |
+
|
1356 |
+
if sys.version[:3] in ('2.3', '2.4', '2.5') or 'real_prefix' in sys.__dict__:
|
1357 |
+
sitedir_name = 'site-packages'
|
1358 |
+
else:
|
1359 |
+
sitedir_name = 'dist-packages'
|
1360 |
+
|
1361 |
+
INSTALL_SCHEMES = dict(
|
1362 |
+
posix=dict(
|
1363 |
+
install_dir='$base/lib/python$py_version_short/site-packages',
|
1364 |
+
script_dir='$base/bin',
|
1365 |
+
),
|
1366 |
+
unix_local = dict(
|
1367 |
+
install_dir = '$base/local/lib/python$py_version_short/%s' % sitedir_name,
|
1368 |
+
script_dir = '$base/local/bin',
|
1369 |
+
),
|
1370 |
+
posix_local = dict(
|
1371 |
+
install_dir = '$base/local/lib/python$py_version_short/%s' % sitedir_name,
|
1372 |
+
script_dir = '$base/local/bin',
|
1373 |
+
),
|
1374 |
+
deb_system = dict(
|
1375 |
+
install_dir = '$base/lib/python3/%s' % sitedir_name,
|
1376 |
+
script_dir = '$base/bin',
|
1377 |
+
),
|
1378 |
+
)
|
1379 |
+
|
1380 |
+
DEFAULT_SCHEME = dict(
|
1381 |
+
install_dir='$base/Lib/site-packages',
|
1382 |
+
script_dir='$base/Scripts',
|
1383 |
+
)
|
1384 |
+
|
1385 |
+
def _expand(self, *attrs):
|
1386 |
+
config_vars = self.get_finalized_command('install').config_vars
|
1387 |
+
|
1388 |
+
if self.prefix or self.install_layout:
|
1389 |
+
if self.install_layout and self.install_layout in ['deb']:
|
1390 |
+
scheme_name = "deb_system"
|
1391 |
+
self.prefix = '/usr'
|
1392 |
+
elif self.prefix or 'real_prefix' in sys.__dict__:
|
1393 |
+
scheme_name = os.name
|
1394 |
+
else:
|
1395 |
+
scheme_name = "posix_local"
|
1396 |
+
# Set default install_dir/scripts from --prefix
|
1397 |
+
config_vars = config_vars.copy()
|
1398 |
+
config_vars['base'] = self.prefix
|
1399 |
+
scheme = self.INSTALL_SCHEMES.get(scheme_name,self.DEFAULT_SCHEME)
|
1400 |
+
for attr, val in scheme.items():
|
1401 |
+
if getattr(self, attr, None) is None:
|
1402 |
+
setattr(self, attr, val)
|
1403 |
+
|
1404 |
+
from distutils.util import subst_vars
|
1405 |
+
|
1406 |
+
for attr in attrs:
|
1407 |
+
val = getattr(self, attr)
|
1408 |
+
if val is not None:
|
1409 |
+
val = subst_vars(val, config_vars)
|
1410 |
+
if os.name == 'posix':
|
1411 |
+
val = os.path.expanduser(val)
|
1412 |
+
setattr(self, attr, val)
|
1413 |
+
|
1414 |
+
|
1415 |
+
def _pythonpath():
|
1416 |
+
items = os.environ.get('PYTHONPATH', '').split(os.pathsep)
|
1417 |
+
return filter(None, items)
|
1418 |
+
|
1419 |
+
|
1420 |
+
def get_site_dirs():
|
1421 |
+
"""
|
1422 |
+
Return a list of 'site' dirs
|
1423 |
+
"""
|
1424 |
+
|
1425 |
+
sitedirs = []
|
1426 |
+
|
1427 |
+
# start with PYTHONPATH
|
1428 |
+
sitedirs.extend(_pythonpath())
|
1429 |
+
|
1430 |
+
prefixes = [sys.prefix]
|
1431 |
+
if sys.exec_prefix != sys.prefix:
|
1432 |
+
prefixes.append(sys.exec_prefix)
|
1433 |
+
for prefix in prefixes:
|
1434 |
+
if not prefix:
|
1435 |
+
continue
|
1436 |
+
|
1437 |
+
if sys.platform in ('os2emx', 'riscos'):
|
1438 |
+
sitedirs.append(os.path.join(prefix, "Lib", "site-packages"))
|
1439 |
+
elif os.sep == '/':
|
1440 |
+
sitedirs.extend([
|
1441 |
+
os.path.join(
|
1442 |
+
prefix,
|
1443 |
+
"local/lib",
|
1444 |
+
"python" + sys.version[:3],
|
1445 |
+
"dist-packages",
|
1446 |
+
),
|
1447 |
+
os.path.join(
|
1448 |
+
prefix,
|
1449 |
+
"lib",
|
1450 |
+
"python{}.{}".format(*sys.version_info),
|
1451 |
+
"dist-packages",
|
1452 |
+
),
|
1453 |
+
os.path.join(prefix, "lib", "site-python"),
|
1454 |
+
])
|
1455 |
+
else:
|
1456 |
+
sitedirs.extend([
|
1457 |
+
prefix,
|
1458 |
+
os.path.join(prefix, "lib", "site-packages"),
|
1459 |
+
])
|
1460 |
+
if sys.platform != 'darwin':
|
1461 |
+
continue
|
1462 |
+
|
1463 |
+
# for framework builds *only* we add the standard Apple
|
1464 |
+
# locations. Currently only per-user, but /Library and
|
1465 |
+
# /Network/Library could be added too
|
1466 |
+
if 'Python.framework' not in prefix:
|
1467 |
+
continue
|
1468 |
+
|
1469 |
+
home = os.environ.get('HOME')
|
1470 |
+
if not home:
|
1471 |
+
continue
|
1472 |
+
|
1473 |
+
home_sp = os.path.join(
|
1474 |
+
home,
|
1475 |
+
'Library',
|
1476 |
+
'Python',
|
1477 |
+
'{}.{}'.format(*sys.version_info),
|
1478 |
+
'site-packages',
|
1479 |
+
)
|
1480 |
+
sitedirs.append(home_sp)
|
1481 |
+
lib_paths = get_path('purelib'), get_path('platlib')
|
1482 |
+
|
1483 |
+
sitedirs.extend(s for s in lib_paths if s not in sitedirs)
|
1484 |
+
|
1485 |
+
if site.ENABLE_USER_SITE:
|
1486 |
+
sitedirs.append(site.USER_SITE)
|
1487 |
+
|
1488 |
+
with contextlib.suppress(AttributeError):
|
1489 |
+
sitedirs.extend(site.getsitepackages())
|
1490 |
+
|
1491 |
+
sitedirs = list(map(normalize_path, sitedirs))
|
1492 |
+
|
1493 |
+
return sitedirs
|
1494 |
+
|
1495 |
+
|
1496 |
+
def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME
|
1497 |
+
"""Yield sys.path directories that might contain "old-style" packages"""
|
1498 |
+
|
1499 |
+
seen = {}
|
1500 |
+
|
1501 |
+
for dirname in inputs:
|
1502 |
+
dirname = normalize_path(dirname)
|
1503 |
+
if dirname in seen:
|
1504 |
+
continue
|
1505 |
+
|
1506 |
+
seen[dirname] = 1
|
1507 |
+
if not os.path.isdir(dirname):
|
1508 |
+
continue
|
1509 |
+
|
1510 |
+
files = os.listdir(dirname)
|
1511 |
+
yield dirname, files
|
1512 |
+
|
1513 |
+
for name in files:
|
1514 |
+
if not name.endswith('.pth'):
|
1515 |
+
# We only care about the .pth files
|
1516 |
+
continue
|
1517 |
+
if name in ('easy-install.pth', 'setuptools.pth'):
|
1518 |
+
# Ignore .pth files that we control
|
1519 |
+
continue
|
1520 |
+
|
1521 |
+
# Read the .pth file
|
1522 |
+
f = open(os.path.join(dirname, name))
|
1523 |
+
lines = list(yield_lines(f))
|
1524 |
+
f.close()
|
1525 |
+
|
1526 |
+
# Yield existing non-dupe, non-import directory lines from it
|
1527 |
+
for line in lines:
|
1528 |
+
if line.startswith("import"):
|
1529 |
+
continue
|
1530 |
+
|
1531 |
+
line = normalize_path(line.rstrip())
|
1532 |
+
if line in seen:
|
1533 |
+
continue
|
1534 |
+
|
1535 |
+
seen[line] = 1
|
1536 |
+
if not os.path.isdir(line):
|
1537 |
+
continue
|
1538 |
+
|
1539 |
+
yield line, os.listdir(line)
|
1540 |
+
|
1541 |
+
|
1542 |
+
def extract_wininst_cfg(dist_filename):
|
1543 |
+
"""Extract configuration data from a bdist_wininst .exe
|
1544 |
+
|
1545 |
+
Returns a configparser.RawConfigParser, or None
|
1546 |
+
"""
|
1547 |
+
f = open(dist_filename, 'rb')
|
1548 |
+
try:
|
1549 |
+
endrec = zipfile._EndRecData(f)
|
1550 |
+
if endrec is None:
|
1551 |
+
return None
|
1552 |
+
|
1553 |
+
prepended = (endrec[9] - endrec[5]) - endrec[6]
|
1554 |
+
if prepended < 12: # no wininst data here
|
1555 |
+
return None
|
1556 |
+
f.seek(prepended - 12)
|
1557 |
+
|
1558 |
+
tag, cfglen, bmlen = struct.unpack("<iii", f.read(12))
|
1559 |
+
if tag not in (0x1234567A, 0x1234567B):
|
1560 |
+
return None # not a valid tag
|
1561 |
+
|
1562 |
+
f.seek(prepended - (12 + cfglen))
|
1563 |
+
init = {'version': '', 'target_version': ''}
|
1564 |
+
cfg = configparser.RawConfigParser(init)
|
1565 |
+
try:
|
1566 |
+
part = f.read(cfglen)
|
1567 |
+
# Read up to the first null byte.
|
1568 |
+
config = part.split(b'\0', 1)[0]
|
1569 |
+
# Now the config is in bytes, but for RawConfigParser, it should
|
1570 |
+
# be text, so decode it.
|
1571 |
+
config = config.decode(sys.getfilesystemencoding())
|
1572 |
+
cfg.read_file(io.StringIO(config))
|
1573 |
+
except configparser.Error:
|
1574 |
+
return None
|
1575 |
+
if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
|
1576 |
+
return None
|
1577 |
+
return cfg
|
1578 |
+
|
1579 |
+
finally:
|
1580 |
+
f.close()
|
1581 |
+
|
1582 |
+
|
1583 |
+
def get_exe_prefixes(exe_filename):
|
1584 |
+
"""Get exe->egg path translations for a given .exe file"""
|
1585 |
+
|
1586 |
+
prefixes = [
|
1587 |
+
('PURELIB/', ''),
|
1588 |
+
('PLATLIB/pywin32_system32', ''),
|
1589 |
+
('PLATLIB/', ''),
|
1590 |
+
('SCRIPTS/', 'EGG-INFO/scripts/'),
|
1591 |
+
('DATA/lib/site-packages', ''),
|
1592 |
+
]
|
1593 |
+
z = zipfile.ZipFile(exe_filename)
|
1594 |
+
try:
|
1595 |
+
for info in z.infolist():
|
1596 |
+
name = info.filename
|
1597 |
+
parts = name.split('/')
|
1598 |
+
if len(parts) == 3 and parts[2] == 'PKG-INFO':
|
1599 |
+
if parts[1].endswith('.egg-info'):
|
1600 |
+
prefixes.insert(0, ('/'.join(parts[:2]), 'EGG-INFO/'))
|
1601 |
+
break
|
1602 |
+
if len(parts) != 2 or not name.endswith('.pth'):
|
1603 |
+
continue
|
1604 |
+
if name.endswith('-nspkg.pth'):
|
1605 |
+
continue
|
1606 |
+
if parts[0].upper() in ('PURELIB', 'PLATLIB'):
|
1607 |
+
contents = z.read(name).decode()
|
1608 |
+
for pth in yield_lines(contents):
|
1609 |
+
pth = pth.strip().replace('\\', '/')
|
1610 |
+
if not pth.startswith('import'):
|
1611 |
+
prefixes.append((('%s/%s/' % (parts[0], pth)), ''))
|
1612 |
+
finally:
|
1613 |
+
z.close()
|
1614 |
+
prefixes = [(x.lower(), y) for x, y in prefixes]
|
1615 |
+
prefixes.sort()
|
1616 |
+
prefixes.reverse()
|
1617 |
+
return prefixes
|
1618 |
+
|
1619 |
+
|
1620 |
+
class PthDistributions(Environment):
|
1621 |
+
"""A .pth file with Distribution paths in it"""
|
1622 |
+
|
1623 |
+
dirty = False
|
1624 |
+
|
1625 |
+
def __init__(self, filename, sitedirs=()):
|
1626 |
+
self.filename = filename
|
1627 |
+
self.sitedirs = list(map(normalize_path, sitedirs))
|
1628 |
+
self.basedir = normalize_path(os.path.dirname(self.filename))
|
1629 |
+
self._load()
|
1630 |
+
Environment.__init__(self, [], None, None)
|
1631 |
+
for path in yield_lines(self.paths):
|
1632 |
+
list(map(self.add, find_distributions(path, True)))
|
1633 |
+
|
1634 |
+
def _load(self):
|
1635 |
+
self.paths = []
|
1636 |
+
saw_import = False
|
1637 |
+
seen = dict.fromkeys(self.sitedirs)
|
1638 |
+
if os.path.isfile(self.filename):
|
1639 |
+
f = open(self.filename, 'rt')
|
1640 |
+
for line in f:
|
1641 |
+
if line.startswith('import'):
|
1642 |
+
saw_import = True
|
1643 |
+
continue
|
1644 |
+
path = line.rstrip()
|
1645 |
+
self.paths.append(path)
|
1646 |
+
if not path.strip() or path.strip().startswith('#'):
|
1647 |
+
continue
|
1648 |
+
# skip non-existent paths, in case somebody deleted a package
|
1649 |
+
# manually, and duplicate paths as well
|
1650 |
+
path = self.paths[-1] = normalize_path(
|
1651 |
+
os.path.join(self.basedir, path)
|
1652 |
+
)
|
1653 |
+
if not os.path.exists(path) or path in seen:
|
1654 |
+
self.paths.pop() # skip it
|
1655 |
+
self.dirty = True # we cleaned up, so we're dirty now :)
|
1656 |
+
continue
|
1657 |
+
seen[path] = 1
|
1658 |
+
f.close()
|
1659 |
+
|
1660 |
+
if self.paths and not saw_import:
|
1661 |
+
self.dirty = True # ensure anything we touch has import wrappers
|
1662 |
+
while self.paths and not self.paths[-1].strip():
|
1663 |
+
self.paths.pop()
|
1664 |
+
|
1665 |
+
def save(self):
|
1666 |
+
"""Write changed .pth file back to disk"""
|
1667 |
+
if not self.dirty:
|
1668 |
+
return
|
1669 |
+
|
1670 |
+
rel_paths = list(map(self.make_relative, self.paths))
|
1671 |
+
if rel_paths:
|
1672 |
+
log.debug("Saving %s", self.filename)
|
1673 |
+
lines = self._wrap_lines(rel_paths)
|
1674 |
+
data = '\n'.join(lines) + '\n'
|
1675 |
+
|
1676 |
+
if os.path.islink(self.filename):
|
1677 |
+
os.unlink(self.filename)
|
1678 |
+
with open(self.filename, 'wt') as f:
|
1679 |
+
f.write(data)
|
1680 |
+
|
1681 |
+
elif os.path.exists(self.filename):
|
1682 |
+
log.debug("Deleting empty %s", self.filename)
|
1683 |
+
os.unlink(self.filename)
|
1684 |
+
|
1685 |
+
self.dirty = False
|
1686 |
+
|
1687 |
+
@staticmethod
|
1688 |
+
def _wrap_lines(lines):
|
1689 |
+
return lines
|
1690 |
+
|
1691 |
+
def add(self, dist):
|
1692 |
+
"""Add `dist` to the distribution map"""
|
1693 |
+
new_path = (
|
1694 |
+
dist.location not in self.paths and (
|
1695 |
+
dist.location not in self.sitedirs or
|
1696 |
+
# account for '.' being in PYTHONPATH
|
1697 |
+
dist.location == os.getcwd()
|
1698 |
+
)
|
1699 |
+
)
|
1700 |
+
if new_path:
|
1701 |
+
self.paths.append(dist.location)
|
1702 |
+
self.dirty = True
|
1703 |
+
Environment.add(self, dist)
|
1704 |
+
|
1705 |
+
def remove(self, dist):
|
1706 |
+
"""Remove `dist` from the distribution map"""
|
1707 |
+
while dist.location in self.paths:
|
1708 |
+
self.paths.remove(dist.location)
|
1709 |
+
self.dirty = True
|
1710 |
+
Environment.remove(self, dist)
|
1711 |
+
|
1712 |
+
def make_relative(self, path):
|
1713 |
+
npath, last = os.path.split(normalize_path(path))
|
1714 |
+
baselen = len(self.basedir)
|
1715 |
+
parts = [last]
|
1716 |
+
sep = os.altsep == '/' and '/' or os.sep
|
1717 |
+
while len(npath) >= baselen:
|
1718 |
+
if npath == self.basedir:
|
1719 |
+
parts.append(os.curdir)
|
1720 |
+
parts.reverse()
|
1721 |
+
return sep.join(parts)
|
1722 |
+
npath, last = os.path.split(npath)
|
1723 |
+
parts.append(last)
|
1724 |
+
else:
|
1725 |
+
return path
|
1726 |
+
|
1727 |
+
|
1728 |
+
class RewritePthDistributions(PthDistributions):
|
1729 |
+
@classmethod
|
1730 |
+
def _wrap_lines(cls, lines):
|
1731 |
+
yield cls.prelude
|
1732 |
+
for line in lines:
|
1733 |
+
yield line
|
1734 |
+
yield cls.postlude
|
1735 |
+
|
1736 |
+
prelude = _one_liner("""
|
1737 |
+
import sys
|
1738 |
+
sys.__plen = len(sys.path)
|
1739 |
+
""")
|
1740 |
+
postlude = _one_liner("""
|
1741 |
+
import sys
|
1742 |
+
new = sys.path[sys.__plen:]
|
1743 |
+
del sys.path[sys.__plen:]
|
1744 |
+
p = getattr(sys, '__egginsert', 0)
|
1745 |
+
sys.path[p:p] = new
|
1746 |
+
sys.__egginsert = p + len(new)
|
1747 |
+
""")
|
1748 |
+
|
1749 |
+
|
1750 |
+
if os.environ.get('SETUPTOOLS_SYS_PATH_TECHNIQUE', 'raw') == 'rewrite':
|
1751 |
+
PthDistributions = RewritePthDistributions
|
1752 |
+
|
1753 |
+
|
1754 |
+
def _first_line_re():
|
1755 |
+
"""
|
1756 |
+
Return a regular expression based on first_line_re suitable for matching
|
1757 |
+
strings.
|
1758 |
+
"""
|
1759 |
+
if isinstance(first_line_re.pattern, str):
|
1760 |
+
return first_line_re
|
1761 |
+
|
1762 |
+
# first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.
|
1763 |
+
return re.compile(first_line_re.pattern.decode())
|
1764 |
+
|
1765 |
+
|
1766 |
+
def auto_chmod(func, arg, exc):
|
1767 |
+
if func in [os.unlink, os.remove] and os.name == 'nt':
|
1768 |
+
chmod(arg, stat.S_IWRITE)
|
1769 |
+
return func(arg)
|
1770 |
+
et, ev, _ = sys.exc_info()
|
1771 |
+
# TODO: This code doesn't make sense. What is it trying to do?
|
1772 |
+
raise (ev[0], ev[1] + (" %s %s" % (func, arg)))
|
1773 |
+
|
1774 |
+
|
1775 |
+
def update_dist_caches(dist_path, fix_zipimporter_caches):
|
1776 |
+
"""
|
1777 |
+
Fix any globally cached `dist_path` related data
|
1778 |
+
|
1779 |
+
`dist_path` should be a path of a newly installed egg distribution (zipped
|
1780 |
+
or unzipped).
|
1781 |
+
|
1782 |
+
sys.path_importer_cache contains finder objects that have been cached when
|
1783 |
+
importing data from the original distribution. Any such finders need to be
|
1784 |
+
cleared since the replacement distribution might be packaged differently,
|
1785 |
+
e.g. a zipped egg distribution might get replaced with an unzipped egg
|
1786 |
+
folder or vice versa. Having the old finders cached may then cause Python
|
1787 |
+
to attempt loading modules from the replacement distribution using an
|
1788 |
+
incorrect loader.
|
1789 |
+
|
1790 |
+
zipimport.zipimporter objects are Python loaders charged with importing
|
1791 |
+
data packaged inside zip archives. If stale loaders referencing the
|
1792 |
+
original distribution, are left behind, they can fail to load modules from
|
1793 |
+
the replacement distribution. E.g. if an old zipimport.zipimporter instance
|
1794 |
+
is used to load data from a new zipped egg archive, it may cause the
|
1795 |
+
operation to attempt to locate the requested data in the wrong location -
|
1796 |
+
one indicated by the original distribution's zip archive directory
|
1797 |
+
information. Such an operation may then fail outright, e.g. report having
|
1798 |
+
read a 'bad local file header', or even worse, it may fail silently &
|
1799 |
+
return invalid data.
|
1800 |
+
|
1801 |
+
zipimport._zip_directory_cache contains cached zip archive directory
|
1802 |
+
information for all existing zipimport.zipimporter instances and all such
|
1803 |
+
instances connected to the same archive share the same cached directory
|
1804 |
+
information.
|
1805 |
+
|
1806 |
+
If asked, and the underlying Python implementation allows it, we can fix
|
1807 |
+
all existing zipimport.zipimporter instances instead of having to track
|
1808 |
+
them down and remove them one by one, by updating their shared cached zip
|
1809 |
+
archive directory information. This, of course, assumes that the
|
1810 |
+
replacement distribution is packaged as a zipped egg.
|
1811 |
+
|
1812 |
+
If not asked to fix existing zipimport.zipimporter instances, we still do
|
1813 |
+
our best to clear any remaining zipimport.zipimporter related cached data
|
1814 |
+
that might somehow later get used when attempting to load data from the new
|
1815 |
+
distribution and thus cause such load operations to fail. Note that when
|
1816 |
+
tracking down such remaining stale data, we can not catch every conceivable
|
1817 |
+
usage from here, and we clear only those that we know of and have found to
|
1818 |
+
cause problems if left alive. Any remaining caches should be updated by
|
1819 |
+
whomever is in charge of maintaining them, i.e. they should be ready to
|
1820 |
+
handle us replacing their zip archives with new distributions at runtime.
|
1821 |
+
|
1822 |
+
"""
|
1823 |
+
# There are several other known sources of stale zipimport.zipimporter
|
1824 |
+
# instances that we do not clear here, but might if ever given a reason to
|
1825 |
+
# do so:
|
1826 |
+
# * Global setuptools pkg_resources.working_set (a.k.a. 'master working
|
1827 |
+
# set') may contain distributions which may in turn contain their
|
1828 |
+
# zipimport.zipimporter loaders.
|
1829 |
+
# * Several zipimport.zipimporter loaders held by local variables further
|
1830 |
+
# up the function call stack when running the setuptools installation.
|
1831 |
+
# * Already loaded modules may have their __loader__ attribute set to the
|
1832 |
+
# exact loader instance used when importing them. Python 3.4 docs state
|
1833 |
+
# that this information is intended mostly for introspection and so is
|
1834 |
+
# not expected to cause us problems.
|
1835 |
+
normalized_path = normalize_path(dist_path)
|
1836 |
+
_uncache(normalized_path, sys.path_importer_cache)
|
1837 |
+
if fix_zipimporter_caches:
|
1838 |
+
_replace_zip_directory_cache_data(normalized_path)
|
1839 |
+
else:
|
1840 |
+
# Here, even though we do not want to fix existing and now stale
|
1841 |
+
# zipimporter cache information, we still want to remove it. Related to
|
1842 |
+
# Python's zip archive directory information cache, we clear each of
|
1843 |
+
# its stale entries in two phases:
|
1844 |
+
# 1. Clear the entry so attempting to access zip archive information
|
1845 |
+
# via any existing stale zipimport.zipimporter instances fails.
|
1846 |
+
# 2. Remove the entry from the cache so any newly constructed
|
1847 |
+
# zipimport.zipimporter instances do not end up using old stale
|
1848 |
+
# zip archive directory information.
|
1849 |
+
# This whole stale data removal step does not seem strictly necessary,
|
1850 |
+
# but has been left in because it was done before we started replacing
|
1851 |
+
# the zip archive directory information cache content if possible, and
|
1852 |
+
# there are no relevant unit tests that we can depend on to tell us if
|
1853 |
+
# this is really needed.
|
1854 |
+
_remove_and_clear_zip_directory_cache_data(normalized_path)
|
1855 |
+
|
1856 |
+
|
1857 |
+
def _collect_zipimporter_cache_entries(normalized_path, cache):
|
1858 |
+
"""
|
1859 |
+
Return zipimporter cache entry keys related to a given normalized path.
|
1860 |
+
|
1861 |
+
Alternative path spellings (e.g. those using different character case or
|
1862 |
+
those using alternative path separators) related to the same path are
|
1863 |
+
included. Any sub-path entries are included as well, i.e. those
|
1864 |
+
corresponding to zip archives embedded in other zip archives.
|
1865 |
+
|
1866 |
+
"""
|
1867 |
+
result = []
|
1868 |
+
prefix_len = len(normalized_path)
|
1869 |
+
for p in cache:
|
1870 |
+
np = normalize_path(p)
|
1871 |
+
if (np.startswith(normalized_path) and
|
1872 |
+
np[prefix_len:prefix_len + 1] in (os.sep, '')):
|
1873 |
+
result.append(p)
|
1874 |
+
return result
|
1875 |
+
|
1876 |
+
|
1877 |
+
def _update_zipimporter_cache(normalized_path, cache, updater=None):
|
1878 |
+
"""
|
1879 |
+
Update zipimporter cache data for a given normalized path.
|
1880 |
+
|
1881 |
+
Any sub-path entries are processed as well, i.e. those corresponding to zip
|
1882 |
+
archives embedded in other zip archives.
|
1883 |
+
|
1884 |
+
Given updater is a callable taking a cache entry key and the original entry
|
1885 |
+
(after already removing the entry from the cache), and expected to update
|
1886 |
+
the entry and possibly return a new one to be inserted in its place.
|
1887 |
+
Returning None indicates that the entry should not be replaced with a new
|
1888 |
+
one. If no updater is given, the cache entries are simply removed without
|
1889 |
+
any additional processing, the same as if the updater simply returned None.
|
1890 |
+
|
1891 |
+
"""
|
1892 |
+
for p in _collect_zipimporter_cache_entries(normalized_path, cache):
|
1893 |
+
# N.B. pypy's custom zipimport._zip_directory_cache implementation does
|
1894 |
+
# not support the complete dict interface:
|
1895 |
+
# * Does not support item assignment, thus not allowing this function
|
1896 |
+
# to be used only for removing existing cache entries.
|
1897 |
+
# * Does not support the dict.pop() method, forcing us to use the
|
1898 |
+
# get/del patterns instead. For more detailed information see the
|
1899 |
+
# following links:
|
1900 |
+
# https://github.com/pypa/setuptools/issues/202#issuecomment-202913420
|
1901 |
+
# http://bit.ly/2h9itJX
|
1902 |
+
old_entry = cache[p]
|
1903 |
+
del cache[p]
|
1904 |
+
new_entry = updater and updater(p, old_entry)
|
1905 |
+
if new_entry is not None:
|
1906 |
+
cache[p] = new_entry
|
1907 |
+
|
1908 |
+
|
1909 |
+
def _uncache(normalized_path, cache):
|
1910 |
+
_update_zipimporter_cache(normalized_path, cache)
|
1911 |
+
|
1912 |
+
|
1913 |
+
def _remove_and_clear_zip_directory_cache_data(normalized_path):
|
1914 |
+
def clear_and_remove_cached_zip_archive_directory_data(path, old_entry):
|
1915 |
+
old_entry.clear()
|
1916 |
+
|
1917 |
+
_update_zipimporter_cache(
|
1918 |
+
normalized_path, zipimport._zip_directory_cache,
|
1919 |
+
updater=clear_and_remove_cached_zip_archive_directory_data)
|
1920 |
+
|
1921 |
+
|
1922 |
+
# PyPy Python implementation does not allow directly writing to the
|
1923 |
+
# zipimport._zip_directory_cache and so prevents us from attempting to correct
|
1924 |
+
# its content. The best we can do there is clear the problematic cache content
|
1925 |
+
# and have PyPy repopulate it as needed. The downside is that if there are any
|
1926 |
+
# stale zipimport.zipimporter instances laying around, attempting to use them
|
1927 |
+
# will fail due to not having its zip archive directory information available
|
1928 |
+
# instead of being automatically corrected to use the new correct zip archive
|
1929 |
+
# directory information.
|
1930 |
+
if '__pypy__' in sys.builtin_module_names:
|
1931 |
+
_replace_zip_directory_cache_data = \
|
1932 |
+
_remove_and_clear_zip_directory_cache_data
|
1933 |
+
else:
|
1934 |
+
|
1935 |
+
def _replace_zip_directory_cache_data(normalized_path):
|
1936 |
+
def replace_cached_zip_archive_directory_data(path, old_entry):
|
1937 |
+
# N.B. In theory, we could load the zip directory information just
|
1938 |
+
# once for all updated path spellings, and then copy it locally and
|
1939 |
+
# update its contained path strings to contain the correct
|
1940 |
+
# spelling, but that seems like a way too invasive move (this cache
|
1941 |
+
# structure is not officially documented anywhere and could in
|
1942 |
+
# theory change with new Python releases) for no significant
|
1943 |
+
# benefit.
|
1944 |
+
old_entry.clear()
|
1945 |
+
zipimport.zipimporter(path)
|
1946 |
+
old_entry.update(zipimport._zip_directory_cache[path])
|
1947 |
+
return old_entry
|
1948 |
+
|
1949 |
+
_update_zipimporter_cache(
|
1950 |
+
normalized_path, zipimport._zip_directory_cache,
|
1951 |
+
updater=replace_cached_zip_archive_directory_data)
|
1952 |
+
|
1953 |
+
|
1954 |
+
def is_python(text, filename='<string>'):
|
1955 |
+
"Is this string a valid Python script?"
|
1956 |
+
try:
|
1957 |
+
compile(text, filename, 'exec')
|
1958 |
+
except (SyntaxError, TypeError):
|
1959 |
+
return False
|
1960 |
+
else:
|
1961 |
+
return True
|
1962 |
+
|
1963 |
+
|
1964 |
+
def is_sh(executable):
|
1965 |
+
"""Determine if the specified executable is a .sh (contains a #! line)"""
|
1966 |
+
try:
|
1967 |
+
with io.open(executable, encoding='latin-1') as fp:
|
1968 |
+
magic = fp.read(2)
|
1969 |
+
except (OSError, IOError):
|
1970 |
+
return executable
|
1971 |
+
return magic == '#!'
|
1972 |
+
|
1973 |
+
|
1974 |
+
def nt_quote_arg(arg):
|
1975 |
+
"""Quote a command line argument according to Windows parsing rules"""
|
1976 |
+
return subprocess.list2cmdline([arg])
|
1977 |
+
|
1978 |
+
|
1979 |
+
def is_python_script(script_text, filename):
|
1980 |
+
"""Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
|
1981 |
+
"""
|
1982 |
+
if filename.endswith('.py') or filename.endswith('.pyw'):
|
1983 |
+
return True # extension says it's Python
|
1984 |
+
if is_python(script_text, filename):
|
1985 |
+
return True # it's syntactically valid Python
|
1986 |
+
if script_text.startswith('#!'):
|
1987 |
+
# It begins with a '#!' line, so check if 'python' is in it somewhere
|
1988 |
+
return 'python' in script_text.splitlines()[0].lower()
|
1989 |
+
|
1990 |
+
return False # Not any Python I can recognize
|
1991 |
+
|
1992 |
+
|
1993 |
+
try:
|
1994 |
+
from os import chmod as _chmod
|
1995 |
+
except ImportError:
|
1996 |
+
# Jython compatibility
|
1997 |
+
def _chmod(*args):
|
1998 |
+
pass
|
1999 |
+
|
2000 |
+
|
2001 |
+
def chmod(path, mode):
|
2002 |
+
log.debug("changing mode of %s to %o", path, mode)
|
2003 |
+
try:
|
2004 |
+
_chmod(path, mode)
|
2005 |
+
except os.error as e:
|
2006 |
+
log.debug("chmod failed: %s", e)
|
2007 |
+
|
2008 |
+
|
2009 |
+
class CommandSpec(list):
|
2010 |
+
"""
|
2011 |
+
A command spec for a #! header, specified as a list of arguments akin to
|
2012 |
+
those passed to Popen.
|
2013 |
+
"""
|
2014 |
+
|
2015 |
+
options = []
|
2016 |
+
split_args = dict()
|
2017 |
+
|
2018 |
+
@classmethod
|
2019 |
+
def best(cls):
|
2020 |
+
"""
|
2021 |
+
Choose the best CommandSpec class based on environmental conditions.
|
2022 |
+
"""
|
2023 |
+
return cls
|
2024 |
+
|
2025 |
+
@classmethod
|
2026 |
+
def _sys_executable(cls):
|
2027 |
+
_default = os.path.normpath(sys.executable)
|
2028 |
+
return os.environ.get('__PYVENV_LAUNCHER__', _default)
|
2029 |
+
|
2030 |
+
@classmethod
|
2031 |
+
def from_param(cls, param):
|
2032 |
+
"""
|
2033 |
+
Construct a CommandSpec from a parameter to build_scripts, which may
|
2034 |
+
be None.
|
2035 |
+
"""
|
2036 |
+
if isinstance(param, cls):
|
2037 |
+
return param
|
2038 |
+
if isinstance(param, list):
|
2039 |
+
return cls(param)
|
2040 |
+
if param is None:
|
2041 |
+
return cls.from_environment()
|
2042 |
+
# otherwise, assume it's a string.
|
2043 |
+
return cls.from_string(param)
|
2044 |
+
|
2045 |
+
@classmethod
|
2046 |
+
def from_environment(cls):
|
2047 |
+
return cls([cls._sys_executable()])
|
2048 |
+
|
2049 |
+
@classmethod
|
2050 |
+
def from_string(cls, string):
|
2051 |
+
"""
|
2052 |
+
Construct a command spec from a simple string representing a command
|
2053 |
+
line parseable by shlex.split.
|
2054 |
+
"""
|
2055 |
+
items = shlex.split(string, **cls.split_args)
|
2056 |
+
return cls(items)
|
2057 |
+
|
2058 |
+
def install_options(self, script_text):
|
2059 |
+
self.options = shlex.split(self._extract_options(script_text))
|
2060 |
+
cmdline = subprocess.list2cmdline(self)
|
2061 |
+
if not isascii(cmdline):
|
2062 |
+
self.options[:0] = ['-x']
|
2063 |
+
|
2064 |
+
@staticmethod
|
2065 |
+
def _extract_options(orig_script):
|
2066 |
+
"""
|
2067 |
+
Extract any options from the first line of the script.
|
2068 |
+
"""
|
2069 |
+
first = (orig_script + '\n').splitlines()[0]
|
2070 |
+
match = _first_line_re().match(first)
|
2071 |
+
options = match.group(1) or '' if match else ''
|
2072 |
+
return options.strip()
|
2073 |
+
|
2074 |
+
def as_header(self):
|
2075 |
+
return self._render(self + list(self.options))
|
2076 |
+
|
2077 |
+
@staticmethod
|
2078 |
+
def _strip_quotes(item):
|
2079 |
+
_QUOTES = '"\''
|
2080 |
+
for q in _QUOTES:
|
2081 |
+
if item.startswith(q) and item.endswith(q):
|
2082 |
+
return item[1:-1]
|
2083 |
+
return item
|
2084 |
+
|
2085 |
+
@staticmethod
|
2086 |
+
def _render(items):
|
2087 |
+
cmdline = subprocess.list2cmdline(
|
2088 |
+
CommandSpec._strip_quotes(item.strip()) for item in items)
|
2089 |
+
return '#!' + cmdline + '\n'
|
2090 |
+
|
2091 |
+
|
2092 |
+
# For pbr compat; will be removed in a future version.
|
2093 |
+
sys_executable = CommandSpec._sys_executable()
|
2094 |
+
|
2095 |
+
|
2096 |
+
class WindowsCommandSpec(CommandSpec):
|
2097 |
+
split_args = dict(posix=False)
|
2098 |
+
|
2099 |
+
|
2100 |
+
class ScriptWriter:
|
2101 |
+
"""
|
2102 |
+
Encapsulates behavior around writing entry point scripts for console and
|
2103 |
+
gui apps.
|
2104 |
+
"""
|
2105 |
+
|
2106 |
+
template = textwrap.dedent(r"""
|
2107 |
+
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
|
2108 |
+
import re
|
2109 |
+
import sys
|
2110 |
+
|
2111 |
+
# for compatibility with easy_install; see #2198
|
2112 |
+
__requires__ = %(spec)r
|
2113 |
+
|
2114 |
+
try:
|
2115 |
+
from importlib.metadata import distribution
|
2116 |
+
except ImportError:
|
2117 |
+
try:
|
2118 |
+
from importlib_metadata import distribution
|
2119 |
+
except ImportError:
|
2120 |
+
from pkg_resources import load_entry_point
|
2121 |
+
|
2122 |
+
|
2123 |
+
def importlib_load_entry_point(spec, group, name):
|
2124 |
+
dist_name, _, _ = spec.partition('==')
|
2125 |
+
matches = (
|
2126 |
+
entry_point
|
2127 |
+
for entry_point in distribution(dist_name).entry_points
|
2128 |
+
if entry_point.group == group and entry_point.name == name
|
2129 |
+
)
|
2130 |
+
return next(matches).load()
|
2131 |
+
|
2132 |
+
|
2133 |
+
globals().setdefault('load_entry_point', importlib_load_entry_point)
|
2134 |
+
|
2135 |
+
|
2136 |
+
if __name__ == '__main__':
|
2137 |
+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
2138 |
+
sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
|
2139 |
+
""").lstrip()
|
2140 |
+
|
2141 |
+
command_spec_class = CommandSpec
|
2142 |
+
|
2143 |
+
@classmethod
|
2144 |
+
def get_script_args(cls, dist, executable=None, wininst=False):
|
2145 |
+
# for backward compatibility
|
2146 |
+
warnings.warn("Use get_args", EasyInstallDeprecationWarning)
|
2147 |
+
writer = (WindowsScriptWriter if wininst else ScriptWriter).best()
|
2148 |
+
header = cls.get_script_header("", executable, wininst)
|
2149 |
+
return writer.get_args(dist, header)
|
2150 |
+
|
2151 |
+
@classmethod
|
2152 |
+
def get_script_header(cls, script_text, executable=None, wininst=False):
|
2153 |
+
# for backward compatibility
|
2154 |
+
warnings.warn(
|
2155 |
+
"Use get_header", EasyInstallDeprecationWarning, stacklevel=2)
|
2156 |
+
if wininst:
|
2157 |
+
executable = "python.exe"
|
2158 |
+
return cls.get_header(script_text, executable)
|
2159 |
+
|
2160 |
+
@classmethod
|
2161 |
+
def get_args(cls, dist, header=None):
|
2162 |
+
"""
|
2163 |
+
Yield write_script() argument tuples for a distribution's
|
2164 |
+
console_scripts and gui_scripts entry points.
|
2165 |
+
"""
|
2166 |
+
if header is None:
|
2167 |
+
header = cls.get_header()
|
2168 |
+
spec = str(dist.as_requirement())
|
2169 |
+
for type_ in 'console', 'gui':
|
2170 |
+
group = type_ + '_scripts'
|
2171 |
+
for name, ep in dist.get_entry_map(group).items():
|
2172 |
+
cls._ensure_safe_name(name)
|
2173 |
+
script_text = cls.template % locals()
|
2174 |
+
args = cls._get_script_args(type_, name, header, script_text)
|
2175 |
+
for res in args:
|
2176 |
+
yield res
|
2177 |
+
|
2178 |
+
@staticmethod
|
2179 |
+
def _ensure_safe_name(name):
|
2180 |
+
"""
|
2181 |
+
Prevent paths in *_scripts entry point names.
|
2182 |
+
"""
|
2183 |
+
has_path_sep = re.search(r'[\\/]', name)
|
2184 |
+
if has_path_sep:
|
2185 |
+
raise ValueError("Path separators not allowed in script names")
|
2186 |
+
|
2187 |
+
@classmethod
|
2188 |
+
def get_writer(cls, force_windows):
|
2189 |
+
# for backward compatibility
|
2190 |
+
warnings.warn("Use best", EasyInstallDeprecationWarning)
|
2191 |
+
return WindowsScriptWriter.best() if force_windows else cls.best()
|
2192 |
+
|
2193 |
+
@classmethod
|
2194 |
+
def best(cls):
|
2195 |
+
"""
|
2196 |
+
Select the best ScriptWriter for this environment.
|
2197 |
+
"""
|
2198 |
+
if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'):
|
2199 |
+
return WindowsScriptWriter.best()
|
2200 |
+
else:
|
2201 |
+
return cls
|
2202 |
+
|
2203 |
+
@classmethod
|
2204 |
+
def _get_script_args(cls, type_, name, header, script_text):
|
2205 |
+
# Simply write the stub with no extension.
|
2206 |
+
yield (name, header + script_text)
|
2207 |
+
|
2208 |
+
@classmethod
|
2209 |
+
def get_header(cls, script_text="", executable=None):
|
2210 |
+
"""Create a #! line, getting options (if any) from script_text"""
|
2211 |
+
cmd = cls.command_spec_class.best().from_param(executable)
|
2212 |
+
cmd.install_options(script_text)
|
2213 |
+
return cmd.as_header()
|
2214 |
+
|
2215 |
+
|
2216 |
+
class WindowsScriptWriter(ScriptWriter):
|
2217 |
+
command_spec_class = WindowsCommandSpec
|
2218 |
+
|
2219 |
+
@classmethod
|
2220 |
+
def get_writer(cls):
|
2221 |
+
# for backward compatibility
|
2222 |
+
warnings.warn("Use best", EasyInstallDeprecationWarning)
|
2223 |
+
return cls.best()
|
2224 |
+
|
2225 |
+
@classmethod
|
2226 |
+
def best(cls):
|
2227 |
+
"""
|
2228 |
+
Select the best ScriptWriter suitable for Windows
|
2229 |
+
"""
|
2230 |
+
writer_lookup = dict(
|
2231 |
+
executable=WindowsExecutableLauncherWriter,
|
2232 |
+
natural=cls,
|
2233 |
+
)
|
2234 |
+
# for compatibility, use the executable launcher by default
|
2235 |
+
launcher = os.environ.get('SETUPTOOLS_LAUNCHER', 'executable')
|
2236 |
+
return writer_lookup[launcher]
|
2237 |
+
|
2238 |
+
@classmethod
|
2239 |
+
def _get_script_args(cls, type_, name, header, script_text):
|
2240 |
+
"For Windows, add a .py extension"
|
2241 |
+
ext = dict(console='.pya', gui='.pyw')[type_]
|
2242 |
+
if ext not in os.environ['PATHEXT'].lower().split(';'):
|
2243 |
+
msg = (
|
2244 |
+
"{ext} not listed in PATHEXT; scripts will not be "
|
2245 |
+
"recognized as executables."
|
2246 |
+
).format(**locals())
|
2247 |
+
warnings.warn(msg, UserWarning)
|
2248 |
+
old = ['.pya', '.py', '-script.py', '.pyc', '.pyo', '.pyw', '.exe']
|
2249 |
+
old.remove(ext)
|
2250 |
+
header = cls._adjust_header(type_, header)
|
2251 |
+
blockers = [name + x for x in old]
|
2252 |
+
yield name + ext, header + script_text, 't', blockers
|
2253 |
+
|
2254 |
+
@classmethod
|
2255 |
+
def _adjust_header(cls, type_, orig_header):
|
2256 |
+
"""
|
2257 |
+
Make sure 'pythonw' is used for gui and 'python' is used for
|
2258 |
+
console (regardless of what sys.executable is).
|
2259 |
+
"""
|
2260 |
+
pattern = 'pythonw.exe'
|
2261 |
+
repl = 'python.exe'
|
2262 |
+
if type_ == 'gui':
|
2263 |
+
pattern, repl = repl, pattern
|
2264 |
+
pattern_ob = re.compile(re.escape(pattern), re.IGNORECASE)
|
2265 |
+
new_header = pattern_ob.sub(string=orig_header, repl=repl)
|
2266 |
+
return new_header if cls._use_header(new_header) else orig_header
|
2267 |
+
|
2268 |
+
@staticmethod
|
2269 |
+
def _use_header(new_header):
|
2270 |
+
"""
|
2271 |
+
Should _adjust_header use the replaced header?
|
2272 |
+
|
2273 |
+
On non-windows systems, always use. On
|
2274 |
+
Windows systems, only use the replaced header if it resolves
|
2275 |
+
to an executable on the system.
|
2276 |
+
"""
|
2277 |
+
clean_header = new_header[2:-1].strip('"')
|
2278 |
+
return sys.platform != 'win32' or find_executable(clean_header)
|
2279 |
+
|
2280 |
+
|
2281 |
+
class WindowsExecutableLauncherWriter(WindowsScriptWriter):
|
2282 |
+
@classmethod
|
2283 |
+
def _get_script_args(cls, type_, name, header, script_text):
|
2284 |
+
"""
|
2285 |
+
For Windows, add a .py extension and an .exe launcher
|
2286 |
+
"""
|
2287 |
+
if type_ == 'gui':
|
2288 |
+
launcher_type = 'gui'
|
2289 |
+
ext = '-script.pyw'
|
2290 |
+
old = ['.pyw']
|
2291 |
+
else:
|
2292 |
+
launcher_type = 'cli'
|
2293 |
+
ext = '-script.py'
|
2294 |
+
old = ['.py', '.pyc', '.pyo']
|
2295 |
+
hdr = cls._adjust_header(type_, header)
|
2296 |
+
blockers = [name + x for x in old]
|
2297 |
+
yield (name + ext, hdr + script_text, 't', blockers)
|
2298 |
+
yield (
|
2299 |
+
name + '.exe', get_win_launcher(launcher_type),
|
2300 |
+
'b' # write in binary mode
|
2301 |
+
)
|
2302 |
+
if not is_64bit():
|
2303 |
+
# install a manifest for the launcher to prevent Windows
|
2304 |
+
# from detecting it as an installer (which it will for
|
2305 |
+
# launchers like easy_install.exe). Consider only
|
2306 |
+
# adding a manifest for launchers detected as installers.
|
2307 |
+
# See Distribute #143 for details.
|
2308 |
+
m_name = name + '.exe.manifest'
|
2309 |
+
yield (m_name, load_launcher_manifest(name), 't')
|
2310 |
+
|
2311 |
+
|
2312 |
+
# for backward-compatibility
|
2313 |
+
get_script_args = ScriptWriter.get_script_args
|
2314 |
+
get_script_header = ScriptWriter.get_script_header
|
2315 |
+
|
2316 |
+
|
2317 |
+
def get_win_launcher(type):
|
2318 |
+
"""
|
2319 |
+
Load the Windows launcher (executable) suitable for launching a script.
|
2320 |
+
|
2321 |
+
`type` should be either 'cli' or 'gui'
|
2322 |
+
|
2323 |
+
Returns the executable as a byte string.
|
2324 |
+
"""
|
2325 |
+
launcher_fn = '%s.exe' % type
|
2326 |
+
if is_64bit():
|
2327 |
+
if get_platform() == "win-arm64":
|
2328 |
+
launcher_fn = launcher_fn.replace(".", "-arm64.")
|
2329 |
+
else:
|
2330 |
+
launcher_fn = launcher_fn.replace(".", "-64.")
|
2331 |
+
else:
|
2332 |
+
launcher_fn = launcher_fn.replace(".", "-32.")
|
2333 |
+
return resource_string('setuptools', launcher_fn)
|
2334 |
+
|
2335 |
+
|
2336 |
+
def load_launcher_manifest(name):
|
2337 |
+
manifest = pkg_resources.resource_string(__name__, 'launcher manifest.xml')
|
2338 |
+
return manifest.decode('utf-8') % vars()
|
2339 |
+
|
2340 |
+
|
2341 |
+
def rmtree(path, ignore_errors=False, onerror=auto_chmod):
|
2342 |
+
return shutil.rmtree(path, ignore_errors, onerror)
|
2343 |
+
|
2344 |
+
|
2345 |
+
def current_umask():
|
2346 |
+
tmp = os.umask(0o022)
|
2347 |
+
os.umask(tmp)
|
2348 |
+
return tmp
|
2349 |
+
|
2350 |
+
|
2351 |
+
class EasyInstallDeprecationWarning(SetuptoolsDeprecationWarning):
|
2352 |
+
"""
|
2353 |
+
Warning for EasyInstall deprecations, bypassing suppression.
|
2354 |
+
"""
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/egg_info.py
ADDED
@@ -0,0 +1,755 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""setuptools.command.egg_info
|
2 |
+
|
3 |
+
Create a distribution's .egg-info directory and contents"""
|
4 |
+
|
5 |
+
from distutils.filelist import FileList as _FileList
|
6 |
+
from distutils.errors import DistutilsInternalError
|
7 |
+
from distutils.util import convert_path
|
8 |
+
from distutils import log
|
9 |
+
import distutils.errors
|
10 |
+
import distutils.filelist
|
11 |
+
import functools
|
12 |
+
import os
|
13 |
+
import re
|
14 |
+
import sys
|
15 |
+
import io
|
16 |
+
import warnings
|
17 |
+
import time
|
18 |
+
import collections
|
19 |
+
|
20 |
+
from setuptools import Command
|
21 |
+
from setuptools.command.sdist import sdist
|
22 |
+
from setuptools.command.sdist import walk_revctrl
|
23 |
+
from setuptools.command.setopt import edit_config
|
24 |
+
from setuptools.command import bdist_egg
|
25 |
+
from pkg_resources import (
|
26 |
+
parse_requirements, safe_name, parse_version,
|
27 |
+
safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename)
|
28 |
+
import setuptools.unicode_utils as unicode_utils
|
29 |
+
from setuptools.glob import glob
|
30 |
+
|
31 |
+
from setuptools.extern import packaging
|
32 |
+
from setuptools import SetuptoolsDeprecationWarning
|
33 |
+
|
34 |
+
|
35 |
+
def translate_pattern(glob): # noqa: C901 # is too complex (14) # FIXME
|
36 |
+
"""
|
37 |
+
Translate a file path glob like '*.txt' in to a regular expression.
|
38 |
+
This differs from fnmatch.translate which allows wildcards to match
|
39 |
+
directory separators. It also knows about '**/' which matches any number of
|
40 |
+
directories.
|
41 |
+
"""
|
42 |
+
pat = ''
|
43 |
+
|
44 |
+
# This will split on '/' within [character classes]. This is deliberate.
|
45 |
+
chunks = glob.split(os.path.sep)
|
46 |
+
|
47 |
+
sep = re.escape(os.sep)
|
48 |
+
valid_char = '[^%s]' % (sep,)
|
49 |
+
|
50 |
+
for c, chunk in enumerate(chunks):
|
51 |
+
last_chunk = c == len(chunks) - 1
|
52 |
+
|
53 |
+
# Chunks that are a literal ** are globstars. They match anything.
|
54 |
+
if chunk == '**':
|
55 |
+
if last_chunk:
|
56 |
+
# Match anything if this is the last component
|
57 |
+
pat += '.*'
|
58 |
+
else:
|
59 |
+
# Match '(name/)*'
|
60 |
+
pat += '(?:%s+%s)*' % (valid_char, sep)
|
61 |
+
continue # Break here as the whole path component has been handled
|
62 |
+
|
63 |
+
# Find any special characters in the remainder
|
64 |
+
i = 0
|
65 |
+
chunk_len = len(chunk)
|
66 |
+
while i < chunk_len:
|
67 |
+
char = chunk[i]
|
68 |
+
if char == '*':
|
69 |
+
# Match any number of name characters
|
70 |
+
pat += valid_char + '*'
|
71 |
+
elif char == '?':
|
72 |
+
# Match a name character
|
73 |
+
pat += valid_char
|
74 |
+
elif char == '[':
|
75 |
+
# Character class
|
76 |
+
inner_i = i + 1
|
77 |
+
# Skip initial !/] chars
|
78 |
+
if inner_i < chunk_len and chunk[inner_i] == '!':
|
79 |
+
inner_i = inner_i + 1
|
80 |
+
if inner_i < chunk_len and chunk[inner_i] == ']':
|
81 |
+
inner_i = inner_i + 1
|
82 |
+
|
83 |
+
# Loop till the closing ] is found
|
84 |
+
while inner_i < chunk_len and chunk[inner_i] != ']':
|
85 |
+
inner_i = inner_i + 1
|
86 |
+
|
87 |
+
if inner_i >= chunk_len:
|
88 |
+
# Got to the end of the string without finding a closing ]
|
89 |
+
# Do not treat this as a matching group, but as a literal [
|
90 |
+
pat += re.escape(char)
|
91 |
+
else:
|
92 |
+
# Grab the insides of the [brackets]
|
93 |
+
inner = chunk[i + 1:inner_i]
|
94 |
+
char_class = ''
|
95 |
+
|
96 |
+
# Class negation
|
97 |
+
if inner[0] == '!':
|
98 |
+
char_class = '^'
|
99 |
+
inner = inner[1:]
|
100 |
+
|
101 |
+
char_class += re.escape(inner)
|
102 |
+
pat += '[%s]' % (char_class,)
|
103 |
+
|
104 |
+
# Skip to the end ]
|
105 |
+
i = inner_i
|
106 |
+
else:
|
107 |
+
pat += re.escape(char)
|
108 |
+
i += 1
|
109 |
+
|
110 |
+
# Join each chunk with the dir separator
|
111 |
+
if not last_chunk:
|
112 |
+
pat += sep
|
113 |
+
|
114 |
+
pat += r'\Z'
|
115 |
+
return re.compile(pat, flags=re.MULTILINE | re.DOTALL)
|
116 |
+
|
117 |
+
|
118 |
+
class InfoCommon:
|
119 |
+
tag_build = None
|
120 |
+
tag_date = None
|
121 |
+
|
122 |
+
@property
|
123 |
+
def name(self):
|
124 |
+
return safe_name(self.distribution.get_name())
|
125 |
+
|
126 |
+
def tagged_version(self):
|
127 |
+
return safe_version(self._maybe_tag(self.distribution.get_version()))
|
128 |
+
|
129 |
+
def _maybe_tag(self, version):
|
130 |
+
"""
|
131 |
+
egg_info may be called more than once for a distribution,
|
132 |
+
in which case the version string already contains all tags.
|
133 |
+
"""
|
134 |
+
return (
|
135 |
+
version if self.vtags and version.endswith(self.vtags)
|
136 |
+
else version + self.vtags
|
137 |
+
)
|
138 |
+
|
139 |
+
def tags(self):
|
140 |
+
version = ''
|
141 |
+
if self.tag_build:
|
142 |
+
version += self.tag_build
|
143 |
+
if self.tag_date:
|
144 |
+
version += time.strftime("-%Y%m%d")
|
145 |
+
return version
|
146 |
+
vtags = property(tags)
|
147 |
+
|
148 |
+
|
149 |
+
class egg_info(InfoCommon, Command):
|
150 |
+
description = "create a distribution's .egg-info directory"
|
151 |
+
|
152 |
+
user_options = [
|
153 |
+
('egg-base=', 'e', "directory containing .egg-info directories"
|
154 |
+
" (default: top of the source tree)"),
|
155 |
+
('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"),
|
156 |
+
('tag-build=', 'b', "Specify explicit tag to add to version number"),
|
157 |
+
('no-date', 'D', "Don't include date stamp [default]"),
|
158 |
+
]
|
159 |
+
|
160 |
+
boolean_options = ['tag-date']
|
161 |
+
negative_opt = {
|
162 |
+
'no-date': 'tag-date',
|
163 |
+
}
|
164 |
+
|
165 |
+
def initialize_options(self):
|
166 |
+
self.egg_base = None
|
167 |
+
self.egg_name = None
|
168 |
+
self.egg_info = None
|
169 |
+
self.egg_version = None
|
170 |
+
self.broken_egg_info = False
|
171 |
+
|
172 |
+
####################################
|
173 |
+
# allow the 'tag_svn_revision' to be detected and
|
174 |
+
# set, supporting sdists built on older Setuptools.
|
175 |
+
@property
|
176 |
+
def tag_svn_revision(self):
|
177 |
+
pass
|
178 |
+
|
179 |
+
@tag_svn_revision.setter
|
180 |
+
def tag_svn_revision(self, value):
|
181 |
+
pass
|
182 |
+
####################################
|
183 |
+
|
184 |
+
def save_version_info(self, filename):
|
185 |
+
"""
|
186 |
+
Materialize the value of date into the
|
187 |
+
build tag. Install build keys in a deterministic order
|
188 |
+
to avoid arbitrary reordering on subsequent builds.
|
189 |
+
"""
|
190 |
+
egg_info = collections.OrderedDict()
|
191 |
+
# follow the order these keys would have been added
|
192 |
+
# when PYTHONHASHSEED=0
|
193 |
+
egg_info['tag_build'] = self.tags()
|
194 |
+
egg_info['tag_date'] = 0
|
195 |
+
edit_config(filename, dict(egg_info=egg_info))
|
196 |
+
|
197 |
+
def finalize_options(self):
|
198 |
+
# Note: we need to capture the current value returned
|
199 |
+
# by `self.tagged_version()`, so we can later update
|
200 |
+
# `self.distribution.metadata.version` without
|
201 |
+
# repercussions.
|
202 |
+
self.egg_name = self.name
|
203 |
+
self.egg_version = self.tagged_version()
|
204 |
+
parsed_version = parse_version(self.egg_version)
|
205 |
+
|
206 |
+
try:
|
207 |
+
is_version = isinstance(parsed_version, packaging.version.Version)
|
208 |
+
spec = (
|
209 |
+
"%s==%s" if is_version else "%s===%s"
|
210 |
+
)
|
211 |
+
list(
|
212 |
+
parse_requirements(spec % (self.egg_name, self.egg_version))
|
213 |
+
)
|
214 |
+
except ValueError as e:
|
215 |
+
raise distutils.errors.DistutilsOptionError(
|
216 |
+
"Invalid distribution name or version syntax: %s-%s" %
|
217 |
+
(self.egg_name, self.egg_version)
|
218 |
+
) from e
|
219 |
+
|
220 |
+
if self.egg_base is None:
|
221 |
+
dirs = self.distribution.package_dir
|
222 |
+
self.egg_base = (dirs or {}).get('', os.curdir)
|
223 |
+
|
224 |
+
self.ensure_dirname('egg_base')
|
225 |
+
self.egg_info = to_filename(self.egg_name) + '.egg-info'
|
226 |
+
if self.egg_base != os.curdir:
|
227 |
+
self.egg_info = os.path.join(self.egg_base, self.egg_info)
|
228 |
+
if '-' in self.egg_name:
|
229 |
+
self.check_broken_egg_info()
|
230 |
+
|
231 |
+
# Set package version for the benefit of dumber commands
|
232 |
+
# (e.g. sdist, bdist_wininst, etc.)
|
233 |
+
#
|
234 |
+
self.distribution.metadata.version = self.egg_version
|
235 |
+
|
236 |
+
# If we bootstrapped around the lack of a PKG-INFO, as might be the
|
237 |
+
# case in a fresh checkout, make sure that any special tags get added
|
238 |
+
# to the version info
|
239 |
+
#
|
240 |
+
pd = self.distribution._patched_dist
|
241 |
+
if pd is not None and pd.key == self.egg_name.lower():
|
242 |
+
pd._version = self.egg_version
|
243 |
+
pd._parsed_version = parse_version(self.egg_version)
|
244 |
+
self.distribution._patched_dist = None
|
245 |
+
|
246 |
+
def write_or_delete_file(self, what, filename, data, force=False):
|
247 |
+
"""Write `data` to `filename` or delete if empty
|
248 |
+
|
249 |
+
If `data` is non-empty, this routine is the same as ``write_file()``.
|
250 |
+
If `data` is empty but not ``None``, this is the same as calling
|
251 |
+
``delete_file(filename)`. If `data` is ``None``, then this is a no-op
|
252 |
+
unless `filename` exists, in which case a warning is issued about the
|
253 |
+
orphaned file (if `force` is false), or deleted (if `force` is true).
|
254 |
+
"""
|
255 |
+
if data:
|
256 |
+
self.write_file(what, filename, data)
|
257 |
+
elif os.path.exists(filename):
|
258 |
+
if data is None and not force:
|
259 |
+
log.warn(
|
260 |
+
"%s not set in setup(), but %s exists", what, filename
|
261 |
+
)
|
262 |
+
return
|
263 |
+
else:
|
264 |
+
self.delete_file(filename)
|
265 |
+
|
266 |
+
def write_file(self, what, filename, data):
|
267 |
+
"""Write `data` to `filename` (if not a dry run) after announcing it
|
268 |
+
|
269 |
+
`what` is used in a log message to identify what is being written
|
270 |
+
to the file.
|
271 |
+
"""
|
272 |
+
log.info("writing %s to %s", what, filename)
|
273 |
+
data = data.encode("utf-8")
|
274 |
+
if not self.dry_run:
|
275 |
+
f = open(filename, 'wb')
|
276 |
+
f.write(data)
|
277 |
+
f.close()
|
278 |
+
|
279 |
+
def delete_file(self, filename):
|
280 |
+
"""Delete `filename` (if not a dry run) after announcing it"""
|
281 |
+
log.info("deleting %s", filename)
|
282 |
+
if not self.dry_run:
|
283 |
+
os.unlink(filename)
|
284 |
+
|
285 |
+
def run(self):
|
286 |
+
self.mkpath(self.egg_info)
|
287 |
+
os.utime(self.egg_info, None)
|
288 |
+
installer = self.distribution.fetch_build_egg
|
289 |
+
for ep in iter_entry_points('egg_info.writers'):
|
290 |
+
ep.require(installer=installer)
|
291 |
+
writer = ep.resolve()
|
292 |
+
writer(self, ep.name, os.path.join(self.egg_info, ep.name))
|
293 |
+
|
294 |
+
# Get rid of native_libs.txt if it was put there by older bdist_egg
|
295 |
+
nl = os.path.join(self.egg_info, "native_libs.txt")
|
296 |
+
if os.path.exists(nl):
|
297 |
+
self.delete_file(nl)
|
298 |
+
|
299 |
+
self.find_sources()
|
300 |
+
|
301 |
+
def find_sources(self):
|
302 |
+
"""Generate SOURCES.txt manifest file"""
|
303 |
+
manifest_filename = os.path.join(self.egg_info, "SOURCES.txt")
|
304 |
+
mm = manifest_maker(self.distribution)
|
305 |
+
mm.manifest = manifest_filename
|
306 |
+
mm.run()
|
307 |
+
self.filelist = mm.filelist
|
308 |
+
|
309 |
+
def check_broken_egg_info(self):
|
310 |
+
bei = self.egg_name + '.egg-info'
|
311 |
+
if self.egg_base != os.curdir:
|
312 |
+
bei = os.path.join(self.egg_base, bei)
|
313 |
+
if os.path.exists(bei):
|
314 |
+
log.warn(
|
315 |
+
"-" * 78 + '\n'
|
316 |
+
"Note: Your current .egg-info directory has a '-' in its name;"
|
317 |
+
'\nthis will not work correctly with "setup.py develop".\n\n'
|
318 |
+
'Please rename %s to %s to correct this problem.\n' + '-' * 78,
|
319 |
+
bei, self.egg_info
|
320 |
+
)
|
321 |
+
self.broken_egg_info = self.egg_info
|
322 |
+
self.egg_info = bei # make it work for now
|
323 |
+
|
324 |
+
|
325 |
+
class FileList(_FileList):
|
326 |
+
# Implementations of the various MANIFEST.in commands
|
327 |
+
|
328 |
+
def process_template_line(self, line):
|
329 |
+
# Parse the line: split it up, make sure the right number of words
|
330 |
+
# is there, and return the relevant words. 'action' is always
|
331 |
+
# defined: it's the first word of the line. Which of the other
|
332 |
+
# three are defined depends on the action; it'll be either
|
333 |
+
# patterns, (dir and patterns), or (dir_pattern).
|
334 |
+
(action, patterns, dir, dir_pattern) = self._parse_template_line(line)
|
335 |
+
|
336 |
+
action_map = {
|
337 |
+
'include': self.include,
|
338 |
+
'exclude': self.exclude,
|
339 |
+
'global-include': self.global_include,
|
340 |
+
'global-exclude': self.global_exclude,
|
341 |
+
'recursive-include': functools.partial(
|
342 |
+
self.recursive_include, dir,
|
343 |
+
),
|
344 |
+
'recursive-exclude': functools.partial(
|
345 |
+
self.recursive_exclude, dir,
|
346 |
+
),
|
347 |
+
'graft': self.graft,
|
348 |
+
'prune': self.prune,
|
349 |
+
}
|
350 |
+
log_map = {
|
351 |
+
'include': "warning: no files found matching '%s'",
|
352 |
+
'exclude': (
|
353 |
+
"warning: no previously-included files found "
|
354 |
+
"matching '%s'"
|
355 |
+
),
|
356 |
+
'global-include': (
|
357 |
+
"warning: no files found matching '%s' "
|
358 |
+
"anywhere in distribution"
|
359 |
+
),
|
360 |
+
'global-exclude': (
|
361 |
+
"warning: no previously-included files matching "
|
362 |
+
"'%s' found anywhere in distribution"
|
363 |
+
),
|
364 |
+
'recursive-include': (
|
365 |
+
"warning: no files found matching '%s' "
|
366 |
+
"under directory '%s'"
|
367 |
+
),
|
368 |
+
'recursive-exclude': (
|
369 |
+
"warning: no previously-included files matching "
|
370 |
+
"'%s' found under directory '%s'"
|
371 |
+
),
|
372 |
+
'graft': "warning: no directories found matching '%s'",
|
373 |
+
'prune': "no previously-included directories found matching '%s'",
|
374 |
+
}
|
375 |
+
|
376 |
+
try:
|
377 |
+
process_action = action_map[action]
|
378 |
+
except KeyError:
|
379 |
+
raise DistutilsInternalError(
|
380 |
+
"this cannot happen: invalid action '{action!s}'".
|
381 |
+
format(action=action),
|
382 |
+
)
|
383 |
+
|
384 |
+
# OK, now we know that the action is valid and we have the
|
385 |
+
# right number of words on the line for that action -- so we
|
386 |
+
# can proceed with minimal error-checking.
|
387 |
+
|
388 |
+
action_is_recursive = action.startswith('recursive-')
|
389 |
+
if action in {'graft', 'prune'}:
|
390 |
+
patterns = [dir_pattern]
|
391 |
+
extra_log_args = (dir, ) if action_is_recursive else ()
|
392 |
+
log_tmpl = log_map[action]
|
393 |
+
|
394 |
+
self.debug_print(
|
395 |
+
' '.join(
|
396 |
+
[action] +
|
397 |
+
([dir] if action_is_recursive else []) +
|
398 |
+
patterns,
|
399 |
+
)
|
400 |
+
)
|
401 |
+
for pattern in patterns:
|
402 |
+
if not process_action(pattern):
|
403 |
+
log.warn(log_tmpl, pattern, *extra_log_args)
|
404 |
+
|
405 |
+
def _remove_files(self, predicate):
|
406 |
+
"""
|
407 |
+
Remove all files from the file list that match the predicate.
|
408 |
+
Return True if any matching files were removed
|
409 |
+
"""
|
410 |
+
found = False
|
411 |
+
for i in range(len(self.files) - 1, -1, -1):
|
412 |
+
if predicate(self.files[i]):
|
413 |
+
self.debug_print(" removing " + self.files[i])
|
414 |
+
del self.files[i]
|
415 |
+
found = True
|
416 |
+
return found
|
417 |
+
|
418 |
+
def include(self, pattern):
|
419 |
+
"""Include files that match 'pattern'."""
|
420 |
+
found = [f for f in glob(pattern) if not os.path.isdir(f)]
|
421 |
+
self.extend(found)
|
422 |
+
return bool(found)
|
423 |
+
|
424 |
+
def exclude(self, pattern):
|
425 |
+
"""Exclude files that match 'pattern'."""
|
426 |
+
match = translate_pattern(pattern)
|
427 |
+
return self._remove_files(match.match)
|
428 |
+
|
429 |
+
def recursive_include(self, dir, pattern):
|
430 |
+
"""
|
431 |
+
Include all files anywhere in 'dir/' that match the pattern.
|
432 |
+
"""
|
433 |
+
full_pattern = os.path.join(dir, '**', pattern)
|
434 |
+
found = [f for f in glob(full_pattern, recursive=True)
|
435 |
+
if not os.path.isdir(f)]
|
436 |
+
self.extend(found)
|
437 |
+
return bool(found)
|
438 |
+
|
439 |
+
def recursive_exclude(self, dir, pattern):
|
440 |
+
"""
|
441 |
+
Exclude any file anywhere in 'dir/' that match the pattern.
|
442 |
+
"""
|
443 |
+
match = translate_pattern(os.path.join(dir, '**', pattern))
|
444 |
+
return self._remove_files(match.match)
|
445 |
+
|
446 |
+
def graft(self, dir):
|
447 |
+
"""Include all files from 'dir/'."""
|
448 |
+
found = [
|
449 |
+
item
|
450 |
+
for match_dir in glob(dir)
|
451 |
+
for item in distutils.filelist.findall(match_dir)
|
452 |
+
]
|
453 |
+
self.extend(found)
|
454 |
+
return bool(found)
|
455 |
+
|
456 |
+
def prune(self, dir):
|
457 |
+
"""Filter out files from 'dir/'."""
|
458 |
+
match = translate_pattern(os.path.join(dir, '**'))
|
459 |
+
return self._remove_files(match.match)
|
460 |
+
|
461 |
+
def global_include(self, pattern):
|
462 |
+
"""
|
463 |
+
Include all files anywhere in the current directory that match the
|
464 |
+
pattern. This is very inefficient on large file trees.
|
465 |
+
"""
|
466 |
+
if self.allfiles is None:
|
467 |
+
self.findall()
|
468 |
+
match = translate_pattern(os.path.join('**', pattern))
|
469 |
+
found = [f for f in self.allfiles if match.match(f)]
|
470 |
+
self.extend(found)
|
471 |
+
return bool(found)
|
472 |
+
|
473 |
+
def global_exclude(self, pattern):
|
474 |
+
"""
|
475 |
+
Exclude all files anywhere that match the pattern.
|
476 |
+
"""
|
477 |
+
match = translate_pattern(os.path.join('**', pattern))
|
478 |
+
return self._remove_files(match.match)
|
479 |
+
|
480 |
+
def append(self, item):
|
481 |
+
if item.endswith('\r'): # Fix older sdists built on Windows
|
482 |
+
item = item[:-1]
|
483 |
+
path = convert_path(item)
|
484 |
+
|
485 |
+
if self._safe_path(path):
|
486 |
+
self.files.append(path)
|
487 |
+
|
488 |
+
def extend(self, paths):
|
489 |
+
self.files.extend(filter(self._safe_path, paths))
|
490 |
+
|
491 |
+
def _repair(self):
|
492 |
+
"""
|
493 |
+
Replace self.files with only safe paths
|
494 |
+
|
495 |
+
Because some owners of FileList manipulate the underlying
|
496 |
+
``files`` attribute directly, this method must be called to
|
497 |
+
repair those paths.
|
498 |
+
"""
|
499 |
+
self.files = list(filter(self._safe_path, self.files))
|
500 |
+
|
501 |
+
def _safe_path(self, path):
|
502 |
+
enc_warn = "'%s' not %s encodable -- skipping"
|
503 |
+
|
504 |
+
# To avoid accidental trans-codings errors, first to unicode
|
505 |
+
u_path = unicode_utils.filesys_decode(path)
|
506 |
+
if u_path is None:
|
507 |
+
log.warn("'%s' in unexpected encoding -- skipping" % path)
|
508 |
+
return False
|
509 |
+
|
510 |
+
# Must ensure utf-8 encodability
|
511 |
+
utf8_path = unicode_utils.try_encode(u_path, "utf-8")
|
512 |
+
if utf8_path is None:
|
513 |
+
log.warn(enc_warn, path, 'utf-8')
|
514 |
+
return False
|
515 |
+
|
516 |
+
try:
|
517 |
+
# accept is either way checks out
|
518 |
+
if os.path.exists(u_path) or os.path.exists(utf8_path):
|
519 |
+
return True
|
520 |
+
# this will catch any encode errors decoding u_path
|
521 |
+
except UnicodeEncodeError:
|
522 |
+
log.warn(enc_warn, path, sys.getfilesystemencoding())
|
523 |
+
|
524 |
+
|
525 |
+
class manifest_maker(sdist):
|
526 |
+
template = "MANIFEST.in"
|
527 |
+
|
528 |
+
def initialize_options(self):
|
529 |
+
self.use_defaults = 1
|
530 |
+
self.prune = 1
|
531 |
+
self.manifest_only = 1
|
532 |
+
self.force_manifest = 1
|
533 |
+
|
534 |
+
def finalize_options(self):
|
535 |
+
pass
|
536 |
+
|
537 |
+
def run(self):
|
538 |
+
self.filelist = FileList()
|
539 |
+
if not os.path.exists(self.manifest):
|
540 |
+
self.write_manifest() # it must exist so it'll get in the list
|
541 |
+
self.add_defaults()
|
542 |
+
if os.path.exists(self.template):
|
543 |
+
self.read_template()
|
544 |
+
self.add_license_files()
|
545 |
+
self.prune_file_list()
|
546 |
+
self.filelist.sort()
|
547 |
+
self.filelist.remove_duplicates()
|
548 |
+
self.write_manifest()
|
549 |
+
|
550 |
+
def _manifest_normalize(self, path):
|
551 |
+
path = unicode_utils.filesys_decode(path)
|
552 |
+
return path.replace(os.sep, '/')
|
553 |
+
|
554 |
+
def write_manifest(self):
|
555 |
+
"""
|
556 |
+
Write the file list in 'self.filelist' to the manifest file
|
557 |
+
named by 'self.manifest'.
|
558 |
+
"""
|
559 |
+
self.filelist._repair()
|
560 |
+
|
561 |
+
# Now _repairs should encodability, but not unicode
|
562 |
+
files = [self._manifest_normalize(f) for f in self.filelist.files]
|
563 |
+
msg = "writing manifest file '%s'" % self.manifest
|
564 |
+
self.execute(write_file, (self.manifest, files), msg)
|
565 |
+
|
566 |
+
def warn(self, msg):
|
567 |
+
if not self._should_suppress_warning(msg):
|
568 |
+
sdist.warn(self, msg)
|
569 |
+
|
570 |
+
@staticmethod
|
571 |
+
def _should_suppress_warning(msg):
|
572 |
+
"""
|
573 |
+
suppress missing-file warnings from sdist
|
574 |
+
"""
|
575 |
+
return re.match(r"standard file .*not found", msg)
|
576 |
+
|
577 |
+
def add_defaults(self):
|
578 |
+
sdist.add_defaults(self)
|
579 |
+
self.filelist.append(self.template)
|
580 |
+
self.filelist.append(self.manifest)
|
581 |
+
rcfiles = list(walk_revctrl())
|
582 |
+
if rcfiles:
|
583 |
+
self.filelist.extend(rcfiles)
|
584 |
+
elif os.path.exists(self.manifest):
|
585 |
+
self.read_manifest()
|
586 |
+
|
587 |
+
if os.path.exists("setup.py"):
|
588 |
+
# setup.py should be included by default, even if it's not
|
589 |
+
# the script called to create the sdist
|
590 |
+
self.filelist.append("setup.py")
|
591 |
+
|
592 |
+
ei_cmd = self.get_finalized_command('egg_info')
|
593 |
+
self.filelist.graft(ei_cmd.egg_info)
|
594 |
+
|
595 |
+
def add_license_files(self):
|
596 |
+
license_files = self.distribution.metadata.license_files or []
|
597 |
+
for lf in license_files:
|
598 |
+
log.info("adding license file '%s'", lf)
|
599 |
+
pass
|
600 |
+
self.filelist.extend(license_files)
|
601 |
+
|
602 |
+
def prune_file_list(self):
|
603 |
+
build = self.get_finalized_command('build')
|
604 |
+
base_dir = self.distribution.get_fullname()
|
605 |
+
self.filelist.prune(build.build_base)
|
606 |
+
self.filelist.prune(base_dir)
|
607 |
+
sep = re.escape(os.sep)
|
608 |
+
self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep,
|
609 |
+
is_regex=1)
|
610 |
+
|
611 |
+
def _safe_data_files(self, build_py):
|
612 |
+
"""
|
613 |
+
The parent class implementation of this method
|
614 |
+
(``sdist``) will try to include data files, which
|
615 |
+
might cause recursion problems when
|
616 |
+
``include_package_data=True``.
|
617 |
+
|
618 |
+
Therefore, avoid triggering any attempt of
|
619 |
+
analyzing/building the manifest again.
|
620 |
+
"""
|
621 |
+
if hasattr(build_py, 'get_data_files_without_manifest'):
|
622 |
+
return build_py.get_data_files_without_manifest()
|
623 |
+
|
624 |
+
warnings.warn(
|
625 |
+
"Custom 'build_py' does not implement "
|
626 |
+
"'get_data_files_without_manifest'.\nPlease extend command classes"
|
627 |
+
" from setuptools instead of distutils.",
|
628 |
+
SetuptoolsDeprecationWarning
|
629 |
+
)
|
630 |
+
return build_py.get_data_files()
|
631 |
+
|
632 |
+
|
633 |
+
def write_file(filename, contents):
|
634 |
+
"""Create a file with the specified name and write 'contents' (a
|
635 |
+
sequence of strings without line terminators) to it.
|
636 |
+
"""
|
637 |
+
contents = "\n".join(contents)
|
638 |
+
|
639 |
+
# assuming the contents has been vetted for utf-8 encoding
|
640 |
+
contents = contents.encode("utf-8")
|
641 |
+
|
642 |
+
with open(filename, "wb") as f: # always write POSIX-style manifest
|
643 |
+
f.write(contents)
|
644 |
+
|
645 |
+
|
646 |
+
def write_pkg_info(cmd, basename, filename):
|
647 |
+
log.info("writing %s", filename)
|
648 |
+
if not cmd.dry_run:
|
649 |
+
metadata = cmd.distribution.metadata
|
650 |
+
metadata.version, oldver = cmd.egg_version, metadata.version
|
651 |
+
metadata.name, oldname = cmd.egg_name, metadata.name
|
652 |
+
|
653 |
+
try:
|
654 |
+
# write unescaped data to PKG-INFO, so older pkg_resources
|
655 |
+
# can still parse it
|
656 |
+
metadata.write_pkg_info(cmd.egg_info)
|
657 |
+
finally:
|
658 |
+
metadata.name, metadata.version = oldname, oldver
|
659 |
+
|
660 |
+
safe = getattr(cmd.distribution, 'zip_safe', None)
|
661 |
+
|
662 |
+
bdist_egg.write_safety_flag(cmd.egg_info, safe)
|
663 |
+
|
664 |
+
|
665 |
+
def warn_depends_obsolete(cmd, basename, filename):
|
666 |
+
if os.path.exists(filename):
|
667 |
+
log.warn(
|
668 |
+
"WARNING: 'depends.txt' is not used by setuptools 0.6!\n"
|
669 |
+
"Use the install_requires/extras_require setup() args instead."
|
670 |
+
)
|
671 |
+
|
672 |
+
|
673 |
+
def _write_requirements(stream, reqs):
|
674 |
+
lines = yield_lines(reqs or ())
|
675 |
+
|
676 |
+
def append_cr(line):
|
677 |
+
return line + '\n'
|
678 |
+
lines = map(append_cr, sorted(lines))
|
679 |
+
stream.writelines(lines)
|
680 |
+
|
681 |
+
|
682 |
+
def write_requirements(cmd, basename, filename):
|
683 |
+
dist = cmd.distribution
|
684 |
+
data = io.StringIO()
|
685 |
+
_write_requirements(data, dist.install_requires)
|
686 |
+
extras_require = dist.extras_require or {}
|
687 |
+
for extra in sorted(extras_require):
|
688 |
+
data.write('\n[{extra}]\n'.format(**vars()))
|
689 |
+
_write_requirements(data, extras_require[extra])
|
690 |
+
cmd.write_or_delete_file("requirements", filename, data.getvalue())
|
691 |
+
|
692 |
+
|
693 |
+
def write_setup_requirements(cmd, basename, filename):
|
694 |
+
data = io.StringIO()
|
695 |
+
_write_requirements(data, cmd.distribution.setup_requires)
|
696 |
+
cmd.write_or_delete_file("setup-requirements", filename, data.getvalue())
|
697 |
+
|
698 |
+
|
699 |
+
def write_toplevel_names(cmd, basename, filename):
|
700 |
+
pkgs = dict.fromkeys(
|
701 |
+
[
|
702 |
+
k.split('.', 1)[0]
|
703 |
+
for k in cmd.distribution.iter_distribution_names()
|
704 |
+
]
|
705 |
+
)
|
706 |
+
cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs)) + '\n')
|
707 |
+
|
708 |
+
|
709 |
+
def overwrite_arg(cmd, basename, filename):
|
710 |
+
write_arg(cmd, basename, filename, True)
|
711 |
+
|
712 |
+
|
713 |
+
def write_arg(cmd, basename, filename, force=False):
|
714 |
+
argname = os.path.splitext(basename)[0]
|
715 |
+
value = getattr(cmd.distribution, argname, None)
|
716 |
+
if value is not None:
|
717 |
+
value = '\n'.join(value) + '\n'
|
718 |
+
cmd.write_or_delete_file(argname, filename, value, force)
|
719 |
+
|
720 |
+
|
721 |
+
def write_entries(cmd, basename, filename):
|
722 |
+
ep = cmd.distribution.entry_points
|
723 |
+
|
724 |
+
if isinstance(ep, str) or ep is None:
|
725 |
+
data = ep
|
726 |
+
elif ep is not None:
|
727 |
+
data = []
|
728 |
+
for section, contents in sorted(ep.items()):
|
729 |
+
if not isinstance(contents, str):
|
730 |
+
contents = EntryPoint.parse_group(section, contents)
|
731 |
+
contents = '\n'.join(sorted(map(str, contents.values())))
|
732 |
+
data.append('[%s]\n%s\n\n' % (section, contents))
|
733 |
+
data = ''.join(data)
|
734 |
+
|
735 |
+
cmd.write_or_delete_file('entry points', filename, data, True)
|
736 |
+
|
737 |
+
|
738 |
+
def get_pkg_info_revision():
|
739 |
+
"""
|
740 |
+
Get a -r### off of PKG-INFO Version in case this is an sdist of
|
741 |
+
a subversion revision.
|
742 |
+
"""
|
743 |
+
warnings.warn(
|
744 |
+
"get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning)
|
745 |
+
if os.path.exists('PKG-INFO'):
|
746 |
+
with io.open('PKG-INFO') as f:
|
747 |
+
for line in f:
|
748 |
+
match = re.match(r"Version:.*-r(\d+)\s*$", line)
|
749 |
+
if match:
|
750 |
+
return int(match.group(1))
|
751 |
+
return 0
|
752 |
+
|
753 |
+
|
754 |
+
class EggInfoDeprecationWarning(SetuptoolsDeprecationWarning):
|
755 |
+
"""Deprecated behavior warning for EggInfo, bypassing suppression."""
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/install.py
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.errors import DistutilsArgError
|
2 |
+
import inspect
|
3 |
+
import glob
|
4 |
+
import warnings
|
5 |
+
import platform
|
6 |
+
import distutils.command.install as orig
|
7 |
+
|
8 |
+
import setuptools
|
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 |
+
('single-version-externally-managed', None,
|
21 |
+
"used by system package builders to create 'flat' eggs"),
|
22 |
+
]
|
23 |
+
boolean_options = orig.install.boolean_options + [
|
24 |
+
'old-and-unmanageable', 'single-version-externally-managed',
|
25 |
+
]
|
26 |
+
new_commands = [
|
27 |
+
('install_egg_info', lambda self: True),
|
28 |
+
('install_scripts', lambda self: True),
|
29 |
+
]
|
30 |
+
_nc = dict(new_commands)
|
31 |
+
|
32 |
+
def initialize_options(self):
|
33 |
+
|
34 |
+
warnings.warn(
|
35 |
+
"setup.py install is deprecated. "
|
36 |
+
"Use build and pip and other standards-based tools.",
|
37 |
+
setuptools.SetuptoolsDeprecationWarning,
|
38 |
+
)
|
39 |
+
|
40 |
+
orig.install.initialize_options(self)
|
41 |
+
self.old_and_unmanageable = None
|
42 |
+
self.single_version_externally_managed = None
|
43 |
+
|
44 |
+
def finalize_options(self):
|
45 |
+
orig.install.finalize_options(self)
|
46 |
+
if self.root:
|
47 |
+
self.single_version_externally_managed = True
|
48 |
+
elif self.single_version_externally_managed:
|
49 |
+
if not self.root and not self.record:
|
50 |
+
raise DistutilsArgError(
|
51 |
+
"You must specify --record or --root when building system"
|
52 |
+
" packages"
|
53 |
+
)
|
54 |
+
|
55 |
+
def handle_extra_path(self):
|
56 |
+
if self.root or self.single_version_externally_managed:
|
57 |
+
# explicit backward-compatibility mode, allow extra_path to work
|
58 |
+
return orig.install.handle_extra_path(self)
|
59 |
+
|
60 |
+
# Ignore extra_path when installing an egg (or being run by another
|
61 |
+
# command without --root or --single-version-externally-managed
|
62 |
+
self.path_file = None
|
63 |
+
self.extra_dirs = ''
|
64 |
+
|
65 |
+
def run(self):
|
66 |
+
# Explicit request for old-style install? Just do it
|
67 |
+
if self.old_and_unmanageable or self.single_version_externally_managed:
|
68 |
+
return orig.install.run(self)
|
69 |
+
|
70 |
+
if not self._called_from_setup(inspect.currentframe()):
|
71 |
+
# Run in backward-compatibility mode to support bdist_* commands.
|
72 |
+
orig.install.run(self)
|
73 |
+
else:
|
74 |
+
self.do_egg_install()
|
75 |
+
|
76 |
+
@staticmethod
|
77 |
+
def _called_from_setup(run_frame):
|
78 |
+
"""
|
79 |
+
Attempt to detect whether run() was called from setup() or by another
|
80 |
+
command. If called by setup(), the parent caller will be the
|
81 |
+
'run_command' method in 'distutils.dist', and *its* caller will be
|
82 |
+
the 'run_commands' method. If called any other way, the
|
83 |
+
immediate caller *might* be 'run_command', but it won't have been
|
84 |
+
called by 'run_commands'. Return True in that case or if a call stack
|
85 |
+
is unavailable. Return False otherwise.
|
86 |
+
"""
|
87 |
+
if run_frame is None:
|
88 |
+
msg = "Call stack not available. bdist_* commands may fail."
|
89 |
+
warnings.warn(msg)
|
90 |
+
if platform.python_implementation() == 'IronPython':
|
91 |
+
msg = "For best results, pass -X:Frames to enable call stack."
|
92 |
+
warnings.warn(msg)
|
93 |
+
return True
|
94 |
+
res = inspect.getouterframes(run_frame)[2]
|
95 |
+
caller, = res[:1]
|
96 |
+
info = inspect.getframeinfo(caller)
|
97 |
+
caller_module = caller.f_globals.get('__name__', '')
|
98 |
+
return (
|
99 |
+
caller_module == 'distutils.dist'
|
100 |
+
and info.function == 'run_commands'
|
101 |
+
)
|
102 |
+
|
103 |
+
def do_egg_install(self):
|
104 |
+
|
105 |
+
easy_install = self.distribution.get_command_class('easy_install')
|
106 |
+
|
107 |
+
cmd = easy_install(
|
108 |
+
self.distribution, args="x", root=self.root, record=self.record,
|
109 |
+
)
|
110 |
+
cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
|
111 |
+
cmd.always_copy_from = '.' # make sure local-dir eggs get installed
|
112 |
+
|
113 |
+
# pick up setup-dir .egg files only: no .egg-info
|
114 |
+
cmd.package_index.scan(glob.glob('*.egg'))
|
115 |
+
|
116 |
+
self.run_command('bdist_egg')
|
117 |
+
args = [self.distribution.get_command_obj('bdist_egg').egg_output]
|
118 |
+
|
119 |
+
if setuptools.bootstrap_install_from:
|
120 |
+
# Bootstrap self-installation of setuptools
|
121 |
+
args.insert(0, setuptools.bootstrap_install_from)
|
122 |
+
|
123 |
+
cmd.args = args
|
124 |
+
cmd.run(show_deprecation=False)
|
125 |
+
setuptools.bootstrap_install_from = None
|
126 |
+
|
127 |
+
|
128 |
+
# XXX Python 3.1 doesn't see _nc if this is inside the class
|
129 |
+
install.sub_commands = (
|
130 |
+
[cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc] +
|
131 |
+
install.new_commands
|
132 |
+
)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/install_egg_info.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils import log, dir_util
|
2 |
+
import os, sys
|
3 |
+
|
4 |
+
from setuptools import Command
|
5 |
+
from setuptools import namespaces
|
6 |
+
from setuptools.archive_util import unpack_archive
|
7 |
+
import pkg_resources
|
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 |
+
self.install_layout = None
|
22 |
+
self.prefix_option = None
|
23 |
+
|
24 |
+
def finalize_options(self):
|
25 |
+
self.set_undefined_options('install_lib',
|
26 |
+
('install_dir', 'install_dir'))
|
27 |
+
self.set_undefined_options('install',('install_layout','install_layout'))
|
28 |
+
if sys.hexversion > 0x2060000:
|
29 |
+
self.set_undefined_options('install',('prefix_option','prefix_option'))
|
30 |
+
ei_cmd = self.get_finalized_command("egg_info")
|
31 |
+
basename = pkg_resources.Distribution(
|
32 |
+
None, None, ei_cmd.egg_name, ei_cmd.egg_version
|
33 |
+
).egg_name() + '.egg-info'
|
34 |
+
|
35 |
+
if self.install_layout:
|
36 |
+
if not self.install_layout.lower() in ['deb']:
|
37 |
+
raise DistutilsOptionError("unknown value for --install-layout")
|
38 |
+
self.install_layout = self.install_layout.lower()
|
39 |
+
basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '')
|
40 |
+
elif self.prefix_option or 'real_prefix' in sys.__dict__:
|
41 |
+
# don't modify for virtualenv
|
42 |
+
pass
|
43 |
+
else:
|
44 |
+
basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '')
|
45 |
+
|
46 |
+
self.source = ei_cmd.egg_info
|
47 |
+
self.target = os.path.join(self.install_dir, basename)
|
48 |
+
self.outputs = []
|
49 |
+
|
50 |
+
def run(self):
|
51 |
+
self.run_command('egg_info')
|
52 |
+
if os.path.isdir(self.target) and not os.path.islink(self.target):
|
53 |
+
dir_util.remove_tree(self.target, dry_run=self.dry_run)
|
54 |
+
elif os.path.exists(self.target):
|
55 |
+
self.execute(os.unlink, (self.target,), "Removing " + self.target)
|
56 |
+
if not self.dry_run:
|
57 |
+
pkg_resources.ensure_directory(self.target)
|
58 |
+
self.execute(
|
59 |
+
self.copytree, (), "Copying %s to %s" % (self.source, self.target)
|
60 |
+
)
|
61 |
+
self.install_namespaces()
|
62 |
+
|
63 |
+
def get_outputs(self):
|
64 |
+
return self.outputs
|
65 |
+
|
66 |
+
def copytree(self):
|
67 |
+
# Copy the .egg-info tree to site-packages
|
68 |
+
def skimmer(src, dst):
|
69 |
+
# filter out source-control directories; note that 'src' is always
|
70 |
+
# a '/'-separated path, regardless of platform. 'dst' is a
|
71 |
+
# platform-specific path.
|
72 |
+
for skip in '.svn/', 'CVS/':
|
73 |
+
if src.startswith(skip) or '/' + skip in src:
|
74 |
+
return None
|
75 |
+
if self.install_layout and self.install_layout in ['deb'] and src.startswith('SOURCES.txt'):
|
76 |
+
log.info("Skipping SOURCES.txt")
|
77 |
+
return None
|
78 |
+
self.outputs.append(dst)
|
79 |
+
log.debug("Copying %s to %s", src, dst)
|
80 |
+
return dst
|
81 |
+
|
82 |
+
unpack_archive(self.source, self.target, skimmer)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/install_lib.py
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
from itertools import product, starmap
|
4 |
+
import distutils.command.install_lib as orig
|
5 |
+
|
6 |
+
|
7 |
+
class install_lib(orig.install_lib):
|
8 |
+
"""Don't add compiled flags to filenames of non-Python files"""
|
9 |
+
|
10 |
+
def initialize_options(self):
|
11 |
+
orig.install_lib.initialize_options(self)
|
12 |
+
self.multiarch = None
|
13 |
+
self.install_layout = None
|
14 |
+
|
15 |
+
def finalize_options(self):
|
16 |
+
orig.install_lib.finalize_options(self)
|
17 |
+
self.set_undefined_options('install',('install_layout','install_layout'))
|
18 |
+
if self.install_layout == 'deb' and sys.version_info[:2] >= (3, 3):
|
19 |
+
import sysconfig
|
20 |
+
self.multiarch = sysconfig.get_config_var('MULTIARCH')
|
21 |
+
|
22 |
+
def run(self):
|
23 |
+
self.build()
|
24 |
+
outfiles = self.install()
|
25 |
+
if outfiles is not None:
|
26 |
+
# always compile, in case we have any extension stubs to deal with
|
27 |
+
self.byte_compile(outfiles)
|
28 |
+
|
29 |
+
def get_exclusions(self):
|
30 |
+
"""
|
31 |
+
Return a collections.Sized collections.Container of paths to be
|
32 |
+
excluded for single_version_externally_managed installations.
|
33 |
+
"""
|
34 |
+
all_packages = (
|
35 |
+
pkg
|
36 |
+
for ns_pkg in self._get_SVEM_NSPs()
|
37 |
+
for pkg in self._all_packages(ns_pkg)
|
38 |
+
)
|
39 |
+
|
40 |
+
excl_specs = product(all_packages, self._gen_exclusion_paths())
|
41 |
+
return set(starmap(self._exclude_pkg_path, excl_specs))
|
42 |
+
|
43 |
+
def _exclude_pkg_path(self, pkg, exclusion_path):
|
44 |
+
"""
|
45 |
+
Given a package name and exclusion path within that package,
|
46 |
+
compute the full exclusion path.
|
47 |
+
"""
|
48 |
+
parts = pkg.split('.') + [exclusion_path]
|
49 |
+
return os.path.join(self.install_dir, *parts)
|
50 |
+
|
51 |
+
@staticmethod
|
52 |
+
def _all_packages(pkg_name):
|
53 |
+
"""
|
54 |
+
>>> list(install_lib._all_packages('foo.bar.baz'))
|
55 |
+
['foo.bar.baz', 'foo.bar', 'foo']
|
56 |
+
"""
|
57 |
+
while pkg_name:
|
58 |
+
yield pkg_name
|
59 |
+
pkg_name, sep, child = pkg_name.rpartition('.')
|
60 |
+
|
61 |
+
def _get_SVEM_NSPs(self):
|
62 |
+
"""
|
63 |
+
Get namespace packages (list) but only for
|
64 |
+
single_version_externally_managed installations and empty otherwise.
|
65 |
+
"""
|
66 |
+
# TODO: is it necessary to short-circuit here? i.e. what's the cost
|
67 |
+
# if get_finalized_command is called even when namespace_packages is
|
68 |
+
# False?
|
69 |
+
if not self.distribution.namespace_packages:
|
70 |
+
return []
|
71 |
+
|
72 |
+
install_cmd = self.get_finalized_command('install')
|
73 |
+
svem = install_cmd.single_version_externally_managed
|
74 |
+
|
75 |
+
return self.distribution.namespace_packages if svem else []
|
76 |
+
|
77 |
+
@staticmethod
|
78 |
+
def _gen_exclusion_paths():
|
79 |
+
"""
|
80 |
+
Generate file paths to be excluded for namespace packages (bytecode
|
81 |
+
cache files).
|
82 |
+
"""
|
83 |
+
# always exclude the package module itself
|
84 |
+
yield '__init__.py'
|
85 |
+
|
86 |
+
yield '__init__.pyc'
|
87 |
+
yield '__init__.pyo'
|
88 |
+
|
89 |
+
if not hasattr(sys, 'implementation'):
|
90 |
+
return
|
91 |
+
|
92 |
+
base = os.path.join(
|
93 |
+
'__pycache__', '__init__.' + sys.implementation.cache_tag)
|
94 |
+
yield base + '.pyc'
|
95 |
+
yield base + '.pyo'
|
96 |
+
yield base + '.opt-1.pyc'
|
97 |
+
yield base + '.opt-2.pyc'
|
98 |
+
|
99 |
+
def copy_tree(
|
100 |
+
self, infile, outfile,
|
101 |
+
preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1
|
102 |
+
):
|
103 |
+
assert preserve_mode and preserve_times and not preserve_symlinks
|
104 |
+
exclude = self.get_exclusions()
|
105 |
+
|
106 |
+
if not exclude:
|
107 |
+
import distutils.dir_util
|
108 |
+
distutils.dir_util._multiarch = self.multiarch
|
109 |
+
return orig.install_lib.copy_tree(self, infile, outfile)
|
110 |
+
|
111 |
+
# Exclude namespace package __init__.py* files from the output
|
112 |
+
|
113 |
+
from setuptools.archive_util import unpack_directory
|
114 |
+
from distutils import log
|
115 |
+
|
116 |
+
outfiles = []
|
117 |
+
|
118 |
+
if self.multiarch:
|
119 |
+
import sysconfig
|
120 |
+
ext_suffix = sysconfig.get_config_var ('EXT_SUFFIX')
|
121 |
+
if ext_suffix.endswith(self.multiarch + ext_suffix[-3:]):
|
122 |
+
new_suffix = None
|
123 |
+
else:
|
124 |
+
new_suffix = "%s-%s%s" % (ext_suffix[:-3], self.multiarch, ext_suffix[-3:])
|
125 |
+
|
126 |
+
def pf(src, dst):
|
127 |
+
if dst in exclude:
|
128 |
+
log.warn("Skipping installation of %s (namespace package)",
|
129 |
+
dst)
|
130 |
+
return False
|
131 |
+
|
132 |
+
if self.multiarch and new_suffix and dst.endswith(ext_suffix) and not dst.endswith(new_suffix):
|
133 |
+
dst = dst.replace(ext_suffix, new_suffix)
|
134 |
+
log.info("renaming extension to %s", os.path.basename(dst))
|
135 |
+
|
136 |
+
log.info("copying %s -> %s", src, os.path.dirname(dst))
|
137 |
+
outfiles.append(dst)
|
138 |
+
return dst
|
139 |
+
|
140 |
+
unpack_directory(infile, outfile, pf)
|
141 |
+
return outfiles
|
142 |
+
|
143 |
+
def get_outputs(self):
|
144 |
+
outputs = orig.install_lib.get_outputs(self)
|
145 |
+
exclude = self.get_exclusions()
|
146 |
+
if exclude:
|
147 |
+
return [f for f in outputs if f not in exclude]
|
148 |
+
return outputs
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/install_scripts.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils import log
|
2 |
+
import distutils.command.install_scripts as orig
|
3 |
+
from distutils.errors import DistutilsModuleError
|
4 |
+
import os
|
5 |
+
import sys
|
6 |
+
|
7 |
+
from pkg_resources import Distribution, PathMetadata, ensure_directory
|
8 |
+
|
9 |
+
|
10 |
+
class install_scripts(orig.install_scripts):
|
11 |
+
"""Do normal script install, plus any egg_info wrapper scripts"""
|
12 |
+
|
13 |
+
def initialize_options(self):
|
14 |
+
orig.install_scripts.initialize_options(self)
|
15 |
+
self.no_ep = False
|
16 |
+
|
17 |
+
def run(self):
|
18 |
+
import setuptools.command.easy_install as ei
|
19 |
+
|
20 |
+
self.run_command("egg_info")
|
21 |
+
if self.distribution.scripts:
|
22 |
+
orig.install_scripts.run(self) # run first to set up self.outfiles
|
23 |
+
else:
|
24 |
+
self.outfiles = []
|
25 |
+
if self.no_ep:
|
26 |
+
# don't install entry point scripts into .egg file!
|
27 |
+
return
|
28 |
+
|
29 |
+
ei_cmd = self.get_finalized_command("egg_info")
|
30 |
+
dist = Distribution(
|
31 |
+
ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
|
32 |
+
ei_cmd.egg_name, ei_cmd.egg_version,
|
33 |
+
)
|
34 |
+
bs_cmd = self.get_finalized_command('build_scripts')
|
35 |
+
exec_param = getattr(bs_cmd, 'executable', None)
|
36 |
+
try:
|
37 |
+
bw_cmd = self.get_finalized_command("bdist_wininst")
|
38 |
+
is_wininst = getattr(bw_cmd, '_is_running', False)
|
39 |
+
except (ImportError, DistutilsModuleError):
|
40 |
+
is_wininst = False
|
41 |
+
writer = ei.ScriptWriter
|
42 |
+
if is_wininst:
|
43 |
+
exec_param = "python.exe"
|
44 |
+
writer = ei.WindowsScriptWriter
|
45 |
+
if exec_param == sys.executable:
|
46 |
+
# In case the path to the Python executable contains a space, wrap
|
47 |
+
# it so it's not split up.
|
48 |
+
exec_param = [exec_param]
|
49 |
+
# resolve the writer to the environment
|
50 |
+
writer = writer.best()
|
51 |
+
cmd = writer.command_spec_class.best().from_param(exec_param)
|
52 |
+
for args in writer.get_args(dist, cmd.as_header()):
|
53 |
+
self.write_script(*args)
|
54 |
+
|
55 |
+
def write_script(self, script_name, contents, mode="t", *ignored):
|
56 |
+
"""Write an executable file to the scripts directory"""
|
57 |
+
from setuptools.command.easy_install import chmod, current_umask
|
58 |
+
|
59 |
+
log.info("Installing %s script to %s", script_name, self.install_dir)
|
60 |
+
target = os.path.join(self.install_dir, script_name)
|
61 |
+
self.outfiles.append(target)
|
62 |
+
|
63 |
+
mask = current_umask()
|
64 |
+
if not self.dry_run:
|
65 |
+
ensure_directory(target)
|
66 |
+
f = open(target, "w" + mode)
|
67 |
+
f.write(contents)
|
68 |
+
f.close()
|
69 |
+
chmod(target, 0o777 - mask)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/launcher manifest.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2 |
+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
3 |
+
<assemblyIdentity version="1.0.0.0"
|
4 |
+
processorArchitecture="X86"
|
5 |
+
name="%(name)s"
|
6 |
+
type="win32"/>
|
7 |
+
<!-- Identify the application security requirements. -->
|
8 |
+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
9 |
+
<security>
|
10 |
+
<requestedPrivileges>
|
11 |
+
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
12 |
+
</requestedPrivileges>
|
13 |
+
</security>
|
14 |
+
</trustInfo>
|
15 |
+
</assembly>
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/py36compat.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from glob import glob
|
3 |
+
from distutils.util import convert_path
|
4 |
+
from distutils.command import sdist
|
5 |
+
|
6 |
+
|
7 |
+
class sdist_add_defaults:
|
8 |
+
"""
|
9 |
+
Mix-in providing forward-compatibility for functionality as found in
|
10 |
+
distutils on Python 3.7.
|
11 |
+
|
12 |
+
Do not edit the code in this class except to update functionality
|
13 |
+
as implemented in distutils. Instead, override in the subclass.
|
14 |
+
"""
|
15 |
+
|
16 |
+
def add_defaults(self):
|
17 |
+
"""Add all the default files to self.filelist:
|
18 |
+
- README or README.txt
|
19 |
+
- setup.py
|
20 |
+
- test/test*.py
|
21 |
+
- all pure Python modules mentioned in setup script
|
22 |
+
- all files pointed by package_data (build_py)
|
23 |
+
- all files defined in data_files.
|
24 |
+
- all files defined as scripts.
|
25 |
+
- all C sources listed as part of extensions or C libraries
|
26 |
+
in the setup script (doesn't catch C headers!)
|
27 |
+
Warns if (README or README.txt) or setup.py are missing; everything
|
28 |
+
else is optional.
|
29 |
+
"""
|
30 |
+
self._add_defaults_standards()
|
31 |
+
self._add_defaults_optional()
|
32 |
+
self._add_defaults_python()
|
33 |
+
self._add_defaults_data_files()
|
34 |
+
self._add_defaults_ext()
|
35 |
+
self._add_defaults_c_libs()
|
36 |
+
self._add_defaults_scripts()
|
37 |
+
|
38 |
+
@staticmethod
|
39 |
+
def _cs_path_exists(fspath):
|
40 |
+
"""
|
41 |
+
Case-sensitive path existence check
|
42 |
+
|
43 |
+
>>> sdist_add_defaults._cs_path_exists(__file__)
|
44 |
+
True
|
45 |
+
>>> sdist_add_defaults._cs_path_exists(__file__.upper())
|
46 |
+
False
|
47 |
+
"""
|
48 |
+
if not os.path.exists(fspath):
|
49 |
+
return False
|
50 |
+
# make absolute so we always have a directory
|
51 |
+
abspath = os.path.abspath(fspath)
|
52 |
+
directory, filename = os.path.split(abspath)
|
53 |
+
return filename in os.listdir(directory)
|
54 |
+
|
55 |
+
def _add_defaults_standards(self):
|
56 |
+
standards = [self.READMES, self.distribution.script_name]
|
57 |
+
for fn in standards:
|
58 |
+
if isinstance(fn, tuple):
|
59 |
+
alts = fn
|
60 |
+
got_it = False
|
61 |
+
for fn in alts:
|
62 |
+
if self._cs_path_exists(fn):
|
63 |
+
got_it = True
|
64 |
+
self.filelist.append(fn)
|
65 |
+
break
|
66 |
+
|
67 |
+
if not got_it:
|
68 |
+
self.warn("standard file not found: should have one of " +
|
69 |
+
', '.join(alts))
|
70 |
+
else:
|
71 |
+
if self._cs_path_exists(fn):
|
72 |
+
self.filelist.append(fn)
|
73 |
+
else:
|
74 |
+
self.warn("standard file '%s' not found" % fn)
|
75 |
+
|
76 |
+
def _add_defaults_optional(self):
|
77 |
+
optional = ['test/test*.py', 'setup.cfg']
|
78 |
+
for pattern in optional:
|
79 |
+
files = filter(os.path.isfile, glob(pattern))
|
80 |
+
self.filelist.extend(files)
|
81 |
+
|
82 |
+
def _add_defaults_python(self):
|
83 |
+
# build_py is used to get:
|
84 |
+
# - python modules
|
85 |
+
# - files defined in package_data
|
86 |
+
build_py = self.get_finalized_command('build_py')
|
87 |
+
|
88 |
+
# getting python files
|
89 |
+
if self.distribution.has_pure_modules():
|
90 |
+
self.filelist.extend(build_py.get_source_files())
|
91 |
+
|
92 |
+
# getting package_data files
|
93 |
+
# (computed in build_py.data_files by build_py.finalize_options)
|
94 |
+
for pkg, src_dir, build_dir, filenames in build_py.data_files:
|
95 |
+
for filename in filenames:
|
96 |
+
self.filelist.append(os.path.join(src_dir, filename))
|
97 |
+
|
98 |
+
def _add_defaults_data_files(self):
|
99 |
+
# getting distribution.data_files
|
100 |
+
if self.distribution.has_data_files():
|
101 |
+
for item in self.distribution.data_files:
|
102 |
+
if isinstance(item, str):
|
103 |
+
# plain file
|
104 |
+
item = convert_path(item)
|
105 |
+
if os.path.isfile(item):
|
106 |
+
self.filelist.append(item)
|
107 |
+
else:
|
108 |
+
# a (dirname, filenames) tuple
|
109 |
+
dirname, filenames = item
|
110 |
+
for f in filenames:
|
111 |
+
f = convert_path(f)
|
112 |
+
if os.path.isfile(f):
|
113 |
+
self.filelist.append(f)
|
114 |
+
|
115 |
+
def _add_defaults_ext(self):
|
116 |
+
if self.distribution.has_ext_modules():
|
117 |
+
build_ext = self.get_finalized_command('build_ext')
|
118 |
+
self.filelist.extend(build_ext.get_source_files())
|
119 |
+
|
120 |
+
def _add_defaults_c_libs(self):
|
121 |
+
if self.distribution.has_c_libraries():
|
122 |
+
build_clib = self.get_finalized_command('build_clib')
|
123 |
+
self.filelist.extend(build_clib.get_source_files())
|
124 |
+
|
125 |
+
def _add_defaults_scripts(self):
|
126 |
+
if self.distribution.has_scripts():
|
127 |
+
build_scripts = self.get_finalized_command('build_scripts')
|
128 |
+
self.filelist.extend(build_scripts.get_source_files())
|
129 |
+
|
130 |
+
|
131 |
+
if hasattr(sdist.sdist, '_add_defaults_standards'):
|
132 |
+
# disable the functionality already available upstream
|
133 |
+
class sdist_add_defaults: # noqa
|
134 |
+
pass
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/register.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils import log
|
2 |
+
import distutils.command.register as orig
|
3 |
+
|
4 |
+
from setuptools.errors import RemovedCommandError
|
5 |
+
|
6 |
+
|
7 |
+
class register(orig.register):
|
8 |
+
"""Formerly used to register packages on PyPI."""
|
9 |
+
|
10 |
+
def run(self):
|
11 |
+
msg = (
|
12 |
+
"The register command has been removed, use twine to upload "
|
13 |
+
+ "instead (https://pypi.org/p/twine)"
|
14 |
+
)
|
15 |
+
|
16 |
+
self.announce("ERROR: " + msg, log.ERROR)
|
17 |
+
|
18 |
+
raise RemovedCommandError(msg)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/rotate.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.util import convert_path
|
2 |
+
from distutils import log
|
3 |
+
from distutils.errors import DistutilsOptionError
|
4 |
+
import os
|
5 |
+
import shutil
|
6 |
+
|
7 |
+
from setuptools import Command
|
8 |
+
|
9 |
+
|
10 |
+
class rotate(Command):
|
11 |
+
"""Delete older distributions"""
|
12 |
+
|
13 |
+
description = "delete older distributions, keeping N newest files"
|
14 |
+
user_options = [
|
15 |
+
('match=', 'm', "patterns to match (required)"),
|
16 |
+
('dist-dir=', 'd', "directory where the distributions are"),
|
17 |
+
('keep=', 'k', "number of matching distributions to keep"),
|
18 |
+
]
|
19 |
+
|
20 |
+
boolean_options = []
|
21 |
+
|
22 |
+
def initialize_options(self):
|
23 |
+
self.match = None
|
24 |
+
self.dist_dir = None
|
25 |
+
self.keep = None
|
26 |
+
|
27 |
+
def finalize_options(self):
|
28 |
+
if self.match is None:
|
29 |
+
raise DistutilsOptionError(
|
30 |
+
"Must specify one or more (comma-separated) match patterns "
|
31 |
+
"(e.g. '.zip' or '.egg')"
|
32 |
+
)
|
33 |
+
if self.keep is None:
|
34 |
+
raise DistutilsOptionError("Must specify number of files to keep")
|
35 |
+
try:
|
36 |
+
self.keep = int(self.keep)
|
37 |
+
except ValueError as e:
|
38 |
+
raise DistutilsOptionError("--keep must be an integer") from e
|
39 |
+
if isinstance(self.match, str):
|
40 |
+
self.match = [
|
41 |
+
convert_path(p.strip()) for p in self.match.split(',')
|
42 |
+
]
|
43 |
+
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
44 |
+
|
45 |
+
def run(self):
|
46 |
+
self.run_command("egg_info")
|
47 |
+
from glob import glob
|
48 |
+
|
49 |
+
for pattern in self.match:
|
50 |
+
pattern = self.distribution.get_name() + '*' + pattern
|
51 |
+
files = glob(os.path.join(self.dist_dir, pattern))
|
52 |
+
files = [(os.path.getmtime(f), f) for f in files]
|
53 |
+
files.sort()
|
54 |
+
files.reverse()
|
55 |
+
|
56 |
+
log.info("%d file(s) matching %s", len(files), pattern)
|
57 |
+
files = files[self.keep:]
|
58 |
+
for (t, f) in files:
|
59 |
+
log.info("Deleting %s", f)
|
60 |
+
if not self.dry_run:
|
61 |
+
if os.path.isdir(f):
|
62 |
+
shutil.rmtree(f)
|
63 |
+
else:
|
64 |
+
os.unlink(f)
|
scripts/myenv/lib/python3.10/site-packages/setuptools/command/saveopts.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from setuptools.command.setopt import edit_config, option_base
|
2 |
+
|
3 |
+
|
4 |
+
class saveopts(option_base):
|
5 |
+
"""Save command-line options to a file"""
|
6 |
+
|
7 |
+
description = "save supplied options to setup.cfg or other config file"
|
8 |
+
|
9 |
+
def run(self):
|
10 |
+
dist = self.distribution
|
11 |
+
settings = {}
|
12 |
+
|
13 |
+
for cmd in dist.command_options:
|
14 |
+
|
15 |
+
if cmd == 'saveopts':
|
16 |
+
continue # don't save our own options!
|
17 |
+
|
18 |
+
for opt, (src, val) in dist.get_option_dict(cmd).items():
|
19 |
+
if src == "command line":
|
20 |
+
settings.setdefault(cmd, {})[opt] = val
|
21 |
+
|
22 |
+
edit_config(self.filename, settings, self.dry_run)
|