Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/_distutils_hack/override.py +1 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/__init__.py +0 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/api_tests.txt +424 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/py.typed +0 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/__init__.py +0 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/setup.cfg +0 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/setup.py +7 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/PKG-INFO +10 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/SOURCES.txt +7 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/dependency_links.txt +1 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/top_level.txt +1 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/zip-safe +1 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_zipped-egg/my_test_package-1.0-py3.7.egg +0 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_find_distributions.py +56 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_integration_zope_interface.py +54 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_markers.py +8 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_pkg_resources.py +485 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_resources.py +869 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_working_set.py +505 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/PKG-INFO +141 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/SOURCES.txt +527 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/dependency_links.txt +1 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/entry_points.txt +51 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/requires.txt +83 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/top_level.txt +3 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/__init__.py +250 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_core_metadata.py +337 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_discovery.py +33 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/__init__.py +14 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_log.py +3 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_macos_compat.py +12 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_modified.py +95 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_msvccompiler.py +16 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/archive_util.py +294 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py +26 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/cmd.py +554 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/__init__.py +23 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/_framework_compat.py +54 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/bdist.py +167 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_dumb.py +141 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_rpm.py +598 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build.py +156 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_clib.py +201 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py +812 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_py.py +407 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_scripts.py +160 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/check.py +152 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/clean.py +77 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/config.py +358 -0
- miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/install.py +805 -0
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/_distutils_hack/override.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__import__('_distutils_hack').do_override()
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/__init__.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/api_tests.txt
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Pluggable Distributions of Python Software
|
| 2 |
+
==========================================
|
| 3 |
+
|
| 4 |
+
Distributions
|
| 5 |
+
-------------
|
| 6 |
+
|
| 7 |
+
A "Distribution" is a collection of files that represent a "Release" of a
|
| 8 |
+
"Project" as of a particular point in time, denoted by a
|
| 9 |
+
"Version"::
|
| 10 |
+
|
| 11 |
+
>>> import sys, pkg_resources
|
| 12 |
+
>>> from pkg_resources import Distribution
|
| 13 |
+
>>> Distribution(project_name="Foo", version="1.2")
|
| 14 |
+
Foo 1.2
|
| 15 |
+
|
| 16 |
+
Distributions have a location, which can be a filename, URL, or really anything
|
| 17 |
+
else you care to use::
|
| 18 |
+
|
| 19 |
+
>>> dist = Distribution(
|
| 20 |
+
... location="http://example.com/something",
|
| 21 |
+
... project_name="Bar", version="0.9"
|
| 22 |
+
... )
|
| 23 |
+
|
| 24 |
+
>>> dist
|
| 25 |
+
Bar 0.9 (http://example.com/something)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
Distributions have various introspectable attributes::
|
| 29 |
+
|
| 30 |
+
>>> dist.location
|
| 31 |
+
'http://example.com/something'
|
| 32 |
+
|
| 33 |
+
>>> dist.project_name
|
| 34 |
+
'Bar'
|
| 35 |
+
|
| 36 |
+
>>> dist.version
|
| 37 |
+
'0.9'
|
| 38 |
+
|
| 39 |
+
>>> dist.py_version == '{}.{}'.format(*sys.version_info)
|
| 40 |
+
True
|
| 41 |
+
|
| 42 |
+
>>> print(dist.platform)
|
| 43 |
+
None
|
| 44 |
+
|
| 45 |
+
Including various computed attributes::
|
| 46 |
+
|
| 47 |
+
>>> from pkg_resources import parse_version
|
| 48 |
+
>>> dist.parsed_version == parse_version(dist.version)
|
| 49 |
+
True
|
| 50 |
+
|
| 51 |
+
>>> dist.key # case-insensitive form of the project name
|
| 52 |
+
'bar'
|
| 53 |
+
|
| 54 |
+
Distributions are compared (and hashed) by version first::
|
| 55 |
+
|
| 56 |
+
>>> Distribution(version='1.0') == Distribution(version='1.0')
|
| 57 |
+
True
|
| 58 |
+
>>> Distribution(version='1.0') == Distribution(version='1.1')
|
| 59 |
+
False
|
| 60 |
+
>>> Distribution(version='1.0') < Distribution(version='1.1')
|
| 61 |
+
True
|
| 62 |
+
|
| 63 |
+
but also by project name (case-insensitive), platform, Python version,
|
| 64 |
+
location, etc.::
|
| 65 |
+
|
| 66 |
+
>>> Distribution(project_name="Foo",version="1.0") == \
|
| 67 |
+
... Distribution(project_name="Foo",version="1.0")
|
| 68 |
+
True
|
| 69 |
+
|
| 70 |
+
>>> Distribution(project_name="Foo",version="1.0") == \
|
| 71 |
+
... Distribution(project_name="foo",version="1.0")
|
| 72 |
+
True
|
| 73 |
+
|
| 74 |
+
>>> Distribution(project_name="Foo",version="1.0") == \
|
| 75 |
+
... Distribution(project_name="Foo",version="1.1")
|
| 76 |
+
False
|
| 77 |
+
|
| 78 |
+
>>> Distribution(project_name="Foo",py_version="2.3",version="1.0") == \
|
| 79 |
+
... Distribution(project_name="Foo",py_version="2.4",version="1.0")
|
| 80 |
+
False
|
| 81 |
+
|
| 82 |
+
>>> Distribution(location="spam",version="1.0") == \
|
| 83 |
+
... Distribution(location="spam",version="1.0")
|
| 84 |
+
True
|
| 85 |
+
|
| 86 |
+
>>> Distribution(location="spam",version="1.0") == \
|
| 87 |
+
... Distribution(location="baz",version="1.0")
|
| 88 |
+
False
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
Hash and compare distribution by prio/plat
|
| 93 |
+
|
| 94 |
+
Get version from metadata
|
| 95 |
+
provider capabilities
|
| 96 |
+
egg_name()
|
| 97 |
+
as_requirement()
|
| 98 |
+
from_location, from_filename (w/path normalization)
|
| 99 |
+
|
| 100 |
+
Releases may have zero or more "Requirements", which indicate
|
| 101 |
+
what releases of another project the release requires in order to
|
| 102 |
+
function. A Requirement names the other project, expresses some criteria
|
| 103 |
+
as to what releases of that project are acceptable, and lists any "Extras"
|
| 104 |
+
that the requiring release may need from that project. (An Extra is an
|
| 105 |
+
optional feature of a Release, that can only be used if its additional
|
| 106 |
+
Requirements are satisfied.)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
The Working Set
|
| 111 |
+
---------------
|
| 112 |
+
|
| 113 |
+
A collection of active distributions is called a Working Set. Note that a
|
| 114 |
+
Working Set can contain any importable distribution, not just pluggable ones.
|
| 115 |
+
For example, the Python standard library is an importable distribution that
|
| 116 |
+
will usually be part of the Working Set, even though it is not pluggable.
|
| 117 |
+
Similarly, when you are doing development work on a project, the files you are
|
| 118 |
+
editing are also a Distribution. (And, with a little attention to the
|
| 119 |
+
directory names used, and including some additional metadata, such a
|
| 120 |
+
"development distribution" can be made pluggable as well.)
|
| 121 |
+
|
| 122 |
+
>>> from pkg_resources import WorkingSet
|
| 123 |
+
|
| 124 |
+
A working set's entries are the sys.path entries that correspond to the active
|
| 125 |
+
distributions. By default, the working set's entries are the items on
|
| 126 |
+
``sys.path``::
|
| 127 |
+
|
| 128 |
+
>>> ws = WorkingSet()
|
| 129 |
+
>>> ws.entries == sys.path
|
| 130 |
+
True
|
| 131 |
+
|
| 132 |
+
But you can also create an empty working set explicitly, and add distributions
|
| 133 |
+
to it::
|
| 134 |
+
|
| 135 |
+
>>> ws = WorkingSet([])
|
| 136 |
+
>>> ws.add(dist)
|
| 137 |
+
>>> ws.entries
|
| 138 |
+
['http://example.com/something']
|
| 139 |
+
>>> dist in ws
|
| 140 |
+
True
|
| 141 |
+
>>> Distribution('foo',version="") in ws
|
| 142 |
+
False
|
| 143 |
+
|
| 144 |
+
And you can iterate over its distributions::
|
| 145 |
+
|
| 146 |
+
>>> list(ws)
|
| 147 |
+
[Bar 0.9 (http://example.com/something)]
|
| 148 |
+
|
| 149 |
+
Adding the same distribution more than once is a no-op::
|
| 150 |
+
|
| 151 |
+
>>> ws.add(dist)
|
| 152 |
+
>>> list(ws)
|
| 153 |
+
[Bar 0.9 (http://example.com/something)]
|
| 154 |
+
|
| 155 |
+
For that matter, adding multiple distributions for the same project also does
|
| 156 |
+
nothing, because a working set can only hold one active distribution per
|
| 157 |
+
project -- the first one added to it::
|
| 158 |
+
|
| 159 |
+
>>> ws.add(
|
| 160 |
+
... Distribution(
|
| 161 |
+
... 'http://example.com/something', project_name="Bar",
|
| 162 |
+
... version="7.2"
|
| 163 |
+
... )
|
| 164 |
+
... )
|
| 165 |
+
>>> list(ws)
|
| 166 |
+
[Bar 0.9 (http://example.com/something)]
|
| 167 |
+
|
| 168 |
+
You can append a path entry to a working set using ``add_entry()``::
|
| 169 |
+
|
| 170 |
+
>>> ws.entries
|
| 171 |
+
['http://example.com/something']
|
| 172 |
+
>>> ws.add_entry(pkg_resources.__file__)
|
| 173 |
+
>>> ws.entries
|
| 174 |
+
['http://example.com/something', '...pkg_resources...']
|
| 175 |
+
|
| 176 |
+
Multiple additions result in multiple entries, even if the entry is already in
|
| 177 |
+
the working set (because ``sys.path`` can contain the same entry more than
|
| 178 |
+
once)::
|
| 179 |
+
|
| 180 |
+
>>> ws.add_entry(pkg_resources.__file__)
|
| 181 |
+
>>> ws.entries
|
| 182 |
+
['...example.com...', '...pkg_resources...', '...pkg_resources...']
|
| 183 |
+
|
| 184 |
+
And you can specify the path entry a distribution was found under, using the
|
| 185 |
+
optional second parameter to ``add()``::
|
| 186 |
+
|
| 187 |
+
>>> ws = WorkingSet([])
|
| 188 |
+
>>> ws.add(dist,"foo")
|
| 189 |
+
>>> ws.entries
|
| 190 |
+
['foo']
|
| 191 |
+
|
| 192 |
+
But even if a distribution is found under multiple path entries, it still only
|
| 193 |
+
shows up once when iterating the working set:
|
| 194 |
+
|
| 195 |
+
>>> ws.add_entry(ws.entries[0])
|
| 196 |
+
>>> list(ws)
|
| 197 |
+
[Bar 0.9 (http://example.com/something)]
|
| 198 |
+
|
| 199 |
+
You can ask a WorkingSet to ``find()`` a distribution matching a requirement::
|
| 200 |
+
|
| 201 |
+
>>> from pkg_resources import Requirement
|
| 202 |
+
>>> print(ws.find(Requirement.parse("Foo==1.0"))) # no match, return None
|
| 203 |
+
None
|
| 204 |
+
|
| 205 |
+
>>> ws.find(Requirement.parse("Bar==0.9")) # match, return distribution
|
| 206 |
+
Bar 0.9 (http://example.com/something)
|
| 207 |
+
|
| 208 |
+
Note that asking for a conflicting version of a distribution already in a
|
| 209 |
+
working set triggers a ``pkg_resources.VersionConflict`` error:
|
| 210 |
+
|
| 211 |
+
>>> try:
|
| 212 |
+
... ws.find(Requirement.parse("Bar==1.0"))
|
| 213 |
+
... except pkg_resources.VersionConflict as exc:
|
| 214 |
+
... print(str(exc))
|
| 215 |
+
... else:
|
| 216 |
+
... raise AssertionError("VersionConflict was not raised")
|
| 217 |
+
(Bar 0.9 (http://example.com/something), Requirement.parse('Bar==1.0'))
|
| 218 |
+
|
| 219 |
+
You can subscribe a callback function to receive notifications whenever a new
|
| 220 |
+
distribution is added to a working set. The callback is immediately invoked
|
| 221 |
+
once for each existing distribution in the working set, and then is called
|
| 222 |
+
again for new distributions added thereafter::
|
| 223 |
+
|
| 224 |
+
>>> def added(dist): print("Added %s" % dist)
|
| 225 |
+
>>> ws.subscribe(added)
|
| 226 |
+
Added Bar 0.9
|
| 227 |
+
>>> foo12 = Distribution(project_name="Foo", version="1.2", location="f12")
|
| 228 |
+
>>> ws.add(foo12)
|
| 229 |
+
Added Foo 1.2
|
| 230 |
+
|
| 231 |
+
Note, however, that only the first distribution added for a given project name
|
| 232 |
+
will trigger a callback, even during the initial ``subscribe()`` callback::
|
| 233 |
+
|
| 234 |
+
>>> foo14 = Distribution(project_name="Foo", version="1.4", location="f14")
|
| 235 |
+
>>> ws.add(foo14) # no callback, because Foo 1.2 is already active
|
| 236 |
+
|
| 237 |
+
>>> ws = WorkingSet([])
|
| 238 |
+
>>> ws.add(foo12)
|
| 239 |
+
>>> ws.add(foo14)
|
| 240 |
+
>>> ws.subscribe(added)
|
| 241 |
+
Added Foo 1.2
|
| 242 |
+
|
| 243 |
+
And adding a callback more than once has no effect, either::
|
| 244 |
+
|
| 245 |
+
>>> ws.subscribe(added) # no callbacks
|
| 246 |
+
|
| 247 |
+
# and no double-callbacks on subsequent additions, either
|
| 248 |
+
>>> just_a_test = Distribution(project_name="JustATest", version="0.99")
|
| 249 |
+
>>> ws.add(just_a_test)
|
| 250 |
+
Added JustATest 0.99
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
Finding Plugins
|
| 254 |
+
---------------
|
| 255 |
+
|
| 256 |
+
``WorkingSet`` objects can be used to figure out what plugins in an
|
| 257 |
+
``Environment`` can be loaded without any resolution errors::
|
| 258 |
+
|
| 259 |
+
>>> from pkg_resources import Environment
|
| 260 |
+
|
| 261 |
+
>>> plugins = Environment([]) # normally, a list of plugin directories
|
| 262 |
+
>>> plugins.add(foo12)
|
| 263 |
+
>>> plugins.add(foo14)
|
| 264 |
+
>>> plugins.add(just_a_test)
|
| 265 |
+
|
| 266 |
+
In the simplest case, we just get the newest version of each distribution in
|
| 267 |
+
the plugin environment::
|
| 268 |
+
|
| 269 |
+
>>> ws = WorkingSet([])
|
| 270 |
+
>>> ws.find_plugins(plugins)
|
| 271 |
+
([JustATest 0.99, Foo 1.4 (f14)], {})
|
| 272 |
+
|
| 273 |
+
But if there's a problem with a version conflict or missing requirements, the
|
| 274 |
+
method falls back to older versions, and the error info dict will contain an
|
| 275 |
+
exception instance for each unloadable plugin::
|
| 276 |
+
|
| 277 |
+
>>> ws.add(foo12) # this will conflict with Foo 1.4
|
| 278 |
+
>>> ws.find_plugins(plugins)
|
| 279 |
+
([JustATest 0.99, Foo 1.2 (f12)], {Foo 1.4 (f14): VersionConflict(...)})
|
| 280 |
+
|
| 281 |
+
But if you disallow fallbacks, the failed plugin will be skipped instead of
|
| 282 |
+
trying older versions::
|
| 283 |
+
|
| 284 |
+
>>> ws.find_plugins(plugins, fallback=False)
|
| 285 |
+
([JustATest 0.99], {Foo 1.4 (f14): VersionConflict(...)})
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
Platform Compatibility Rules
|
| 290 |
+
----------------------------
|
| 291 |
+
|
| 292 |
+
On the Mac, there are potential compatibility issues for modules compiled
|
| 293 |
+
on newer versions of macOS than what the user is running. Additionally,
|
| 294 |
+
macOS will soon have two platforms to contend with: Intel and PowerPC.
|
| 295 |
+
|
| 296 |
+
Basic equality works as on other platforms::
|
| 297 |
+
|
| 298 |
+
>>> from pkg_resources import compatible_platforms as cp
|
| 299 |
+
>>> reqd = 'macosx-10.4-ppc'
|
| 300 |
+
>>> cp(reqd, reqd)
|
| 301 |
+
True
|
| 302 |
+
>>> cp("win32", reqd)
|
| 303 |
+
False
|
| 304 |
+
|
| 305 |
+
Distributions made on other machine types are not compatible::
|
| 306 |
+
|
| 307 |
+
>>> cp("macosx-10.4-i386", reqd)
|
| 308 |
+
False
|
| 309 |
+
|
| 310 |
+
Distributions made on earlier versions of the OS are compatible, as
|
| 311 |
+
long as they are from the same top-level version. The patchlevel version
|
| 312 |
+
number does not matter::
|
| 313 |
+
|
| 314 |
+
>>> cp("macosx-10.4-ppc", reqd)
|
| 315 |
+
True
|
| 316 |
+
>>> cp("macosx-10.3-ppc", reqd)
|
| 317 |
+
True
|
| 318 |
+
>>> cp("macosx-10.5-ppc", reqd)
|
| 319 |
+
False
|
| 320 |
+
>>> cp("macosx-9.5-ppc", reqd)
|
| 321 |
+
False
|
| 322 |
+
|
| 323 |
+
Backwards compatibility for packages made via earlier versions of
|
| 324 |
+
setuptools is provided as well::
|
| 325 |
+
|
| 326 |
+
>>> cp("darwin-8.2.0-Power_Macintosh", reqd)
|
| 327 |
+
True
|
| 328 |
+
>>> cp("darwin-7.2.0-Power_Macintosh", reqd)
|
| 329 |
+
True
|
| 330 |
+
>>> cp("darwin-8.2.0-Power_Macintosh", "macosx-10.3-ppc")
|
| 331 |
+
False
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
Environment Markers
|
| 335 |
+
-------------------
|
| 336 |
+
|
| 337 |
+
>>> from pkg_resources import invalid_marker as im, evaluate_marker as em
|
| 338 |
+
>>> import os
|
| 339 |
+
|
| 340 |
+
>>> print(im("sys_platform"))
|
| 341 |
+
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
|
| 342 |
+
sys_platform
|
| 343 |
+
^
|
| 344 |
+
|
| 345 |
+
>>> print(im("sys_platform=="))
|
| 346 |
+
Expected a marker variable or quoted string
|
| 347 |
+
sys_platform==
|
| 348 |
+
^
|
| 349 |
+
|
| 350 |
+
>>> print(im("sys_platform=='win32'"))
|
| 351 |
+
False
|
| 352 |
+
|
| 353 |
+
>>> print(im("sys=='x'"))
|
| 354 |
+
Expected a marker variable or quoted string
|
| 355 |
+
sys=='x'
|
| 356 |
+
^
|
| 357 |
+
|
| 358 |
+
>>> print(im("(extra)"))
|
| 359 |
+
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
|
| 360 |
+
(extra)
|
| 361 |
+
^
|
| 362 |
+
|
| 363 |
+
>>> print(im("(extra"))
|
| 364 |
+
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
|
| 365 |
+
(extra
|
| 366 |
+
^
|
| 367 |
+
|
| 368 |
+
>>> print(im("os.open('foo')=='y'"))
|
| 369 |
+
Expected a marker variable or quoted string
|
| 370 |
+
os.open('foo')=='y'
|
| 371 |
+
^
|
| 372 |
+
|
| 373 |
+
>>> print(im("'x'=='y' and os.open('foo')=='y'")) # no short-circuit!
|
| 374 |
+
Expected a marker variable or quoted string
|
| 375 |
+
'x'=='y' and os.open('foo')=='y'
|
| 376 |
+
^
|
| 377 |
+
|
| 378 |
+
>>> print(im("'x'=='x' or os.open('foo')=='y'")) # no short-circuit!
|
| 379 |
+
Expected a marker variable or quoted string
|
| 380 |
+
'x'=='x' or os.open('foo')=='y'
|
| 381 |
+
^
|
| 382 |
+
|
| 383 |
+
>>> print(im("r'x'=='x'"))
|
| 384 |
+
Expected a marker variable or quoted string
|
| 385 |
+
r'x'=='x'
|
| 386 |
+
^
|
| 387 |
+
|
| 388 |
+
>>> print(im("'''x'''=='x'"))
|
| 389 |
+
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
|
| 390 |
+
'''x'''=='x'
|
| 391 |
+
^
|
| 392 |
+
|
| 393 |
+
>>> print(im('"""x"""=="x"'))
|
| 394 |
+
Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in
|
| 395 |
+
"""x"""=="x"
|
| 396 |
+
^
|
| 397 |
+
|
| 398 |
+
>>> print(im(r"x\n=='x'"))
|
| 399 |
+
Expected a marker variable or quoted string
|
| 400 |
+
x\n=='x'
|
| 401 |
+
^
|
| 402 |
+
|
| 403 |
+
>>> print(im("os.open=='y'"))
|
| 404 |
+
Expected a marker variable or quoted string
|
| 405 |
+
os.open=='y'
|
| 406 |
+
^
|
| 407 |
+
|
| 408 |
+
>>> em("sys_platform=='win32'") == (sys.platform=='win32')
|
| 409 |
+
True
|
| 410 |
+
|
| 411 |
+
>>> em("python_version >= '2.7'")
|
| 412 |
+
True
|
| 413 |
+
|
| 414 |
+
>>> em("python_version > '2.6'")
|
| 415 |
+
True
|
| 416 |
+
|
| 417 |
+
>>> im("implementation_name=='cpython'")
|
| 418 |
+
False
|
| 419 |
+
|
| 420 |
+
>>> im("platform_python_implementation=='CPython'")
|
| 421 |
+
False
|
| 422 |
+
|
| 423 |
+
>>> im("implementation_version=='3.5.1'")
|
| 424 |
+
False
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/py.typed
ADDED
|
File without changes
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/__init__.py
ADDED
|
File without changes
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/setup.cfg
ADDED
|
File without changes
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-source/setup.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import setuptools
|
| 2 |
+
|
| 3 |
+
setuptools.setup(
|
| 4 |
+
name="my-test-package",
|
| 5 |
+
version="1.0",
|
| 6 |
+
zip_safe=True,
|
| 7 |
+
)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/PKG-INFO
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 1.0
|
| 2 |
+
Name: my-test-package
|
| 3 |
+
Version: 1.0
|
| 4 |
+
Summary: UNKNOWN
|
| 5 |
+
Home-page: UNKNOWN
|
| 6 |
+
Author: UNKNOWN
|
| 7 |
+
Author-email: UNKNOWN
|
| 8 |
+
License: UNKNOWN
|
| 9 |
+
Description: UNKNOWN
|
| 10 |
+
Platform: UNKNOWN
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/SOURCES.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
setup.cfg
|
| 2 |
+
setup.py
|
| 3 |
+
my_test_package.egg-info/PKG-INFO
|
| 4 |
+
my_test_package.egg-info/SOURCES.txt
|
| 5 |
+
my_test_package.egg-info/dependency_links.txt
|
| 6 |
+
my_test_package.egg-info/top_level.txt
|
| 7 |
+
my_test_package.egg-info/zip-safe
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package_zipped-egg/my_test_package-1.0-py3.7.egg
ADDED
|
Binary file (843 Bytes). View file
|
|
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_find_distributions.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import shutil
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
import pkg_resources
|
| 7 |
+
|
| 8 |
+
TESTS_DATA_DIR = Path(__file__).parent / 'data'
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class TestFindDistributions:
|
| 12 |
+
@pytest.fixture
|
| 13 |
+
def target_dir(self, tmpdir):
|
| 14 |
+
target_dir = tmpdir.mkdir('target')
|
| 15 |
+
# place a .egg named directory in the target that is not an egg:
|
| 16 |
+
target_dir.mkdir('not.an.egg')
|
| 17 |
+
return target_dir
|
| 18 |
+
|
| 19 |
+
def test_non_egg_dir_named_egg(self, target_dir):
|
| 20 |
+
dists = pkg_resources.find_distributions(str(target_dir))
|
| 21 |
+
assert not list(dists)
|
| 22 |
+
|
| 23 |
+
def test_standalone_egg_directory(self, target_dir):
|
| 24 |
+
shutil.copytree(
|
| 25 |
+
TESTS_DATA_DIR / 'my-test-package_unpacked-egg',
|
| 26 |
+
target_dir,
|
| 27 |
+
dirs_exist_ok=True,
|
| 28 |
+
)
|
| 29 |
+
dists = pkg_resources.find_distributions(str(target_dir))
|
| 30 |
+
assert [dist.project_name for dist in dists] == ['my-test-package']
|
| 31 |
+
dists = pkg_resources.find_distributions(str(target_dir), only=True)
|
| 32 |
+
assert not list(dists)
|
| 33 |
+
|
| 34 |
+
def test_zipped_egg(self, target_dir):
|
| 35 |
+
shutil.copytree(
|
| 36 |
+
TESTS_DATA_DIR / 'my-test-package_zipped-egg',
|
| 37 |
+
target_dir,
|
| 38 |
+
dirs_exist_ok=True,
|
| 39 |
+
)
|
| 40 |
+
dists = pkg_resources.find_distributions(str(target_dir))
|
| 41 |
+
assert [dist.project_name for dist in dists] == ['my-test-package']
|
| 42 |
+
dists = pkg_resources.find_distributions(str(target_dir), only=True)
|
| 43 |
+
assert not list(dists)
|
| 44 |
+
|
| 45 |
+
def test_zipped_sdist_one_level_removed(self, target_dir):
|
| 46 |
+
shutil.copytree(
|
| 47 |
+
TESTS_DATA_DIR / 'my-test-package-zip', target_dir, dirs_exist_ok=True
|
| 48 |
+
)
|
| 49 |
+
dists = pkg_resources.find_distributions(
|
| 50 |
+
str(target_dir / "my-test-package.zip")
|
| 51 |
+
)
|
| 52 |
+
assert [dist.project_name for dist in dists] == ['my-test-package']
|
| 53 |
+
dists = pkg_resources.find_distributions(
|
| 54 |
+
str(target_dir / "my-test-package.zip"), only=True
|
| 55 |
+
)
|
| 56 |
+
assert not list(dists)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_integration_zope_interface.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import platform
|
| 2 |
+
from inspect import cleandoc
|
| 3 |
+
|
| 4 |
+
import jaraco.path
|
| 5 |
+
import pytest
|
| 6 |
+
|
| 7 |
+
pytestmark = pytest.mark.integration
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# For the sake of simplicity this test uses fixtures defined in
|
| 11 |
+
# `setuptools.test.fixtures`,
|
| 12 |
+
# and it also exercise conditions considered deprecated...
|
| 13 |
+
# So if needed this test can be deleted.
|
| 14 |
+
@pytest.mark.skipif(
|
| 15 |
+
platform.system() != "Linux",
|
| 16 |
+
reason="only demonstrated to fail on Linux in #4399",
|
| 17 |
+
)
|
| 18 |
+
def test_interop_pkg_resources_iter_entry_points(tmp_path, venv):
|
| 19 |
+
"""
|
| 20 |
+
Importing pkg_resources.iter_entry_points on console_scripts
|
| 21 |
+
seems to cause trouble with zope-interface, when deprecates installation method
|
| 22 |
+
is used. See #4399.
|
| 23 |
+
"""
|
| 24 |
+
project = {
|
| 25 |
+
"pkg": {
|
| 26 |
+
"foo.py": cleandoc(
|
| 27 |
+
"""
|
| 28 |
+
from pkg_resources import iter_entry_points
|
| 29 |
+
|
| 30 |
+
def bar():
|
| 31 |
+
print("Print me if you can")
|
| 32 |
+
"""
|
| 33 |
+
),
|
| 34 |
+
"setup.py": cleandoc(
|
| 35 |
+
"""
|
| 36 |
+
from setuptools import setup, find_packages
|
| 37 |
+
|
| 38 |
+
setup(
|
| 39 |
+
install_requires=["zope-interface==6.4.post2"],
|
| 40 |
+
entry_points={
|
| 41 |
+
"console_scripts": [
|
| 42 |
+
"foo=foo:bar",
|
| 43 |
+
],
|
| 44 |
+
},
|
| 45 |
+
)
|
| 46 |
+
"""
|
| 47 |
+
),
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
jaraco.path.build(project, prefix=tmp_path)
|
| 51 |
+
cmd = ["pip", "install", "-e", ".", "--no-use-pep517"]
|
| 52 |
+
venv.run(cmd, cwd=tmp_path / "pkg") # Needs this version of pkg_resources installed
|
| 53 |
+
out = venv.run(["foo"])
|
| 54 |
+
assert "Print me if you can" in out
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_markers.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from unittest import mock
|
| 2 |
+
|
| 3 |
+
from pkg_resources import evaluate_marker
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
@mock.patch('platform.python_version', return_value='2.7.10')
|
| 7 |
+
def test_ordering(python_version_mock):
|
| 8 |
+
assert evaluate_marker("python_full_version > '2.7.3'") is True
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_pkg_resources.py
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import builtins
|
| 4 |
+
import datetime
|
| 5 |
+
import inspect
|
| 6 |
+
import os
|
| 7 |
+
import plistlib
|
| 8 |
+
import stat
|
| 9 |
+
import subprocess
|
| 10 |
+
import sys
|
| 11 |
+
import tempfile
|
| 12 |
+
import zipfile
|
| 13 |
+
from unittest import mock
|
| 14 |
+
|
| 15 |
+
import pytest
|
| 16 |
+
|
| 17 |
+
import pkg_resources
|
| 18 |
+
from pkg_resources import DistInfoDistribution, Distribution, EggInfoDistribution
|
| 19 |
+
|
| 20 |
+
import distutils.command.install_egg_info
|
| 21 |
+
import distutils.dist
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class EggRemover(str):
|
| 25 |
+
def __call__(self):
|
| 26 |
+
if self in sys.path:
|
| 27 |
+
sys.path.remove(self)
|
| 28 |
+
if os.path.exists(self):
|
| 29 |
+
os.remove(self)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class TestZipProvider:
|
| 33 |
+
finalizers: list[EggRemover] = []
|
| 34 |
+
|
| 35 |
+
ref_time = datetime.datetime(2013, 5, 12, 13, 25, 0)
|
| 36 |
+
"A reference time for a file modification"
|
| 37 |
+
|
| 38 |
+
@classmethod
|
| 39 |
+
def setup_class(cls):
|
| 40 |
+
"create a zip egg and add it to sys.path"
|
| 41 |
+
egg = tempfile.NamedTemporaryFile(suffix='.egg', delete=False)
|
| 42 |
+
zip_egg = zipfile.ZipFile(egg, 'w')
|
| 43 |
+
zip_info = zipfile.ZipInfo()
|
| 44 |
+
zip_info.filename = 'mod.py'
|
| 45 |
+
zip_info.date_time = cls.ref_time.timetuple()
|
| 46 |
+
zip_egg.writestr(zip_info, 'x = 3\n')
|
| 47 |
+
zip_info = zipfile.ZipInfo()
|
| 48 |
+
zip_info.filename = 'data.dat'
|
| 49 |
+
zip_info.date_time = cls.ref_time.timetuple()
|
| 50 |
+
zip_egg.writestr(zip_info, 'hello, world!')
|
| 51 |
+
zip_info = zipfile.ZipInfo()
|
| 52 |
+
zip_info.filename = 'subdir/mod2.py'
|
| 53 |
+
zip_info.date_time = cls.ref_time.timetuple()
|
| 54 |
+
zip_egg.writestr(zip_info, 'x = 6\n')
|
| 55 |
+
zip_info = zipfile.ZipInfo()
|
| 56 |
+
zip_info.filename = 'subdir/data2.dat'
|
| 57 |
+
zip_info.date_time = cls.ref_time.timetuple()
|
| 58 |
+
zip_egg.writestr(zip_info, 'goodbye, world!')
|
| 59 |
+
zip_egg.close()
|
| 60 |
+
egg.close()
|
| 61 |
+
|
| 62 |
+
sys.path.append(egg.name)
|
| 63 |
+
subdir = os.path.join(egg.name, 'subdir')
|
| 64 |
+
sys.path.append(subdir)
|
| 65 |
+
cls.finalizers.append(EggRemover(subdir))
|
| 66 |
+
cls.finalizers.append(EggRemover(egg.name))
|
| 67 |
+
|
| 68 |
+
@classmethod
|
| 69 |
+
def teardown_class(cls):
|
| 70 |
+
for finalizer in cls.finalizers:
|
| 71 |
+
finalizer()
|
| 72 |
+
|
| 73 |
+
def test_resource_listdir(self):
|
| 74 |
+
import mod # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 75 |
+
|
| 76 |
+
zp = pkg_resources.ZipProvider(mod)
|
| 77 |
+
|
| 78 |
+
expected_root = ['data.dat', 'mod.py', 'subdir']
|
| 79 |
+
assert sorted(zp.resource_listdir('')) == expected_root
|
| 80 |
+
|
| 81 |
+
expected_subdir = ['data2.dat', 'mod2.py']
|
| 82 |
+
assert sorted(zp.resource_listdir('subdir')) == expected_subdir
|
| 83 |
+
assert sorted(zp.resource_listdir('subdir/')) == expected_subdir
|
| 84 |
+
|
| 85 |
+
assert zp.resource_listdir('nonexistent') == []
|
| 86 |
+
assert zp.resource_listdir('nonexistent/') == []
|
| 87 |
+
|
| 88 |
+
import mod2 # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 89 |
+
|
| 90 |
+
zp2 = pkg_resources.ZipProvider(mod2)
|
| 91 |
+
|
| 92 |
+
assert sorted(zp2.resource_listdir('')) == expected_subdir
|
| 93 |
+
|
| 94 |
+
assert zp2.resource_listdir('subdir') == []
|
| 95 |
+
assert zp2.resource_listdir('subdir/') == []
|
| 96 |
+
|
| 97 |
+
def test_resource_filename_rewrites_on_change(self):
|
| 98 |
+
"""
|
| 99 |
+
If a previous call to get_resource_filename has saved the file, but
|
| 100 |
+
the file has been subsequently mutated with different file of the
|
| 101 |
+
same size and modification time, it should not be overwritten on a
|
| 102 |
+
subsequent call to get_resource_filename.
|
| 103 |
+
"""
|
| 104 |
+
import mod # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 105 |
+
|
| 106 |
+
manager = pkg_resources.ResourceManager()
|
| 107 |
+
zp = pkg_resources.ZipProvider(mod)
|
| 108 |
+
filename = zp.get_resource_filename(manager, 'data.dat')
|
| 109 |
+
actual = datetime.datetime.fromtimestamp(os.stat(filename).st_mtime)
|
| 110 |
+
assert actual == self.ref_time
|
| 111 |
+
f = open(filename, 'w', encoding="utf-8")
|
| 112 |
+
f.write('hello, world?')
|
| 113 |
+
f.close()
|
| 114 |
+
ts = self.ref_time.timestamp()
|
| 115 |
+
os.utime(filename, (ts, ts))
|
| 116 |
+
filename = zp.get_resource_filename(manager, 'data.dat')
|
| 117 |
+
with open(filename, encoding="utf-8") as f:
|
| 118 |
+
assert f.read() == 'hello, world!'
|
| 119 |
+
manager.cleanup_resources()
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class TestResourceManager:
|
| 123 |
+
def test_get_cache_path(self):
|
| 124 |
+
mgr = pkg_resources.ResourceManager()
|
| 125 |
+
path = mgr.get_cache_path('foo')
|
| 126 |
+
type_ = str(type(path))
|
| 127 |
+
message = "Unexpected type from get_cache_path: " + type_
|
| 128 |
+
assert isinstance(path, str), message
|
| 129 |
+
|
| 130 |
+
def test_get_cache_path_race(self, tmpdir):
|
| 131 |
+
# Patch to os.path.isdir to create a race condition
|
| 132 |
+
def patched_isdir(dirname, unpatched_isdir=pkg_resources.isdir):
|
| 133 |
+
patched_isdir.dirnames.append(dirname)
|
| 134 |
+
|
| 135 |
+
was_dir = unpatched_isdir(dirname)
|
| 136 |
+
if not was_dir:
|
| 137 |
+
os.makedirs(dirname)
|
| 138 |
+
return was_dir
|
| 139 |
+
|
| 140 |
+
patched_isdir.dirnames = []
|
| 141 |
+
|
| 142 |
+
# Get a cache path with a "race condition"
|
| 143 |
+
mgr = pkg_resources.ResourceManager()
|
| 144 |
+
mgr.set_extraction_path(str(tmpdir))
|
| 145 |
+
|
| 146 |
+
archive_name = os.sep.join(('foo', 'bar', 'baz'))
|
| 147 |
+
with mock.patch.object(pkg_resources, 'isdir', new=patched_isdir):
|
| 148 |
+
mgr.get_cache_path(archive_name)
|
| 149 |
+
|
| 150 |
+
# Because this test relies on the implementation details of this
|
| 151 |
+
# function, these assertions are a sentinel to ensure that the
|
| 152 |
+
# test suite will not fail silently if the implementation changes.
|
| 153 |
+
called_dirnames = patched_isdir.dirnames
|
| 154 |
+
assert len(called_dirnames) == 2
|
| 155 |
+
assert called_dirnames[0].split(os.sep)[-2:] == ['foo', 'bar']
|
| 156 |
+
assert called_dirnames[1].split(os.sep)[-1:] == ['foo']
|
| 157 |
+
|
| 158 |
+
"""
|
| 159 |
+
Tests to ensure that pkg_resources runs independently from setuptools.
|
| 160 |
+
"""
|
| 161 |
+
|
| 162 |
+
def test_setuptools_not_imported(self):
|
| 163 |
+
"""
|
| 164 |
+
In a separate Python environment, import pkg_resources and assert
|
| 165 |
+
that action doesn't cause setuptools to be imported.
|
| 166 |
+
"""
|
| 167 |
+
lines = (
|
| 168 |
+
'import pkg_resources',
|
| 169 |
+
'import sys',
|
| 170 |
+
('assert "setuptools" not in sys.modules, "setuptools was imported"'),
|
| 171 |
+
)
|
| 172 |
+
cmd = [sys.executable, '-c', '; '.join(lines)]
|
| 173 |
+
subprocess.check_call(cmd)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def make_test_distribution(metadata_path, metadata):
|
| 177 |
+
"""
|
| 178 |
+
Make a test Distribution object, and return it.
|
| 179 |
+
|
| 180 |
+
:param metadata_path: the path to the metadata file that should be
|
| 181 |
+
created. This should be inside a distribution directory that should
|
| 182 |
+
also be created. For example, an argument value might end with
|
| 183 |
+
"<project>.dist-info/METADATA".
|
| 184 |
+
:param metadata: the desired contents of the metadata file, as bytes.
|
| 185 |
+
"""
|
| 186 |
+
dist_dir = os.path.dirname(metadata_path)
|
| 187 |
+
os.mkdir(dist_dir)
|
| 188 |
+
with open(metadata_path, 'wb') as f:
|
| 189 |
+
f.write(metadata)
|
| 190 |
+
dists = list(pkg_resources.distributions_from_metadata(dist_dir))
|
| 191 |
+
(dist,) = dists
|
| 192 |
+
|
| 193 |
+
return dist
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def test_get_metadata__bad_utf8(tmpdir):
|
| 197 |
+
"""
|
| 198 |
+
Test a metadata file with bytes that can't be decoded as utf-8.
|
| 199 |
+
"""
|
| 200 |
+
filename = 'METADATA'
|
| 201 |
+
# Convert the tmpdir LocalPath object to a string before joining.
|
| 202 |
+
metadata_path = os.path.join(str(tmpdir), 'foo.dist-info', filename)
|
| 203 |
+
# Encode a non-ascii string with the wrong encoding (not utf-8).
|
| 204 |
+
metadata = 'née'.encode('iso-8859-1')
|
| 205 |
+
dist = make_test_distribution(metadata_path, metadata=metadata)
|
| 206 |
+
|
| 207 |
+
with pytest.raises(UnicodeDecodeError) as excinfo:
|
| 208 |
+
dist.get_metadata(filename)
|
| 209 |
+
|
| 210 |
+
exc = excinfo.value
|
| 211 |
+
actual = str(exc)
|
| 212 |
+
expected = (
|
| 213 |
+
# The error message starts with "'utf-8' codec ..." However, the
|
| 214 |
+
# spelling of "utf-8" can vary (e.g. "utf8") so we don't include it
|
| 215 |
+
"codec can't decode byte 0xe9 in position 1: "
|
| 216 |
+
'invalid continuation byte in METADATA file at path: '
|
| 217 |
+
)
|
| 218 |
+
assert expected in actual, f'actual: {actual}'
|
| 219 |
+
assert actual.endswith(metadata_path), f'actual: {actual}'
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def make_distribution_no_version(tmpdir, basename):
|
| 223 |
+
"""
|
| 224 |
+
Create a distribution directory with no file containing the version.
|
| 225 |
+
"""
|
| 226 |
+
dist_dir = tmpdir / basename
|
| 227 |
+
dist_dir.ensure_dir()
|
| 228 |
+
# Make the directory non-empty so distributions_from_metadata()
|
| 229 |
+
# will detect it and yield it.
|
| 230 |
+
dist_dir.join('temp.txt').ensure()
|
| 231 |
+
|
| 232 |
+
dists = list(pkg_resources.distributions_from_metadata(dist_dir))
|
| 233 |
+
assert len(dists) == 1
|
| 234 |
+
(dist,) = dists
|
| 235 |
+
|
| 236 |
+
return dist, dist_dir
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
@pytest.mark.parametrize(
|
| 240 |
+
("suffix", "expected_filename", "expected_dist_type"),
|
| 241 |
+
[
|
| 242 |
+
('egg-info', 'PKG-INFO', EggInfoDistribution),
|
| 243 |
+
('dist-info', 'METADATA', DistInfoDistribution),
|
| 244 |
+
],
|
| 245 |
+
)
|
| 246 |
+
@pytest.mark.xfail(
|
| 247 |
+
sys.version_info[:2] == (3, 12) and sys.version_info.releaselevel != 'final',
|
| 248 |
+
reason="https://github.com/python/cpython/issues/103632",
|
| 249 |
+
)
|
| 250 |
+
def test_distribution_version_missing(
|
| 251 |
+
tmpdir, suffix, expected_filename, expected_dist_type
|
| 252 |
+
):
|
| 253 |
+
"""
|
| 254 |
+
Test Distribution.version when the "Version" header is missing.
|
| 255 |
+
"""
|
| 256 |
+
basename = f'foo.{suffix}'
|
| 257 |
+
dist, dist_dir = make_distribution_no_version(tmpdir, basename)
|
| 258 |
+
|
| 259 |
+
expected_text = (
|
| 260 |
+
f"Missing 'Version:' header and/or {expected_filename} file at path: "
|
| 261 |
+
)
|
| 262 |
+
metadata_path = os.path.join(dist_dir, expected_filename)
|
| 263 |
+
|
| 264 |
+
# Now check the exception raised when the "version" attribute is accessed.
|
| 265 |
+
with pytest.raises(ValueError) as excinfo:
|
| 266 |
+
dist.version
|
| 267 |
+
|
| 268 |
+
err = str(excinfo.value)
|
| 269 |
+
# Include a string expression after the assert so the full strings
|
| 270 |
+
# will be visible for inspection on failure.
|
| 271 |
+
assert expected_text in err, str((expected_text, err))
|
| 272 |
+
|
| 273 |
+
# Also check the args passed to the ValueError.
|
| 274 |
+
msg, dist = excinfo.value.args
|
| 275 |
+
assert expected_text in msg
|
| 276 |
+
# Check that the message portion contains the path.
|
| 277 |
+
assert metadata_path in msg, str((metadata_path, msg))
|
| 278 |
+
assert type(dist) is expected_dist_type
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
@pytest.mark.xfail(
|
| 282 |
+
sys.version_info[:2] == (3, 12) and sys.version_info.releaselevel != 'final',
|
| 283 |
+
reason="https://github.com/python/cpython/issues/103632",
|
| 284 |
+
)
|
| 285 |
+
def test_distribution_version_missing_undetected_path():
|
| 286 |
+
"""
|
| 287 |
+
Test Distribution.version when the "Version" header is missing and
|
| 288 |
+
the path can't be detected.
|
| 289 |
+
"""
|
| 290 |
+
# Create a Distribution object with no metadata argument, which results
|
| 291 |
+
# in an empty metadata provider.
|
| 292 |
+
dist = Distribution('/foo')
|
| 293 |
+
with pytest.raises(ValueError) as excinfo:
|
| 294 |
+
dist.version
|
| 295 |
+
|
| 296 |
+
msg, dist = excinfo.value.args
|
| 297 |
+
expected = (
|
| 298 |
+
"Missing 'Version:' header and/or PKG-INFO file at path: [could not detect]"
|
| 299 |
+
)
|
| 300 |
+
assert msg == expected
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
@pytest.mark.parametrize('only', [False, True])
|
| 304 |
+
def test_dist_info_is_not_dir(tmp_path, only):
|
| 305 |
+
"""Test path containing a file with dist-info extension."""
|
| 306 |
+
dist_info = tmp_path / 'foobar.dist-info'
|
| 307 |
+
dist_info.touch()
|
| 308 |
+
assert not pkg_resources.dist_factory(str(tmp_path), str(dist_info), only)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
def test_macos_vers_fallback(monkeypatch, tmp_path):
|
| 312 |
+
"""Regression test for pkg_resources._macos_vers"""
|
| 313 |
+
orig_open = builtins.open
|
| 314 |
+
|
| 315 |
+
# Pretend we need to use the plist file
|
| 316 |
+
monkeypatch.setattr('platform.mac_ver', mock.Mock(return_value=('', (), '')))
|
| 317 |
+
|
| 318 |
+
# Create fake content for the fake plist file
|
| 319 |
+
with open(tmp_path / 'fake.plist', 'wb') as fake_file:
|
| 320 |
+
plistlib.dump({"ProductVersion": "11.4"}, fake_file)
|
| 321 |
+
|
| 322 |
+
# Pretend the fake file exists
|
| 323 |
+
monkeypatch.setattr('os.path.exists', mock.Mock(return_value=True))
|
| 324 |
+
|
| 325 |
+
def fake_open(file, *args, **kwargs):
|
| 326 |
+
return orig_open(tmp_path / 'fake.plist', *args, **kwargs)
|
| 327 |
+
|
| 328 |
+
# Ensure that the _macos_vers works correctly
|
| 329 |
+
with mock.patch('builtins.open', mock.Mock(side_effect=fake_open)) as m:
|
| 330 |
+
pkg_resources._macos_vers.cache_clear()
|
| 331 |
+
assert pkg_resources._macos_vers() == ["11", "4"]
|
| 332 |
+
pkg_resources._macos_vers.cache_clear()
|
| 333 |
+
|
| 334 |
+
m.assert_called()
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
class TestDeepVersionLookupDistutils:
|
| 338 |
+
@pytest.fixture
|
| 339 |
+
def env(self, tmpdir):
|
| 340 |
+
"""
|
| 341 |
+
Create a package environment, similar to a virtualenv,
|
| 342 |
+
in which packages are installed.
|
| 343 |
+
"""
|
| 344 |
+
|
| 345 |
+
class Environment(str):
|
| 346 |
+
pass
|
| 347 |
+
|
| 348 |
+
env = Environment(tmpdir)
|
| 349 |
+
tmpdir.chmod(stat.S_IRWXU)
|
| 350 |
+
subs = 'home', 'lib', 'scripts', 'data', 'egg-base'
|
| 351 |
+
env.paths = dict((dirname, str(tmpdir / dirname)) for dirname in subs)
|
| 352 |
+
list(map(os.mkdir, env.paths.values()))
|
| 353 |
+
return env
|
| 354 |
+
|
| 355 |
+
def create_foo_pkg(self, env, version):
|
| 356 |
+
"""
|
| 357 |
+
Create a foo package installed (distutils-style) to env.paths['lib']
|
| 358 |
+
as version.
|
| 359 |
+
"""
|
| 360 |
+
ld = "This package has unicode metadata! ❄"
|
| 361 |
+
attrs = dict(name='foo', version=version, long_description=ld)
|
| 362 |
+
dist = distutils.dist.Distribution(attrs)
|
| 363 |
+
iei_cmd = distutils.command.install_egg_info.install_egg_info(dist)
|
| 364 |
+
iei_cmd.initialize_options()
|
| 365 |
+
iei_cmd.install_dir = env.paths['lib']
|
| 366 |
+
iei_cmd.finalize_options()
|
| 367 |
+
iei_cmd.run()
|
| 368 |
+
|
| 369 |
+
def test_version_resolved_from_egg_info(self, env):
|
| 370 |
+
version = '1.11.0.dev0+2329eae'
|
| 371 |
+
self.create_foo_pkg(env, version)
|
| 372 |
+
|
| 373 |
+
# this requirement parsing will raise a VersionConflict unless the
|
| 374 |
+
# .egg-info file is parsed (see #419 on BitBucket)
|
| 375 |
+
req = pkg_resources.Requirement.parse('foo>=1.9')
|
| 376 |
+
dist = pkg_resources.WorkingSet([env.paths['lib']]).find(req)
|
| 377 |
+
assert dist.version == version
|
| 378 |
+
|
| 379 |
+
@pytest.mark.parametrize(
|
| 380 |
+
("unnormalized", "normalized"),
|
| 381 |
+
[
|
| 382 |
+
('foo', 'foo'),
|
| 383 |
+
('foo/', 'foo'),
|
| 384 |
+
('foo/bar', 'foo/bar'),
|
| 385 |
+
('foo/bar/', 'foo/bar'),
|
| 386 |
+
],
|
| 387 |
+
)
|
| 388 |
+
def test_normalize_path_trailing_sep(self, unnormalized, normalized):
|
| 389 |
+
"""Ensure the trailing slash is cleaned for path comparison.
|
| 390 |
+
|
| 391 |
+
See pypa/setuptools#1519.
|
| 392 |
+
"""
|
| 393 |
+
result_from_unnormalized = pkg_resources.normalize_path(unnormalized)
|
| 394 |
+
result_from_normalized = pkg_resources.normalize_path(normalized)
|
| 395 |
+
assert result_from_unnormalized == result_from_normalized
|
| 396 |
+
|
| 397 |
+
@pytest.mark.skipif(
|
| 398 |
+
os.path.normcase('A') != os.path.normcase('a'),
|
| 399 |
+
reason='Testing case-insensitive filesystems.',
|
| 400 |
+
)
|
| 401 |
+
@pytest.mark.parametrize(
|
| 402 |
+
("unnormalized", "normalized"),
|
| 403 |
+
[
|
| 404 |
+
('MiXeD/CasE', 'mixed/case'),
|
| 405 |
+
],
|
| 406 |
+
)
|
| 407 |
+
def test_normalize_path_normcase(self, unnormalized, normalized):
|
| 408 |
+
"""Ensure mixed case is normalized on case-insensitive filesystems."""
|
| 409 |
+
result_from_unnormalized = pkg_resources.normalize_path(unnormalized)
|
| 410 |
+
result_from_normalized = pkg_resources.normalize_path(normalized)
|
| 411 |
+
assert result_from_unnormalized == result_from_normalized
|
| 412 |
+
|
| 413 |
+
@pytest.mark.skipif(
|
| 414 |
+
os.path.sep != '\\',
|
| 415 |
+
reason='Testing systems using backslashes as path separators.',
|
| 416 |
+
)
|
| 417 |
+
@pytest.mark.parametrize(
|
| 418 |
+
("unnormalized", "expected"),
|
| 419 |
+
[
|
| 420 |
+
('forward/slash', 'forward\\slash'),
|
| 421 |
+
('forward/slash/', 'forward\\slash'),
|
| 422 |
+
('backward\\slash\\', 'backward\\slash'),
|
| 423 |
+
],
|
| 424 |
+
)
|
| 425 |
+
def test_normalize_path_backslash_sep(self, unnormalized, expected):
|
| 426 |
+
"""Ensure path seps are cleaned on backslash path sep systems."""
|
| 427 |
+
result = pkg_resources.normalize_path(unnormalized)
|
| 428 |
+
assert result.endswith(expected)
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
class TestWorkdirRequire:
|
| 432 |
+
def fake_site_packages(self, tmp_path, monkeypatch, dist_files):
|
| 433 |
+
site_packages = tmp_path / "site-packages"
|
| 434 |
+
site_packages.mkdir()
|
| 435 |
+
for file, content in self.FILES.items():
|
| 436 |
+
path = site_packages / file
|
| 437 |
+
path.parent.mkdir(exist_ok=True, parents=True)
|
| 438 |
+
path.write_text(inspect.cleandoc(content), encoding="utf-8")
|
| 439 |
+
|
| 440 |
+
monkeypatch.setattr(sys, "path", [site_packages])
|
| 441 |
+
return os.fspath(site_packages)
|
| 442 |
+
|
| 443 |
+
FILES = {
|
| 444 |
+
"pkg1_mod-1.2.3.dist-info/METADATA": """
|
| 445 |
+
Metadata-Version: 2.4
|
| 446 |
+
Name: pkg1.mod
|
| 447 |
+
Version: 1.2.3
|
| 448 |
+
""",
|
| 449 |
+
"pkg2.mod-0.42.dist-info/METADATA": """
|
| 450 |
+
Metadata-Version: 2.1
|
| 451 |
+
Name: pkg2.mod
|
| 452 |
+
Version: 0.42
|
| 453 |
+
""",
|
| 454 |
+
"pkg3_mod.egg-info/PKG-INFO": """
|
| 455 |
+
Name: pkg3.mod
|
| 456 |
+
Version: 1.2.3.4
|
| 457 |
+
""",
|
| 458 |
+
"pkg4.mod.egg-info/PKG-INFO": """
|
| 459 |
+
Name: pkg4.mod
|
| 460 |
+
Version: 0.42.1
|
| 461 |
+
""",
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
@pytest.mark.parametrize(
|
| 465 |
+
("version", "requirement"),
|
| 466 |
+
[
|
| 467 |
+
("1.2.3", "pkg1.mod>=1"),
|
| 468 |
+
("0.42", "pkg2.mod>=0.4"),
|
| 469 |
+
("1.2.3.4", "pkg3.mod<=2"),
|
| 470 |
+
("0.42.1", "pkg4.mod>0.2,<1"),
|
| 471 |
+
],
|
| 472 |
+
)
|
| 473 |
+
def test_require_non_normalised_name(
|
| 474 |
+
self, tmp_path, monkeypatch, version, requirement
|
| 475 |
+
):
|
| 476 |
+
# https://github.com/pypa/setuptools/issues/4853
|
| 477 |
+
site_packages = self.fake_site_packages(tmp_path, monkeypatch, self.FILES)
|
| 478 |
+
ws = pkg_resources.WorkingSet([site_packages])
|
| 479 |
+
|
| 480 |
+
for req in [requirement, requirement.replace(".", "-")]:
|
| 481 |
+
[dist] = ws.require(req)
|
| 482 |
+
assert dist.version == version
|
| 483 |
+
assert os.path.samefile(
|
| 484 |
+
os.path.commonpath([dist.location, site_packages]), site_packages
|
| 485 |
+
)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_resources.py
ADDED
|
@@ -0,0 +1,869 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import itertools
|
| 2 |
+
import os
|
| 3 |
+
import platform
|
| 4 |
+
import string
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
import pytest
|
| 8 |
+
from packaging.specifiers import SpecifierSet
|
| 9 |
+
|
| 10 |
+
import pkg_resources
|
| 11 |
+
from pkg_resources import (
|
| 12 |
+
Distribution,
|
| 13 |
+
EntryPoint,
|
| 14 |
+
Requirement,
|
| 15 |
+
VersionConflict,
|
| 16 |
+
WorkingSet,
|
| 17 |
+
parse_requirements,
|
| 18 |
+
parse_version,
|
| 19 |
+
safe_name,
|
| 20 |
+
safe_version,
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# from Python 3.6 docs. Available from itertools on Python 3.10
|
| 25 |
+
def pairwise(iterable):
|
| 26 |
+
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
|
| 27 |
+
a, b = itertools.tee(iterable)
|
| 28 |
+
next(b, None)
|
| 29 |
+
return zip(a, b)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class Metadata(pkg_resources.EmptyProvider):
|
| 33 |
+
"""Mock object to return metadata as if from an on-disk distribution"""
|
| 34 |
+
|
| 35 |
+
def __init__(self, *pairs) -> None:
|
| 36 |
+
self.metadata = dict(pairs)
|
| 37 |
+
|
| 38 |
+
def has_metadata(self, name) -> bool:
|
| 39 |
+
return name in self.metadata
|
| 40 |
+
|
| 41 |
+
def get_metadata(self, name):
|
| 42 |
+
return self.metadata[name]
|
| 43 |
+
|
| 44 |
+
def get_metadata_lines(self, name):
|
| 45 |
+
return pkg_resources.yield_lines(self.get_metadata(name))
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
dist_from_fn = pkg_resources.Distribution.from_filename
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class TestDistro:
|
| 52 |
+
def testCollection(self):
|
| 53 |
+
# empty path should produce no distributions
|
| 54 |
+
ad = pkg_resources.Environment([], platform=None, python=None)
|
| 55 |
+
assert list(ad) == []
|
| 56 |
+
assert ad['FooPkg'] == []
|
| 57 |
+
ad.add(dist_from_fn("FooPkg-1.3_1.egg"))
|
| 58 |
+
ad.add(dist_from_fn("FooPkg-1.4-py2.4-win32.egg"))
|
| 59 |
+
ad.add(dist_from_fn("FooPkg-1.2-py2.4.egg"))
|
| 60 |
+
|
| 61 |
+
# Name is in there now
|
| 62 |
+
assert ad['FooPkg']
|
| 63 |
+
# But only 1 package
|
| 64 |
+
assert list(ad) == ['foopkg']
|
| 65 |
+
|
| 66 |
+
# Distributions sort by version
|
| 67 |
+
expected = ['1.4', '1.3-1', '1.2']
|
| 68 |
+
assert [dist.version for dist in ad['FooPkg']] == expected
|
| 69 |
+
|
| 70 |
+
# Removing a distribution leaves sequence alone
|
| 71 |
+
ad.remove(ad['FooPkg'][1])
|
| 72 |
+
assert [dist.version for dist in ad['FooPkg']] == ['1.4', '1.2']
|
| 73 |
+
|
| 74 |
+
# And inserting adds them in order
|
| 75 |
+
ad.add(dist_from_fn("FooPkg-1.9.egg"))
|
| 76 |
+
assert [dist.version for dist in ad['FooPkg']] == ['1.9', '1.4', '1.2']
|
| 77 |
+
|
| 78 |
+
ws = WorkingSet([])
|
| 79 |
+
foo12 = dist_from_fn("FooPkg-1.2-py2.4.egg")
|
| 80 |
+
foo14 = dist_from_fn("FooPkg-1.4-py2.4-win32.egg")
|
| 81 |
+
(req,) = parse_requirements("FooPkg>=1.3")
|
| 82 |
+
|
| 83 |
+
# Nominal case: no distros on path, should yield all applicable
|
| 84 |
+
assert ad.best_match(req, ws).version == '1.9'
|
| 85 |
+
# If a matching distro is already installed, should return only that
|
| 86 |
+
ws.add(foo14)
|
| 87 |
+
assert ad.best_match(req, ws).version == '1.4'
|
| 88 |
+
|
| 89 |
+
# If the first matching distro is unsuitable, it's a version conflict
|
| 90 |
+
ws = WorkingSet([])
|
| 91 |
+
ws.add(foo12)
|
| 92 |
+
ws.add(foo14)
|
| 93 |
+
with pytest.raises(VersionConflict):
|
| 94 |
+
ad.best_match(req, ws)
|
| 95 |
+
|
| 96 |
+
# If more than one match on the path, the first one takes precedence
|
| 97 |
+
ws = WorkingSet([])
|
| 98 |
+
ws.add(foo14)
|
| 99 |
+
ws.add(foo12)
|
| 100 |
+
ws.add(foo14)
|
| 101 |
+
assert ad.best_match(req, ws).version == '1.4'
|
| 102 |
+
|
| 103 |
+
def checkFooPkg(self, d):
|
| 104 |
+
assert d.project_name == "FooPkg"
|
| 105 |
+
assert d.key == "foopkg"
|
| 106 |
+
assert d.version == "1.3.post1"
|
| 107 |
+
assert d.py_version == "2.4"
|
| 108 |
+
assert d.platform == "win32"
|
| 109 |
+
assert d.parsed_version == parse_version("1.3-1")
|
| 110 |
+
|
| 111 |
+
def testDistroBasics(self):
|
| 112 |
+
d = Distribution(
|
| 113 |
+
"/some/path",
|
| 114 |
+
project_name="FooPkg",
|
| 115 |
+
version="1.3-1",
|
| 116 |
+
py_version="2.4",
|
| 117 |
+
platform="win32",
|
| 118 |
+
)
|
| 119 |
+
self.checkFooPkg(d)
|
| 120 |
+
|
| 121 |
+
d = Distribution("/some/path")
|
| 122 |
+
assert d.py_version == f'{sys.version_info.major}.{sys.version_info.minor}'
|
| 123 |
+
assert d.platform is None
|
| 124 |
+
|
| 125 |
+
def testDistroParse(self):
|
| 126 |
+
d = dist_from_fn("FooPkg-1.3.post1-py2.4-win32.egg")
|
| 127 |
+
self.checkFooPkg(d)
|
| 128 |
+
d = dist_from_fn("FooPkg-1.3.post1-py2.4-win32.egg-info")
|
| 129 |
+
self.checkFooPkg(d)
|
| 130 |
+
|
| 131 |
+
def testDistroMetadata(self):
|
| 132 |
+
d = Distribution(
|
| 133 |
+
"/some/path",
|
| 134 |
+
project_name="FooPkg",
|
| 135 |
+
py_version="2.4",
|
| 136 |
+
platform="win32",
|
| 137 |
+
metadata=Metadata(('PKG-INFO', "Metadata-Version: 1.0\nVersion: 1.3-1\n")),
|
| 138 |
+
)
|
| 139 |
+
self.checkFooPkg(d)
|
| 140 |
+
|
| 141 |
+
def distRequires(self, txt):
|
| 142 |
+
return Distribution("/foo", metadata=Metadata(('depends.txt', txt)))
|
| 143 |
+
|
| 144 |
+
def checkRequires(self, dist, txt, extras=()):
|
| 145 |
+
assert list(dist.requires(extras)) == list(parse_requirements(txt))
|
| 146 |
+
|
| 147 |
+
def testDistroDependsSimple(self):
|
| 148 |
+
for v in "Twisted>=1.5", "Twisted>=1.5\nZConfig>=2.0":
|
| 149 |
+
self.checkRequires(self.distRequires(v), v)
|
| 150 |
+
|
| 151 |
+
needs_object_dir = pytest.mark.skipif(
|
| 152 |
+
not hasattr(object, '__dir__'),
|
| 153 |
+
reason='object.__dir__ necessary for self.__dir__ implementation',
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
def test_distribution_dir(self):
|
| 157 |
+
d = pkg_resources.Distribution()
|
| 158 |
+
dir(d)
|
| 159 |
+
|
| 160 |
+
@needs_object_dir
|
| 161 |
+
def test_distribution_dir_includes_provider_dir(self):
|
| 162 |
+
d = pkg_resources.Distribution()
|
| 163 |
+
before = d.__dir__()
|
| 164 |
+
assert 'test_attr' not in before
|
| 165 |
+
d._provider.test_attr = None
|
| 166 |
+
after = d.__dir__()
|
| 167 |
+
assert len(after) == len(before) + 1
|
| 168 |
+
assert 'test_attr' in after
|
| 169 |
+
|
| 170 |
+
@needs_object_dir
|
| 171 |
+
def test_distribution_dir_ignores_provider_dir_leading_underscore(self):
|
| 172 |
+
d = pkg_resources.Distribution()
|
| 173 |
+
before = d.__dir__()
|
| 174 |
+
assert '_test_attr' not in before
|
| 175 |
+
d._provider._test_attr = None
|
| 176 |
+
after = d.__dir__()
|
| 177 |
+
assert len(after) == len(before)
|
| 178 |
+
assert '_test_attr' not in after
|
| 179 |
+
|
| 180 |
+
def testResolve(self):
|
| 181 |
+
ad = pkg_resources.Environment([])
|
| 182 |
+
ws = WorkingSet([])
|
| 183 |
+
# Resolving no requirements -> nothing to install
|
| 184 |
+
assert list(ws.resolve([], ad)) == []
|
| 185 |
+
# Request something not in the collection -> DistributionNotFound
|
| 186 |
+
with pytest.raises(pkg_resources.DistributionNotFound):
|
| 187 |
+
ws.resolve(parse_requirements("Foo"), ad)
|
| 188 |
+
|
| 189 |
+
Foo = Distribution.from_filename(
|
| 190 |
+
"/foo_dir/Foo-1.2.egg",
|
| 191 |
+
metadata=Metadata(('depends.txt', "[bar]\nBaz>=2.0")),
|
| 192 |
+
)
|
| 193 |
+
ad.add(Foo)
|
| 194 |
+
ad.add(Distribution.from_filename("Foo-0.9.egg"))
|
| 195 |
+
|
| 196 |
+
# Request thing(s) that are available -> list to activate
|
| 197 |
+
for i in range(3):
|
| 198 |
+
targets = list(ws.resolve(parse_requirements("Foo"), ad))
|
| 199 |
+
assert targets == [Foo]
|
| 200 |
+
list(map(ws.add, targets))
|
| 201 |
+
with pytest.raises(VersionConflict):
|
| 202 |
+
ws.resolve(parse_requirements("Foo==0.9"), ad)
|
| 203 |
+
ws = WorkingSet([]) # reset
|
| 204 |
+
|
| 205 |
+
# Request an extra that causes an unresolved dependency for "Baz"
|
| 206 |
+
with pytest.raises(pkg_resources.DistributionNotFound):
|
| 207 |
+
ws.resolve(parse_requirements("Foo[bar]"), ad)
|
| 208 |
+
Baz = Distribution.from_filename(
|
| 209 |
+
"/foo_dir/Baz-2.1.egg", metadata=Metadata(('depends.txt', "Foo"))
|
| 210 |
+
)
|
| 211 |
+
ad.add(Baz)
|
| 212 |
+
|
| 213 |
+
# Activation list now includes resolved dependency
|
| 214 |
+
assert list(ws.resolve(parse_requirements("Foo[bar]"), ad)) == [Foo, Baz]
|
| 215 |
+
# Requests for conflicting versions produce VersionConflict
|
| 216 |
+
with pytest.raises(VersionConflict) as vc:
|
| 217 |
+
ws.resolve(parse_requirements("Foo==1.2\nFoo!=1.2"), ad)
|
| 218 |
+
|
| 219 |
+
msg = 'Foo 0.9 is installed but Foo==1.2 is required'
|
| 220 |
+
assert vc.value.report() == msg
|
| 221 |
+
|
| 222 |
+
def test_environment_marker_evaluation_negative(self):
|
| 223 |
+
"""Environment markers are evaluated at resolution time."""
|
| 224 |
+
ad = pkg_resources.Environment([])
|
| 225 |
+
ws = WorkingSet([])
|
| 226 |
+
res = ws.resolve(parse_requirements("Foo;python_version<'2'"), ad)
|
| 227 |
+
assert list(res) == []
|
| 228 |
+
|
| 229 |
+
def test_environment_marker_evaluation_positive(self):
|
| 230 |
+
ad = pkg_resources.Environment([])
|
| 231 |
+
ws = WorkingSet([])
|
| 232 |
+
Foo = Distribution.from_filename("/foo_dir/Foo-1.2.dist-info")
|
| 233 |
+
ad.add(Foo)
|
| 234 |
+
res = ws.resolve(parse_requirements("Foo;python_version>='2'"), ad)
|
| 235 |
+
assert list(res) == [Foo]
|
| 236 |
+
|
| 237 |
+
def test_environment_marker_evaluation_called(self):
|
| 238 |
+
"""
|
| 239 |
+
If one package foo requires bar without any extras,
|
| 240 |
+
markers should pass for bar without extras.
|
| 241 |
+
"""
|
| 242 |
+
(parent_req,) = parse_requirements("foo")
|
| 243 |
+
(req,) = parse_requirements("bar;python_version>='2'")
|
| 244 |
+
req_extras = pkg_resources._ReqExtras({req: parent_req.extras})
|
| 245 |
+
assert req_extras.markers_pass(req)
|
| 246 |
+
|
| 247 |
+
(parent_req,) = parse_requirements("foo[]")
|
| 248 |
+
(req,) = parse_requirements("bar;python_version>='2'")
|
| 249 |
+
req_extras = pkg_resources._ReqExtras({req: parent_req.extras})
|
| 250 |
+
assert req_extras.markers_pass(req)
|
| 251 |
+
|
| 252 |
+
def test_marker_evaluation_with_extras(self):
|
| 253 |
+
"""Extras are also evaluated as markers at resolution time."""
|
| 254 |
+
ad = pkg_resources.Environment([])
|
| 255 |
+
ws = WorkingSet([])
|
| 256 |
+
Foo = Distribution.from_filename(
|
| 257 |
+
"/foo_dir/Foo-1.2.dist-info",
|
| 258 |
+
metadata=Metadata((
|
| 259 |
+
"METADATA",
|
| 260 |
+
"Provides-Extra: baz\nRequires-Dist: quux; extra=='baz'",
|
| 261 |
+
)),
|
| 262 |
+
)
|
| 263 |
+
ad.add(Foo)
|
| 264 |
+
assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo]
|
| 265 |
+
quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info")
|
| 266 |
+
ad.add(quux)
|
| 267 |
+
res = list(ws.resolve(parse_requirements("Foo[baz]"), ad))
|
| 268 |
+
assert res == [Foo, quux]
|
| 269 |
+
|
| 270 |
+
def test_marker_evaluation_with_extras_normlized(self):
|
| 271 |
+
"""Extras are also evaluated as markers at resolution time."""
|
| 272 |
+
ad = pkg_resources.Environment([])
|
| 273 |
+
ws = WorkingSet([])
|
| 274 |
+
Foo = Distribution.from_filename(
|
| 275 |
+
"/foo_dir/Foo-1.2.dist-info",
|
| 276 |
+
metadata=Metadata((
|
| 277 |
+
"METADATA",
|
| 278 |
+
"Provides-Extra: baz-lightyear\n"
|
| 279 |
+
"Requires-Dist: quux; extra=='baz-lightyear'",
|
| 280 |
+
)),
|
| 281 |
+
)
|
| 282 |
+
ad.add(Foo)
|
| 283 |
+
assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo]
|
| 284 |
+
quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info")
|
| 285 |
+
ad.add(quux)
|
| 286 |
+
res = list(ws.resolve(parse_requirements("Foo[baz-lightyear]"), ad))
|
| 287 |
+
assert res == [Foo, quux]
|
| 288 |
+
|
| 289 |
+
def test_marker_evaluation_with_multiple_extras(self):
|
| 290 |
+
ad = pkg_resources.Environment([])
|
| 291 |
+
ws = WorkingSet([])
|
| 292 |
+
Foo = Distribution.from_filename(
|
| 293 |
+
"/foo_dir/Foo-1.2.dist-info",
|
| 294 |
+
metadata=Metadata((
|
| 295 |
+
"METADATA",
|
| 296 |
+
"Provides-Extra: baz\n"
|
| 297 |
+
"Requires-Dist: quux; extra=='baz'\n"
|
| 298 |
+
"Provides-Extra: bar\n"
|
| 299 |
+
"Requires-Dist: fred; extra=='bar'\n",
|
| 300 |
+
)),
|
| 301 |
+
)
|
| 302 |
+
ad.add(Foo)
|
| 303 |
+
quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info")
|
| 304 |
+
ad.add(quux)
|
| 305 |
+
fred = Distribution.from_filename("/foo_dir/fred-0.1.dist-info")
|
| 306 |
+
ad.add(fred)
|
| 307 |
+
res = list(ws.resolve(parse_requirements("Foo[baz,bar]"), ad))
|
| 308 |
+
assert sorted(res) == [fred, quux, Foo]
|
| 309 |
+
|
| 310 |
+
def test_marker_evaluation_with_extras_loop(self):
|
| 311 |
+
ad = pkg_resources.Environment([])
|
| 312 |
+
ws = WorkingSet([])
|
| 313 |
+
a = Distribution.from_filename(
|
| 314 |
+
"/foo_dir/a-0.2.dist-info",
|
| 315 |
+
metadata=Metadata(("METADATA", "Requires-Dist: c[a]")),
|
| 316 |
+
)
|
| 317 |
+
b = Distribution.from_filename(
|
| 318 |
+
"/foo_dir/b-0.3.dist-info",
|
| 319 |
+
metadata=Metadata(("METADATA", "Requires-Dist: c[b]")),
|
| 320 |
+
)
|
| 321 |
+
c = Distribution.from_filename(
|
| 322 |
+
"/foo_dir/c-1.0.dist-info",
|
| 323 |
+
metadata=Metadata((
|
| 324 |
+
"METADATA",
|
| 325 |
+
"Provides-Extra: a\n"
|
| 326 |
+
"Requires-Dist: b;extra=='a'\n"
|
| 327 |
+
"Provides-Extra: b\n"
|
| 328 |
+
"Requires-Dist: foo;extra=='b'",
|
| 329 |
+
)),
|
| 330 |
+
)
|
| 331 |
+
foo = Distribution.from_filename("/foo_dir/foo-0.1.dist-info")
|
| 332 |
+
for dist in (a, b, c, foo):
|
| 333 |
+
ad.add(dist)
|
| 334 |
+
res = list(ws.resolve(parse_requirements("a"), ad))
|
| 335 |
+
assert res == [a, c, b, foo]
|
| 336 |
+
|
| 337 |
+
@pytest.mark.xfail(
|
| 338 |
+
sys.version_info[:2] == (3, 12) and sys.version_info.releaselevel != 'final',
|
| 339 |
+
reason="https://github.com/python/cpython/issues/103632",
|
| 340 |
+
)
|
| 341 |
+
def testDistroDependsOptions(self):
|
| 342 |
+
d = self.distRequires(
|
| 343 |
+
"""
|
| 344 |
+
Twisted>=1.5
|
| 345 |
+
[docgen]
|
| 346 |
+
ZConfig>=2.0
|
| 347 |
+
docutils>=0.3
|
| 348 |
+
[fastcgi]
|
| 349 |
+
fcgiapp>=0.1"""
|
| 350 |
+
)
|
| 351 |
+
self.checkRequires(d, "Twisted>=1.5")
|
| 352 |
+
self.checkRequires(
|
| 353 |
+
d, "Twisted>=1.5 ZConfig>=2.0 docutils>=0.3".split(), ["docgen"]
|
| 354 |
+
)
|
| 355 |
+
self.checkRequires(d, "Twisted>=1.5 fcgiapp>=0.1".split(), ["fastcgi"])
|
| 356 |
+
self.checkRequires(
|
| 357 |
+
d,
|
| 358 |
+
"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3 fcgiapp>=0.1".split(),
|
| 359 |
+
["docgen", "fastcgi"],
|
| 360 |
+
)
|
| 361 |
+
self.checkRequires(
|
| 362 |
+
d,
|
| 363 |
+
"Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3".split(),
|
| 364 |
+
["fastcgi", "docgen"],
|
| 365 |
+
)
|
| 366 |
+
with pytest.raises(pkg_resources.UnknownExtra):
|
| 367 |
+
d.requires(["foo"])
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
class TestWorkingSet:
|
| 371 |
+
def test_find_conflicting(self):
|
| 372 |
+
ws = WorkingSet([])
|
| 373 |
+
Foo = Distribution.from_filename("/foo_dir/Foo-1.2.egg")
|
| 374 |
+
ws.add(Foo)
|
| 375 |
+
|
| 376 |
+
# create a requirement that conflicts with Foo 1.2
|
| 377 |
+
req = next(parse_requirements("Foo<1.2"))
|
| 378 |
+
|
| 379 |
+
with pytest.raises(VersionConflict) as vc:
|
| 380 |
+
ws.find(req)
|
| 381 |
+
|
| 382 |
+
msg = 'Foo 1.2 is installed but Foo<1.2 is required'
|
| 383 |
+
assert vc.value.report() == msg
|
| 384 |
+
|
| 385 |
+
def test_resolve_conflicts_with_prior(self):
|
| 386 |
+
"""
|
| 387 |
+
A ContextualVersionConflict should be raised when a requirement
|
| 388 |
+
conflicts with a prior requirement for a different package.
|
| 389 |
+
"""
|
| 390 |
+
# Create installation where Foo depends on Baz 1.0 and Bar depends on
|
| 391 |
+
# Baz 2.0.
|
| 392 |
+
ws = WorkingSet([])
|
| 393 |
+
md = Metadata(('depends.txt', "Baz==1.0"))
|
| 394 |
+
Foo = Distribution.from_filename("/foo_dir/Foo-1.0.egg", metadata=md)
|
| 395 |
+
ws.add(Foo)
|
| 396 |
+
md = Metadata(('depends.txt', "Baz==2.0"))
|
| 397 |
+
Bar = Distribution.from_filename("/foo_dir/Bar-1.0.egg", metadata=md)
|
| 398 |
+
ws.add(Bar)
|
| 399 |
+
Baz = Distribution.from_filename("/foo_dir/Baz-1.0.egg")
|
| 400 |
+
ws.add(Baz)
|
| 401 |
+
Baz = Distribution.from_filename("/foo_dir/Baz-2.0.egg")
|
| 402 |
+
ws.add(Baz)
|
| 403 |
+
|
| 404 |
+
with pytest.raises(VersionConflict) as vc:
|
| 405 |
+
ws.resolve(parse_requirements("Foo\nBar\n"))
|
| 406 |
+
|
| 407 |
+
msg = "Baz 1.0 is installed but Baz==2.0 is required by "
|
| 408 |
+
msg += repr(set(['Bar']))
|
| 409 |
+
assert vc.value.report() == msg
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
class TestEntryPoints:
|
| 413 |
+
def assertfields(self, ep):
|
| 414 |
+
assert ep.name == "foo"
|
| 415 |
+
assert ep.module_name == "pkg_resources.tests.test_resources"
|
| 416 |
+
assert ep.attrs == ("TestEntryPoints",)
|
| 417 |
+
assert ep.extras == ("x",)
|
| 418 |
+
assert ep.load() is TestEntryPoints
|
| 419 |
+
expect = "foo = pkg_resources.tests.test_resources:TestEntryPoints [x]"
|
| 420 |
+
assert str(ep) == expect
|
| 421 |
+
|
| 422 |
+
def setup_method(self, method):
|
| 423 |
+
self.dist = Distribution.from_filename(
|
| 424 |
+
"FooPkg-1.2-py2.4.egg", metadata=Metadata(('requires.txt', '[x]'))
|
| 425 |
+
)
|
| 426 |
+
|
| 427 |
+
def testBasics(self):
|
| 428 |
+
ep = EntryPoint(
|
| 429 |
+
"foo",
|
| 430 |
+
"pkg_resources.tests.test_resources",
|
| 431 |
+
["TestEntryPoints"],
|
| 432 |
+
["x"],
|
| 433 |
+
self.dist,
|
| 434 |
+
)
|
| 435 |
+
self.assertfields(ep)
|
| 436 |
+
|
| 437 |
+
def testParse(self):
|
| 438 |
+
s = "foo = pkg_resources.tests.test_resources:TestEntryPoints [x]"
|
| 439 |
+
ep = EntryPoint.parse(s, self.dist)
|
| 440 |
+
self.assertfields(ep)
|
| 441 |
+
|
| 442 |
+
ep = EntryPoint.parse("bar baz= spammity[PING]")
|
| 443 |
+
assert ep.name == "bar baz"
|
| 444 |
+
assert ep.module_name == "spammity"
|
| 445 |
+
assert ep.attrs == ()
|
| 446 |
+
assert ep.extras == ("ping",)
|
| 447 |
+
|
| 448 |
+
ep = EntryPoint.parse(" fizzly = wocka:foo")
|
| 449 |
+
assert ep.name == "fizzly"
|
| 450 |
+
assert ep.module_name == "wocka"
|
| 451 |
+
assert ep.attrs == ("foo",)
|
| 452 |
+
assert ep.extras == ()
|
| 453 |
+
|
| 454 |
+
# plus in the name
|
| 455 |
+
spec = "html+mako = mako.ext.pygmentplugin:MakoHtmlLexer"
|
| 456 |
+
ep = EntryPoint.parse(spec)
|
| 457 |
+
assert ep.name == 'html+mako'
|
| 458 |
+
|
| 459 |
+
reject_specs = "foo", "x=a:b:c", "q=x/na", "fez=pish:tush-z", "x=f[a]>2"
|
| 460 |
+
|
| 461 |
+
@pytest.mark.parametrize("reject_spec", reject_specs)
|
| 462 |
+
def test_reject_spec(self, reject_spec):
|
| 463 |
+
with pytest.raises(ValueError):
|
| 464 |
+
EntryPoint.parse(reject_spec)
|
| 465 |
+
|
| 466 |
+
def test_printable_name(self):
|
| 467 |
+
"""
|
| 468 |
+
Allow any printable character in the name.
|
| 469 |
+
"""
|
| 470 |
+
# Create a name with all printable characters; strip the whitespace.
|
| 471 |
+
name = string.printable.strip()
|
| 472 |
+
spec = "{name} = module:attr".format(**locals())
|
| 473 |
+
ep = EntryPoint.parse(spec)
|
| 474 |
+
assert ep.name == name
|
| 475 |
+
|
| 476 |
+
def checkSubMap(self, m):
|
| 477 |
+
assert len(m) == len(self.submap_expect)
|
| 478 |
+
for key, ep in self.submap_expect.items():
|
| 479 |
+
assert m.get(key).name == ep.name
|
| 480 |
+
assert m.get(key).module_name == ep.module_name
|
| 481 |
+
assert sorted(m.get(key).attrs) == sorted(ep.attrs)
|
| 482 |
+
assert sorted(m.get(key).extras) == sorted(ep.extras)
|
| 483 |
+
|
| 484 |
+
submap_expect = dict(
|
| 485 |
+
feature1=EntryPoint('feature1', 'somemodule', ['somefunction']),
|
| 486 |
+
feature2=EntryPoint(
|
| 487 |
+
'feature2', 'another.module', ['SomeClass'], ['extra1', 'extra2']
|
| 488 |
+
),
|
| 489 |
+
feature3=EntryPoint('feature3', 'this.module', extras=['something']),
|
| 490 |
+
)
|
| 491 |
+
submap_str = """
|
| 492 |
+
# define features for blah blah
|
| 493 |
+
feature1 = somemodule:somefunction
|
| 494 |
+
feature2 = another.module:SomeClass [extra1,extra2]
|
| 495 |
+
feature3 = this.module [something]
|
| 496 |
+
"""
|
| 497 |
+
|
| 498 |
+
def testParseList(self):
|
| 499 |
+
self.checkSubMap(EntryPoint.parse_group("xyz", self.submap_str))
|
| 500 |
+
with pytest.raises(ValueError):
|
| 501 |
+
EntryPoint.parse_group("x a", "foo=bar")
|
| 502 |
+
with pytest.raises(ValueError):
|
| 503 |
+
EntryPoint.parse_group("x", ["foo=baz", "foo=bar"])
|
| 504 |
+
|
| 505 |
+
def testParseMap(self):
|
| 506 |
+
m = EntryPoint.parse_map({'xyz': self.submap_str})
|
| 507 |
+
self.checkSubMap(m['xyz'])
|
| 508 |
+
assert list(m.keys()) == ['xyz']
|
| 509 |
+
m = EntryPoint.parse_map("[xyz]\n" + self.submap_str)
|
| 510 |
+
self.checkSubMap(m['xyz'])
|
| 511 |
+
assert list(m.keys()) == ['xyz']
|
| 512 |
+
with pytest.raises(ValueError):
|
| 513 |
+
EntryPoint.parse_map(["[xyz]", "[xyz]"])
|
| 514 |
+
with pytest.raises(ValueError):
|
| 515 |
+
EntryPoint.parse_map(self.submap_str)
|
| 516 |
+
|
| 517 |
+
def testDeprecationWarnings(self):
|
| 518 |
+
ep = EntryPoint(
|
| 519 |
+
"foo", "pkg_resources.tests.test_resources", ["TestEntryPoints"], ["x"]
|
| 520 |
+
)
|
| 521 |
+
with pytest.warns(pkg_resources.PkgResourcesDeprecationWarning):
|
| 522 |
+
ep.load(require=False)
|
| 523 |
+
|
| 524 |
+
|
| 525 |
+
class TestRequirements:
|
| 526 |
+
def testBasics(self):
|
| 527 |
+
r = Requirement.parse("Twisted>=1.2")
|
| 528 |
+
assert str(r) == "Twisted>=1.2"
|
| 529 |
+
assert repr(r) == "Requirement.parse('Twisted>=1.2')"
|
| 530 |
+
assert r == Requirement("Twisted>=1.2")
|
| 531 |
+
assert r == Requirement("twisTed>=1.2")
|
| 532 |
+
assert r != Requirement("Twisted>=2.0")
|
| 533 |
+
assert r != Requirement("Zope>=1.2")
|
| 534 |
+
assert r != Requirement("Zope>=3.0")
|
| 535 |
+
assert r != Requirement("Twisted[extras]>=1.2")
|
| 536 |
+
|
| 537 |
+
def testOrdering(self):
|
| 538 |
+
r1 = Requirement("Twisted==1.2c1,>=1.2")
|
| 539 |
+
r2 = Requirement("Twisted>=1.2,==1.2c1")
|
| 540 |
+
assert r1 == r2
|
| 541 |
+
assert str(r1) == str(r2)
|
| 542 |
+
assert str(r2) == "Twisted==1.2c1,>=1.2"
|
| 543 |
+
assert Requirement("Twisted") != Requirement(
|
| 544 |
+
"Twisted @ https://localhost/twisted.zip"
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
def testBasicContains(self):
|
| 548 |
+
r = Requirement("Twisted>=1.2")
|
| 549 |
+
foo_dist = Distribution.from_filename("FooPkg-1.3_1.egg")
|
| 550 |
+
twist11 = Distribution.from_filename("Twisted-1.1.egg")
|
| 551 |
+
twist12 = Distribution.from_filename("Twisted-1.2.egg")
|
| 552 |
+
assert parse_version('1.2') in r
|
| 553 |
+
assert parse_version('1.1') not in r
|
| 554 |
+
assert '1.2' in r
|
| 555 |
+
assert '1.1' not in r
|
| 556 |
+
assert foo_dist not in r
|
| 557 |
+
assert twist11 not in r
|
| 558 |
+
assert twist12 in r
|
| 559 |
+
|
| 560 |
+
def testOptionsAndHashing(self):
|
| 561 |
+
r1 = Requirement.parse("Twisted[foo,bar]>=1.2")
|
| 562 |
+
r2 = Requirement.parse("Twisted[bar,FOO]>=1.2")
|
| 563 |
+
assert r1 == r2
|
| 564 |
+
assert set(r1.extras) == set(("foo", "bar"))
|
| 565 |
+
assert set(r2.extras) == set(("foo", "bar"))
|
| 566 |
+
assert hash(r1) == hash(r2)
|
| 567 |
+
assert hash(r1) == hash((
|
| 568 |
+
"twisted",
|
| 569 |
+
None,
|
| 570 |
+
SpecifierSet(">=1.2"),
|
| 571 |
+
frozenset(["foo", "bar"]),
|
| 572 |
+
None,
|
| 573 |
+
))
|
| 574 |
+
assert hash(
|
| 575 |
+
Requirement.parse("Twisted @ https://localhost/twisted.zip")
|
| 576 |
+
) == hash((
|
| 577 |
+
"twisted",
|
| 578 |
+
"https://localhost/twisted.zip",
|
| 579 |
+
SpecifierSet(),
|
| 580 |
+
frozenset(),
|
| 581 |
+
None,
|
| 582 |
+
))
|
| 583 |
+
|
| 584 |
+
def testVersionEquality(self):
|
| 585 |
+
r1 = Requirement.parse("foo==0.3a2")
|
| 586 |
+
r2 = Requirement.parse("foo!=0.3a4")
|
| 587 |
+
d = Distribution.from_filename
|
| 588 |
+
|
| 589 |
+
assert d("foo-0.3a4.egg") not in r1
|
| 590 |
+
assert d("foo-0.3a1.egg") not in r1
|
| 591 |
+
assert d("foo-0.3a4.egg") not in r2
|
| 592 |
+
|
| 593 |
+
assert d("foo-0.3a2.egg") in r1
|
| 594 |
+
assert d("foo-0.3a2.egg") in r2
|
| 595 |
+
assert d("foo-0.3a3.egg") in r2
|
| 596 |
+
assert d("foo-0.3a5.egg") in r2
|
| 597 |
+
|
| 598 |
+
def testSetuptoolsProjectName(self):
|
| 599 |
+
"""
|
| 600 |
+
The setuptools project should implement the setuptools package.
|
| 601 |
+
"""
|
| 602 |
+
|
| 603 |
+
assert Requirement.parse('setuptools').project_name == 'setuptools'
|
| 604 |
+
# setuptools 0.7 and higher means setuptools.
|
| 605 |
+
assert Requirement.parse('setuptools == 0.7').project_name == 'setuptools'
|
| 606 |
+
assert Requirement.parse('setuptools == 0.7a1').project_name == 'setuptools'
|
| 607 |
+
assert Requirement.parse('setuptools >= 0.7').project_name == 'setuptools'
|
| 608 |
+
|
| 609 |
+
|
| 610 |
+
class TestParsing:
|
| 611 |
+
def testEmptyParse(self):
|
| 612 |
+
assert list(parse_requirements('')) == []
|
| 613 |
+
|
| 614 |
+
def testYielding(self):
|
| 615 |
+
for inp, out in [
|
| 616 |
+
([], []),
|
| 617 |
+
('x', ['x']),
|
| 618 |
+
([[]], []),
|
| 619 |
+
(' x\n y', ['x', 'y']),
|
| 620 |
+
(['x\n\n', 'y'], ['x', 'y']),
|
| 621 |
+
]:
|
| 622 |
+
assert list(pkg_resources.yield_lines(inp)) == out
|
| 623 |
+
|
| 624 |
+
def testSplitting(self):
|
| 625 |
+
sample = """
|
| 626 |
+
x
|
| 627 |
+
[Y]
|
| 628 |
+
z
|
| 629 |
+
|
| 630 |
+
a
|
| 631 |
+
[b ]
|
| 632 |
+
# foo
|
| 633 |
+
c
|
| 634 |
+
[ d]
|
| 635 |
+
[q]
|
| 636 |
+
v
|
| 637 |
+
"""
|
| 638 |
+
assert list(pkg_resources.split_sections(sample)) == [
|
| 639 |
+
(None, ["x"]),
|
| 640 |
+
("Y", ["z", "a"]),
|
| 641 |
+
("b", ["c"]),
|
| 642 |
+
("d", []),
|
| 643 |
+
("q", ["v"]),
|
| 644 |
+
]
|
| 645 |
+
with pytest.raises(ValueError):
|
| 646 |
+
list(pkg_resources.split_sections("[foo"))
|
| 647 |
+
|
| 648 |
+
def testSafeName(self):
|
| 649 |
+
assert safe_name("adns-python") == "adns-python"
|
| 650 |
+
assert safe_name("WSGI Utils") == "WSGI-Utils"
|
| 651 |
+
assert safe_name("WSGI Utils") == "WSGI-Utils"
|
| 652 |
+
assert safe_name("Money$$$Maker") == "Money-Maker"
|
| 653 |
+
assert safe_name("peak.web") != "peak-web"
|
| 654 |
+
|
| 655 |
+
def testSafeVersion(self):
|
| 656 |
+
assert safe_version("1.2-1") == "1.2.post1"
|
| 657 |
+
assert safe_version("1.2 alpha") == "1.2.alpha"
|
| 658 |
+
assert safe_version("2.3.4 20050521") == "2.3.4.20050521"
|
| 659 |
+
assert safe_version("Money$$$Maker") == "Money-Maker"
|
| 660 |
+
assert safe_version("peak.web") == "peak.web"
|
| 661 |
+
|
| 662 |
+
def testSimpleRequirements(self):
|
| 663 |
+
assert list(parse_requirements('Twis-Ted>=1.2-1')) == [
|
| 664 |
+
Requirement('Twis-Ted>=1.2-1')
|
| 665 |
+
]
|
| 666 |
+
assert list(parse_requirements('Twisted >=1.2, \\ # more\n<2.0')) == [
|
| 667 |
+
Requirement('Twisted>=1.2,<2.0')
|
| 668 |
+
]
|
| 669 |
+
assert Requirement.parse("FooBar==1.99a3") == Requirement("FooBar==1.99a3")
|
| 670 |
+
with pytest.raises(ValueError):
|
| 671 |
+
Requirement.parse(">=2.3")
|
| 672 |
+
with pytest.raises(ValueError):
|
| 673 |
+
Requirement.parse("x\\")
|
| 674 |
+
with pytest.raises(ValueError):
|
| 675 |
+
Requirement.parse("x==2 q")
|
| 676 |
+
with pytest.raises(ValueError):
|
| 677 |
+
Requirement.parse("X==1\nY==2")
|
| 678 |
+
with pytest.raises(ValueError):
|
| 679 |
+
Requirement.parse("#")
|
| 680 |
+
|
| 681 |
+
def test_requirements_with_markers(self):
|
| 682 |
+
assert Requirement.parse("foobar;os_name=='a'") == Requirement.parse(
|
| 683 |
+
"foobar;os_name=='a'"
|
| 684 |
+
)
|
| 685 |
+
assert Requirement.parse(
|
| 686 |
+
"name==1.1;python_version=='2.7'"
|
| 687 |
+
) != Requirement.parse("name==1.1;python_version=='3.6'")
|
| 688 |
+
assert Requirement.parse(
|
| 689 |
+
"name==1.0;python_version=='2.7'"
|
| 690 |
+
) != Requirement.parse("name==1.2;python_version=='2.7'")
|
| 691 |
+
assert Requirement.parse(
|
| 692 |
+
"name[foo]==1.0;python_version=='3.6'"
|
| 693 |
+
) != Requirement.parse("name[foo,bar]==1.0;python_version=='3.6'")
|
| 694 |
+
|
| 695 |
+
def test_local_version(self):
|
| 696 |
+
parse_requirements('foo==1.0+org1')
|
| 697 |
+
|
| 698 |
+
def test_spaces_between_multiple_versions(self):
|
| 699 |
+
parse_requirements('foo>=1.0, <3')
|
| 700 |
+
parse_requirements('foo >= 1.0, < 3')
|
| 701 |
+
|
| 702 |
+
@pytest.mark.parametrize(
|
| 703 |
+
("lower", "upper"),
|
| 704 |
+
[
|
| 705 |
+
('1.2-rc1', '1.2rc1'),
|
| 706 |
+
('0.4', '0.4.0'),
|
| 707 |
+
('0.4.0.0', '0.4.0'),
|
| 708 |
+
('0.4.0-0', '0.4-0'),
|
| 709 |
+
('0post1', '0.0post1'),
|
| 710 |
+
('0pre1', '0.0c1'),
|
| 711 |
+
('0.0.0preview1', '0c1'),
|
| 712 |
+
('0.0c1', '0-rc1'),
|
| 713 |
+
('1.2a1', '1.2.a.1'),
|
| 714 |
+
('1.2.a', '1.2a'),
|
| 715 |
+
],
|
| 716 |
+
)
|
| 717 |
+
def testVersionEquality(self, lower, upper):
|
| 718 |
+
assert parse_version(lower) == parse_version(upper)
|
| 719 |
+
|
| 720 |
+
torture = """
|
| 721 |
+
0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1
|
| 722 |
+
0.79.9999+0.80.0pre2-3 0.79.9999+0.80.0pre2-2
|
| 723 |
+
0.77.2-1 0.77.1-1 0.77.0-1
|
| 724 |
+
"""
|
| 725 |
+
|
| 726 |
+
@pytest.mark.parametrize(
|
| 727 |
+
("lower", "upper"),
|
| 728 |
+
[
|
| 729 |
+
('2.1', '2.1.1'),
|
| 730 |
+
('2a1', '2b0'),
|
| 731 |
+
('2a1', '2.1'),
|
| 732 |
+
('2.3a1', '2.3'),
|
| 733 |
+
('2.1-1', '2.1-2'),
|
| 734 |
+
('2.1-1', '2.1.1'),
|
| 735 |
+
('2.1', '2.1post4'),
|
| 736 |
+
('2.1a0-20040501', '2.1'),
|
| 737 |
+
('1.1', '02.1'),
|
| 738 |
+
('3.2', '3.2.post0'),
|
| 739 |
+
('3.2post1', '3.2post2'),
|
| 740 |
+
('0.4', '4.0'),
|
| 741 |
+
('0.0.4', '0.4.0'),
|
| 742 |
+
('0post1', '0.4post1'),
|
| 743 |
+
('2.1.0-rc1', '2.1.0'),
|
| 744 |
+
('2.1dev', '2.1a0'),
|
| 745 |
+
]
|
| 746 |
+
+ list(pairwise(reversed(torture.split()))),
|
| 747 |
+
)
|
| 748 |
+
def testVersionOrdering(self, lower, upper):
|
| 749 |
+
assert parse_version(lower) < parse_version(upper)
|
| 750 |
+
|
| 751 |
+
def testVersionHashable(self):
|
| 752 |
+
"""
|
| 753 |
+
Ensure that our versions stay hashable even though we've subclassed
|
| 754 |
+
them and added some shim code to them.
|
| 755 |
+
"""
|
| 756 |
+
assert hash(parse_version("1.0")) == hash(parse_version("1.0"))
|
| 757 |
+
|
| 758 |
+
|
| 759 |
+
class TestNamespaces:
|
| 760 |
+
ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n"
|
| 761 |
+
|
| 762 |
+
@pytest.fixture
|
| 763 |
+
def symlinked_tmpdir(self, tmpdir):
|
| 764 |
+
"""
|
| 765 |
+
Where available, return the tempdir as a symlink,
|
| 766 |
+
which as revealed in #231 is more fragile than
|
| 767 |
+
a natural tempdir.
|
| 768 |
+
"""
|
| 769 |
+
if not hasattr(os, 'symlink'):
|
| 770 |
+
yield str(tmpdir)
|
| 771 |
+
return
|
| 772 |
+
|
| 773 |
+
link_name = str(tmpdir) + '-linked'
|
| 774 |
+
os.symlink(str(tmpdir), link_name)
|
| 775 |
+
try:
|
| 776 |
+
yield type(tmpdir)(link_name)
|
| 777 |
+
finally:
|
| 778 |
+
os.unlink(link_name)
|
| 779 |
+
|
| 780 |
+
@pytest.fixture(autouse=True)
|
| 781 |
+
def patched_path(self, tmpdir):
|
| 782 |
+
"""
|
| 783 |
+
Patch sys.path to include the 'site-pkgs' dir. Also
|
| 784 |
+
restore pkg_resources._namespace_packages to its
|
| 785 |
+
former state.
|
| 786 |
+
"""
|
| 787 |
+
saved_ns_pkgs = pkg_resources._namespace_packages.copy()
|
| 788 |
+
saved_sys_path = sys.path[:]
|
| 789 |
+
site_pkgs = tmpdir.mkdir('site-pkgs')
|
| 790 |
+
sys.path.append(str(site_pkgs))
|
| 791 |
+
try:
|
| 792 |
+
yield
|
| 793 |
+
finally:
|
| 794 |
+
pkg_resources._namespace_packages = saved_ns_pkgs
|
| 795 |
+
sys.path = saved_sys_path
|
| 796 |
+
|
| 797 |
+
issue591 = pytest.mark.xfail(platform.system() == 'Windows', reason="#591")
|
| 798 |
+
|
| 799 |
+
@issue591
|
| 800 |
+
def test_two_levels_deep(self, symlinked_tmpdir):
|
| 801 |
+
"""
|
| 802 |
+
Test nested namespace packages
|
| 803 |
+
Create namespace packages in the following tree :
|
| 804 |
+
site-packages-1/pkg1/pkg2
|
| 805 |
+
site-packages-2/pkg1/pkg2
|
| 806 |
+
Check both are in the _namespace_packages dict and that their __path__
|
| 807 |
+
is correct
|
| 808 |
+
"""
|
| 809 |
+
real_tmpdir = symlinked_tmpdir.realpath()
|
| 810 |
+
tmpdir = symlinked_tmpdir
|
| 811 |
+
sys.path.append(str(tmpdir / 'site-pkgs2'))
|
| 812 |
+
site_dirs = tmpdir / 'site-pkgs', tmpdir / 'site-pkgs2'
|
| 813 |
+
for site in site_dirs:
|
| 814 |
+
pkg1 = site / 'pkg1'
|
| 815 |
+
pkg2 = pkg1 / 'pkg2'
|
| 816 |
+
pkg2.ensure_dir()
|
| 817 |
+
(pkg1 / '__init__.py').write_text(self.ns_str, encoding='utf-8')
|
| 818 |
+
(pkg2 / '__init__.py').write_text(self.ns_str, encoding='utf-8')
|
| 819 |
+
with pytest.warns(DeprecationWarning, match="pkg_resources.declare_namespace"):
|
| 820 |
+
import pkg1 # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 821 |
+
assert "pkg1" in pkg_resources._namespace_packages
|
| 822 |
+
# attempt to import pkg2 from site-pkgs2
|
| 823 |
+
with pytest.warns(DeprecationWarning, match="pkg_resources.declare_namespace"):
|
| 824 |
+
import pkg1.pkg2 # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 825 |
+
# check the _namespace_packages dict
|
| 826 |
+
assert "pkg1.pkg2" in pkg_resources._namespace_packages
|
| 827 |
+
assert pkg_resources._namespace_packages["pkg1"] == ["pkg1.pkg2"]
|
| 828 |
+
# check the __path__ attribute contains both paths
|
| 829 |
+
expected = [
|
| 830 |
+
str(real_tmpdir / "site-pkgs" / "pkg1" / "pkg2"),
|
| 831 |
+
str(real_tmpdir / "site-pkgs2" / "pkg1" / "pkg2"),
|
| 832 |
+
]
|
| 833 |
+
assert pkg1.pkg2.__path__ == expected
|
| 834 |
+
|
| 835 |
+
@issue591
|
| 836 |
+
def test_path_order(self, symlinked_tmpdir):
|
| 837 |
+
"""
|
| 838 |
+
Test that if multiple versions of the same namespace package subpackage
|
| 839 |
+
are on different sys.path entries, that only the one earliest on
|
| 840 |
+
sys.path is imported, and that the namespace package's __path__ is in
|
| 841 |
+
the correct order.
|
| 842 |
+
|
| 843 |
+
Regression test for https://github.com/pypa/setuptools/issues/207
|
| 844 |
+
"""
|
| 845 |
+
|
| 846 |
+
tmpdir = symlinked_tmpdir
|
| 847 |
+
site_dirs = (
|
| 848 |
+
tmpdir / "site-pkgs",
|
| 849 |
+
tmpdir / "site-pkgs2",
|
| 850 |
+
tmpdir / "site-pkgs3",
|
| 851 |
+
)
|
| 852 |
+
|
| 853 |
+
vers_str = "__version__ = %r"
|
| 854 |
+
|
| 855 |
+
for number, site in enumerate(site_dirs, 1):
|
| 856 |
+
if number > 1:
|
| 857 |
+
sys.path.append(str(site))
|
| 858 |
+
nspkg = site / 'nspkg'
|
| 859 |
+
subpkg = nspkg / 'subpkg'
|
| 860 |
+
subpkg.ensure_dir()
|
| 861 |
+
(nspkg / '__init__.py').write_text(self.ns_str, encoding='utf-8')
|
| 862 |
+
(subpkg / '__init__.py').write_text(vers_str % number, encoding='utf-8')
|
| 863 |
+
|
| 864 |
+
with pytest.warns(DeprecationWarning, match="pkg_resources.declare_namespace"):
|
| 865 |
+
import nspkg # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 866 |
+
import nspkg.subpkg # pyright: ignore[reportMissingImports] # Temporary package for test
|
| 867 |
+
expected = [str(site.realpath() / 'nspkg') for site in site_dirs]
|
| 868 |
+
assert nspkg.__path__ == expected
|
| 869 |
+
assert nspkg.subpkg.__version__ == 1
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/pkg_resources/tests/test_working_set.py
ADDED
|
@@ -0,0 +1,505 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
import inspect
|
| 3 |
+
import re
|
| 4 |
+
import textwrap
|
| 5 |
+
|
| 6 |
+
import pytest
|
| 7 |
+
|
| 8 |
+
import pkg_resources
|
| 9 |
+
|
| 10 |
+
from .test_resources import Metadata
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def strip_comments(s):
|
| 14 |
+
return '\n'.join(
|
| 15 |
+
line
|
| 16 |
+
for line in s.split('\n')
|
| 17 |
+
if line.strip() and not line.strip().startswith('#')
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def parse_distributions(s):
|
| 22 |
+
"""
|
| 23 |
+
Parse a series of distribution specs of the form:
|
| 24 |
+
{project_name}-{version}
|
| 25 |
+
[optional, indented requirements specification]
|
| 26 |
+
|
| 27 |
+
Example:
|
| 28 |
+
|
| 29 |
+
foo-0.2
|
| 30 |
+
bar-1.0
|
| 31 |
+
foo>=3.0
|
| 32 |
+
[feature]
|
| 33 |
+
baz
|
| 34 |
+
|
| 35 |
+
yield 2 distributions:
|
| 36 |
+
- project_name=foo, version=0.2
|
| 37 |
+
- project_name=bar, version=1.0,
|
| 38 |
+
requires=['foo>=3.0', 'baz; extra=="feature"']
|
| 39 |
+
"""
|
| 40 |
+
s = s.strip()
|
| 41 |
+
for spec in re.split(r'\n(?=[^\s])', s):
|
| 42 |
+
if not spec:
|
| 43 |
+
continue
|
| 44 |
+
fields = spec.split('\n', 1)
|
| 45 |
+
assert 1 <= len(fields) <= 2
|
| 46 |
+
name, version = fields.pop(0).rsplit('-', 1)
|
| 47 |
+
if fields:
|
| 48 |
+
requires = textwrap.dedent(fields.pop(0))
|
| 49 |
+
metadata = Metadata(('requires.txt', requires))
|
| 50 |
+
else:
|
| 51 |
+
metadata = None
|
| 52 |
+
dist = pkg_resources.Distribution(
|
| 53 |
+
project_name=name, version=version, metadata=metadata
|
| 54 |
+
)
|
| 55 |
+
yield dist
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class FakeInstaller:
|
| 59 |
+
def __init__(self, installable_dists) -> None:
|
| 60 |
+
self._installable_dists = installable_dists
|
| 61 |
+
|
| 62 |
+
def __call__(self, req):
|
| 63 |
+
return next(
|
| 64 |
+
iter(filter(lambda dist: dist in req, self._installable_dists)), None
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def parametrize_test_working_set_resolve(*test_list):
|
| 69 |
+
idlist = []
|
| 70 |
+
argvalues = []
|
| 71 |
+
for test in test_list:
|
| 72 |
+
(
|
| 73 |
+
name,
|
| 74 |
+
installed_dists,
|
| 75 |
+
installable_dists,
|
| 76 |
+
requirements,
|
| 77 |
+
expected1,
|
| 78 |
+
expected2,
|
| 79 |
+
) = (
|
| 80 |
+
strip_comments(s.lstrip())
|
| 81 |
+
for s in textwrap.dedent(test).lstrip().split('\n\n', 5)
|
| 82 |
+
)
|
| 83 |
+
installed_dists = list(parse_distributions(installed_dists))
|
| 84 |
+
installable_dists = list(parse_distributions(installable_dists))
|
| 85 |
+
requirements = list(pkg_resources.parse_requirements(requirements))
|
| 86 |
+
for id_, replace_conflicting, expected in (
|
| 87 |
+
(name, False, expected1),
|
| 88 |
+
(name + '_replace_conflicting', True, expected2),
|
| 89 |
+
):
|
| 90 |
+
idlist.append(id_)
|
| 91 |
+
expected = strip_comments(expected.strip())
|
| 92 |
+
if re.match(r'\w+$', expected):
|
| 93 |
+
expected = getattr(pkg_resources, expected)
|
| 94 |
+
assert issubclass(expected, Exception)
|
| 95 |
+
else:
|
| 96 |
+
expected = list(parse_distributions(expected))
|
| 97 |
+
argvalues.append(
|
| 98 |
+
pytest.param(
|
| 99 |
+
installed_dists,
|
| 100 |
+
installable_dists,
|
| 101 |
+
requirements,
|
| 102 |
+
replace_conflicting,
|
| 103 |
+
expected,
|
| 104 |
+
)
|
| 105 |
+
)
|
| 106 |
+
return pytest.mark.parametrize(
|
| 107 |
+
(
|
| 108 |
+
"installed_dists",
|
| 109 |
+
"installable_dists",
|
| 110 |
+
"requirements",
|
| 111 |
+
"replace_conflicting",
|
| 112 |
+
"resolved_dists_or_exception",
|
| 113 |
+
),
|
| 114 |
+
argvalues,
|
| 115 |
+
ids=idlist,
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
@parametrize_test_working_set_resolve(
|
| 120 |
+
"""
|
| 121 |
+
# id
|
| 122 |
+
noop
|
| 123 |
+
|
| 124 |
+
# installed
|
| 125 |
+
|
| 126 |
+
# installable
|
| 127 |
+
|
| 128 |
+
# wanted
|
| 129 |
+
|
| 130 |
+
# resolved
|
| 131 |
+
|
| 132 |
+
# resolved [replace conflicting]
|
| 133 |
+
""",
|
| 134 |
+
"""
|
| 135 |
+
# id
|
| 136 |
+
already_installed
|
| 137 |
+
|
| 138 |
+
# installed
|
| 139 |
+
foo-3.0
|
| 140 |
+
|
| 141 |
+
# installable
|
| 142 |
+
|
| 143 |
+
# wanted
|
| 144 |
+
foo>=2.1,!=3.1,<4
|
| 145 |
+
|
| 146 |
+
# resolved
|
| 147 |
+
foo-3.0
|
| 148 |
+
|
| 149 |
+
# resolved [replace conflicting]
|
| 150 |
+
foo-3.0
|
| 151 |
+
""",
|
| 152 |
+
"""
|
| 153 |
+
# id
|
| 154 |
+
installable_not_installed
|
| 155 |
+
|
| 156 |
+
# installed
|
| 157 |
+
|
| 158 |
+
# installable
|
| 159 |
+
foo-3.0
|
| 160 |
+
foo-4.0
|
| 161 |
+
|
| 162 |
+
# wanted
|
| 163 |
+
foo>=2.1,!=3.1,<4
|
| 164 |
+
|
| 165 |
+
# resolved
|
| 166 |
+
foo-3.0
|
| 167 |
+
|
| 168 |
+
# resolved [replace conflicting]
|
| 169 |
+
foo-3.0
|
| 170 |
+
""",
|
| 171 |
+
"""
|
| 172 |
+
# id
|
| 173 |
+
not_installable
|
| 174 |
+
|
| 175 |
+
# installed
|
| 176 |
+
|
| 177 |
+
# installable
|
| 178 |
+
|
| 179 |
+
# wanted
|
| 180 |
+
foo>=2.1,!=3.1,<4
|
| 181 |
+
|
| 182 |
+
# resolved
|
| 183 |
+
DistributionNotFound
|
| 184 |
+
|
| 185 |
+
# resolved [replace conflicting]
|
| 186 |
+
DistributionNotFound
|
| 187 |
+
""",
|
| 188 |
+
"""
|
| 189 |
+
# id
|
| 190 |
+
no_matching_version
|
| 191 |
+
|
| 192 |
+
# installed
|
| 193 |
+
|
| 194 |
+
# installable
|
| 195 |
+
foo-3.1
|
| 196 |
+
|
| 197 |
+
# wanted
|
| 198 |
+
foo>=2.1,!=3.1,<4
|
| 199 |
+
|
| 200 |
+
# resolved
|
| 201 |
+
DistributionNotFound
|
| 202 |
+
|
| 203 |
+
# resolved [replace conflicting]
|
| 204 |
+
DistributionNotFound
|
| 205 |
+
""",
|
| 206 |
+
"""
|
| 207 |
+
# id
|
| 208 |
+
installable_with_installed_conflict
|
| 209 |
+
|
| 210 |
+
# installed
|
| 211 |
+
foo-3.1
|
| 212 |
+
|
| 213 |
+
# installable
|
| 214 |
+
foo-3.5
|
| 215 |
+
|
| 216 |
+
# wanted
|
| 217 |
+
foo>=2.1,!=3.1,<4
|
| 218 |
+
|
| 219 |
+
# resolved
|
| 220 |
+
VersionConflict
|
| 221 |
+
|
| 222 |
+
# resolved [replace conflicting]
|
| 223 |
+
foo-3.5
|
| 224 |
+
""",
|
| 225 |
+
"""
|
| 226 |
+
# id
|
| 227 |
+
not_installable_with_installed_conflict
|
| 228 |
+
|
| 229 |
+
# installed
|
| 230 |
+
foo-3.1
|
| 231 |
+
|
| 232 |
+
# installable
|
| 233 |
+
|
| 234 |
+
# wanted
|
| 235 |
+
foo>=2.1,!=3.1,<4
|
| 236 |
+
|
| 237 |
+
# resolved
|
| 238 |
+
VersionConflict
|
| 239 |
+
|
| 240 |
+
# resolved [replace conflicting]
|
| 241 |
+
DistributionNotFound
|
| 242 |
+
""",
|
| 243 |
+
"""
|
| 244 |
+
# id
|
| 245 |
+
installed_with_installed_require
|
| 246 |
+
|
| 247 |
+
# installed
|
| 248 |
+
foo-3.9
|
| 249 |
+
baz-0.1
|
| 250 |
+
foo>=2.1,!=3.1,<4
|
| 251 |
+
|
| 252 |
+
# installable
|
| 253 |
+
|
| 254 |
+
# wanted
|
| 255 |
+
baz
|
| 256 |
+
|
| 257 |
+
# resolved
|
| 258 |
+
foo-3.9
|
| 259 |
+
baz-0.1
|
| 260 |
+
|
| 261 |
+
# resolved [replace conflicting]
|
| 262 |
+
foo-3.9
|
| 263 |
+
baz-0.1
|
| 264 |
+
""",
|
| 265 |
+
"""
|
| 266 |
+
# id
|
| 267 |
+
installed_with_conflicting_installed_require
|
| 268 |
+
|
| 269 |
+
# installed
|
| 270 |
+
foo-5
|
| 271 |
+
baz-0.1
|
| 272 |
+
foo>=2.1,!=3.1,<4
|
| 273 |
+
|
| 274 |
+
# installable
|
| 275 |
+
|
| 276 |
+
# wanted
|
| 277 |
+
baz
|
| 278 |
+
|
| 279 |
+
# resolved
|
| 280 |
+
VersionConflict
|
| 281 |
+
|
| 282 |
+
# resolved [replace conflicting]
|
| 283 |
+
DistributionNotFound
|
| 284 |
+
""",
|
| 285 |
+
"""
|
| 286 |
+
# id
|
| 287 |
+
installed_with_installable_conflicting_require
|
| 288 |
+
|
| 289 |
+
# installed
|
| 290 |
+
foo-5
|
| 291 |
+
baz-0.1
|
| 292 |
+
foo>=2.1,!=3.1,<4
|
| 293 |
+
|
| 294 |
+
# installable
|
| 295 |
+
foo-2.9
|
| 296 |
+
|
| 297 |
+
# wanted
|
| 298 |
+
baz
|
| 299 |
+
|
| 300 |
+
# resolved
|
| 301 |
+
VersionConflict
|
| 302 |
+
|
| 303 |
+
# resolved [replace conflicting]
|
| 304 |
+
baz-0.1
|
| 305 |
+
foo-2.9
|
| 306 |
+
""",
|
| 307 |
+
"""
|
| 308 |
+
# id
|
| 309 |
+
installed_with_installable_require
|
| 310 |
+
|
| 311 |
+
# installed
|
| 312 |
+
baz-0.1
|
| 313 |
+
foo>=2.1,!=3.1,<4
|
| 314 |
+
|
| 315 |
+
# installable
|
| 316 |
+
foo-3.9
|
| 317 |
+
|
| 318 |
+
# wanted
|
| 319 |
+
baz
|
| 320 |
+
|
| 321 |
+
# resolved
|
| 322 |
+
foo-3.9
|
| 323 |
+
baz-0.1
|
| 324 |
+
|
| 325 |
+
# resolved [replace conflicting]
|
| 326 |
+
foo-3.9
|
| 327 |
+
baz-0.1
|
| 328 |
+
""",
|
| 329 |
+
"""
|
| 330 |
+
# id
|
| 331 |
+
installable_with_installed_require
|
| 332 |
+
|
| 333 |
+
# installed
|
| 334 |
+
foo-3.9
|
| 335 |
+
|
| 336 |
+
# installable
|
| 337 |
+
baz-0.1
|
| 338 |
+
foo>=2.1,!=3.1,<4
|
| 339 |
+
|
| 340 |
+
# wanted
|
| 341 |
+
baz
|
| 342 |
+
|
| 343 |
+
# resolved
|
| 344 |
+
foo-3.9
|
| 345 |
+
baz-0.1
|
| 346 |
+
|
| 347 |
+
# resolved [replace conflicting]
|
| 348 |
+
foo-3.9
|
| 349 |
+
baz-0.1
|
| 350 |
+
""",
|
| 351 |
+
"""
|
| 352 |
+
# id
|
| 353 |
+
installable_with_installable_require
|
| 354 |
+
|
| 355 |
+
# installed
|
| 356 |
+
|
| 357 |
+
# installable
|
| 358 |
+
foo-3.9
|
| 359 |
+
baz-0.1
|
| 360 |
+
foo>=2.1,!=3.1,<4
|
| 361 |
+
|
| 362 |
+
# wanted
|
| 363 |
+
baz
|
| 364 |
+
|
| 365 |
+
# resolved
|
| 366 |
+
foo-3.9
|
| 367 |
+
baz-0.1
|
| 368 |
+
|
| 369 |
+
# resolved [replace conflicting]
|
| 370 |
+
foo-3.9
|
| 371 |
+
baz-0.1
|
| 372 |
+
""",
|
| 373 |
+
"""
|
| 374 |
+
# id
|
| 375 |
+
installable_with_conflicting_installable_require
|
| 376 |
+
|
| 377 |
+
# installed
|
| 378 |
+
foo-5
|
| 379 |
+
|
| 380 |
+
# installable
|
| 381 |
+
foo-2.9
|
| 382 |
+
baz-0.1
|
| 383 |
+
foo>=2.1,!=3.1,<4
|
| 384 |
+
|
| 385 |
+
# wanted
|
| 386 |
+
baz
|
| 387 |
+
|
| 388 |
+
# resolved
|
| 389 |
+
VersionConflict
|
| 390 |
+
|
| 391 |
+
# resolved [replace conflicting]
|
| 392 |
+
baz-0.1
|
| 393 |
+
foo-2.9
|
| 394 |
+
""",
|
| 395 |
+
"""
|
| 396 |
+
# id
|
| 397 |
+
conflicting_installables
|
| 398 |
+
|
| 399 |
+
# installed
|
| 400 |
+
|
| 401 |
+
# installable
|
| 402 |
+
foo-2.9
|
| 403 |
+
foo-5.0
|
| 404 |
+
|
| 405 |
+
# wanted
|
| 406 |
+
foo>=2.1,!=3.1,<4
|
| 407 |
+
foo>=4
|
| 408 |
+
|
| 409 |
+
# resolved
|
| 410 |
+
VersionConflict
|
| 411 |
+
|
| 412 |
+
# resolved [replace conflicting]
|
| 413 |
+
VersionConflict
|
| 414 |
+
""",
|
| 415 |
+
"""
|
| 416 |
+
# id
|
| 417 |
+
installables_with_conflicting_requires
|
| 418 |
+
|
| 419 |
+
# installed
|
| 420 |
+
|
| 421 |
+
# installable
|
| 422 |
+
foo-2.9
|
| 423 |
+
dep==1.0
|
| 424 |
+
baz-5.0
|
| 425 |
+
dep==2.0
|
| 426 |
+
dep-1.0
|
| 427 |
+
dep-2.0
|
| 428 |
+
|
| 429 |
+
# wanted
|
| 430 |
+
foo
|
| 431 |
+
baz
|
| 432 |
+
|
| 433 |
+
# resolved
|
| 434 |
+
VersionConflict
|
| 435 |
+
|
| 436 |
+
# resolved [replace conflicting]
|
| 437 |
+
VersionConflict
|
| 438 |
+
""",
|
| 439 |
+
"""
|
| 440 |
+
# id
|
| 441 |
+
installables_with_conflicting_nested_requires
|
| 442 |
+
|
| 443 |
+
# installed
|
| 444 |
+
|
| 445 |
+
# installable
|
| 446 |
+
foo-2.9
|
| 447 |
+
dep1
|
| 448 |
+
dep1-1.0
|
| 449 |
+
subdep<1.0
|
| 450 |
+
baz-5.0
|
| 451 |
+
dep2
|
| 452 |
+
dep2-1.0
|
| 453 |
+
subdep>1.0
|
| 454 |
+
subdep-0.9
|
| 455 |
+
subdep-1.1
|
| 456 |
+
|
| 457 |
+
# wanted
|
| 458 |
+
foo
|
| 459 |
+
baz
|
| 460 |
+
|
| 461 |
+
# resolved
|
| 462 |
+
VersionConflict
|
| 463 |
+
|
| 464 |
+
# resolved [replace conflicting]
|
| 465 |
+
VersionConflict
|
| 466 |
+
""",
|
| 467 |
+
"""
|
| 468 |
+
# id
|
| 469 |
+
wanted_normalized_name_installed_canonical
|
| 470 |
+
|
| 471 |
+
# installed
|
| 472 |
+
foo.bar-3.6
|
| 473 |
+
|
| 474 |
+
# installable
|
| 475 |
+
|
| 476 |
+
# wanted
|
| 477 |
+
foo-bar==3.6
|
| 478 |
+
|
| 479 |
+
# resolved
|
| 480 |
+
foo.bar-3.6
|
| 481 |
+
|
| 482 |
+
# resolved [replace conflicting]
|
| 483 |
+
foo.bar-3.6
|
| 484 |
+
""",
|
| 485 |
+
)
|
| 486 |
+
def test_working_set_resolve(
|
| 487 |
+
installed_dists,
|
| 488 |
+
installable_dists,
|
| 489 |
+
requirements,
|
| 490 |
+
replace_conflicting,
|
| 491 |
+
resolved_dists_or_exception,
|
| 492 |
+
):
|
| 493 |
+
ws = pkg_resources.WorkingSet([])
|
| 494 |
+
list(map(ws.add, installed_dists))
|
| 495 |
+
resolve_call = functools.partial(
|
| 496 |
+
ws.resolve,
|
| 497 |
+
requirements,
|
| 498 |
+
installer=FakeInstaller(installable_dists),
|
| 499 |
+
replace_conflicting=replace_conflicting,
|
| 500 |
+
)
|
| 501 |
+
if inspect.isclass(resolved_dists_or_exception):
|
| 502 |
+
with pytest.raises(resolved_dists_or_exception):
|
| 503 |
+
resolve_call()
|
| 504 |
+
else:
|
| 505 |
+
assert sorted(resolve_call()) == sorted(resolved_dists_or_exception)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: setuptools
|
| 3 |
+
Version: 80.10.2
|
| 4 |
+
Summary: Easily download, build, install, upgrade, and uninstall Python packages
|
| 5 |
+
Author-email: Python Packaging Authority <distutils-sig@python.org>
|
| 6 |
+
License-Expression: MIT
|
| 7 |
+
Project-URL: Source, https://github.com/pypa/setuptools
|
| 8 |
+
Project-URL: Documentation, https://setuptools.pypa.io/
|
| 9 |
+
Project-URL: Changelog, https://setuptools.pypa.io/en/stable/history.html
|
| 10 |
+
Keywords: CPAN PyPI distutils eggs package management
|
| 11 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 12 |
+
Classifier: Intended Audience :: Developers
|
| 13 |
+
Classifier: Programming Language :: Python :: 3
|
| 14 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 15 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 16 |
+
Classifier: Topic :: System :: Archiving :: Packaging
|
| 17 |
+
Classifier: Topic :: System :: Systems Administration
|
| 18 |
+
Classifier: Topic :: Utilities
|
| 19 |
+
Requires-Python: >=3.9
|
| 20 |
+
Description-Content-Type: text/x-rst
|
| 21 |
+
License-File: LICENSE
|
| 22 |
+
Provides-Extra: test
|
| 23 |
+
Requires-Dist: pytest!=8.1.*,>=6; extra == "test"
|
| 24 |
+
Requires-Dist: virtualenv>=13.0.0; extra == "test"
|
| 25 |
+
Requires-Dist: wheel>=0.44.0; extra == "test"
|
| 26 |
+
Requires-Dist: pip>=19.1; extra == "test"
|
| 27 |
+
Requires-Dist: packaging>=24.2; extra == "test"
|
| 28 |
+
Requires-Dist: jaraco.envs>=2.2; extra == "test"
|
| 29 |
+
Requires-Dist: pytest-xdist>=3; extra == "test"
|
| 30 |
+
Requires-Dist: jaraco.path>=3.7.2; extra == "test"
|
| 31 |
+
Requires-Dist: build[virtualenv]>=1.0.3; extra == "test"
|
| 32 |
+
Requires-Dist: filelock>=3.4.0; extra == "test"
|
| 33 |
+
Requires-Dist: ini2toml[lite]>=0.14; extra == "test"
|
| 34 |
+
Requires-Dist: tomli-w>=1.0.0; extra == "test"
|
| 35 |
+
Requires-Dist: pytest-timeout; extra == "test"
|
| 36 |
+
Requires-Dist: pytest-perf; sys_platform != "cygwin" and extra == "test"
|
| 37 |
+
Requires-Dist: jaraco.develop>=7.21; (python_version >= "3.9" and sys_platform != "cygwin") and extra == "test"
|
| 38 |
+
Requires-Dist: pytest-home>=0.5; extra == "test"
|
| 39 |
+
Requires-Dist: pytest-subprocess; extra == "test"
|
| 40 |
+
Requires-Dist: pyproject-hooks!=1.1; extra == "test"
|
| 41 |
+
Requires-Dist: jaraco.test>=5.5; extra == "test"
|
| 42 |
+
Provides-Extra: doc
|
| 43 |
+
Requires-Dist: sphinx>=3.5; extra == "doc"
|
| 44 |
+
Requires-Dist: jaraco.packaging>=9.3; extra == "doc"
|
| 45 |
+
Requires-Dist: rst.linker>=1.9; extra == "doc"
|
| 46 |
+
Requires-Dist: furo; extra == "doc"
|
| 47 |
+
Requires-Dist: sphinx-lint; extra == "doc"
|
| 48 |
+
Requires-Dist: jaraco.tidelift>=1.4; extra == "doc"
|
| 49 |
+
Requires-Dist: pygments-github-lexers==0.0.5; extra == "doc"
|
| 50 |
+
Requires-Dist: sphinx-favicon; extra == "doc"
|
| 51 |
+
Requires-Dist: sphinx-inline-tabs; extra == "doc"
|
| 52 |
+
Requires-Dist: sphinx-reredirects; extra == "doc"
|
| 53 |
+
Requires-Dist: sphinxcontrib-towncrier; extra == "doc"
|
| 54 |
+
Requires-Dist: sphinx-notfound-page<2,>=1; extra == "doc"
|
| 55 |
+
Requires-Dist: pyproject-hooks!=1.1; extra == "doc"
|
| 56 |
+
Requires-Dist: towncrier<24.7; extra == "doc"
|
| 57 |
+
Provides-Extra: ssl
|
| 58 |
+
Provides-Extra: certs
|
| 59 |
+
Provides-Extra: core
|
| 60 |
+
Requires-Dist: packaging>=24.2; extra == "core"
|
| 61 |
+
Requires-Dist: more_itertools>=8.8; extra == "core"
|
| 62 |
+
Requires-Dist: jaraco.text>=3.7; extra == "core"
|
| 63 |
+
Requires-Dist: importlib_metadata>=6; python_version < "3.10" and extra == "core"
|
| 64 |
+
Requires-Dist: tomli>=2.0.1; python_version < "3.11" and extra == "core"
|
| 65 |
+
Requires-Dist: wheel>=0.43.0; extra == "core"
|
| 66 |
+
Requires-Dist: platformdirs>=4.2.2; extra == "core"
|
| 67 |
+
Requires-Dist: jaraco.functools>=4; extra == "core"
|
| 68 |
+
Requires-Dist: more_itertools; extra == "core"
|
| 69 |
+
Provides-Extra: check
|
| 70 |
+
Requires-Dist: pytest-checkdocs>=2.4; extra == "check"
|
| 71 |
+
Requires-Dist: pytest-ruff>=0.2.1; sys_platform != "cygwin" and extra == "check"
|
| 72 |
+
Requires-Dist: ruff>=0.8.0; sys_platform != "cygwin" and extra == "check"
|
| 73 |
+
Provides-Extra: cover
|
| 74 |
+
Requires-Dist: pytest-cov; extra == "cover"
|
| 75 |
+
Provides-Extra: enabler
|
| 76 |
+
Requires-Dist: pytest-enabler>=2.2; extra == "enabler"
|
| 77 |
+
Provides-Extra: type
|
| 78 |
+
Requires-Dist: pytest-mypy; extra == "type"
|
| 79 |
+
Requires-Dist: mypy==1.14.*; extra == "type"
|
| 80 |
+
Requires-Dist: importlib_metadata>=7.0.2; python_version < "3.10" and extra == "type"
|
| 81 |
+
Requires-Dist: jaraco.develop>=7.21; sys_platform != "cygwin" and extra == "type"
|
| 82 |
+
Dynamic: license-file
|
| 83 |
+
|
| 84 |
+
.. |pypi-version| image:: https://img.shields.io/pypi/v/setuptools.svg
|
| 85 |
+
:target: https://pypi.org/project/setuptools
|
| 86 |
+
|
| 87 |
+
.. |py-version| image:: https://img.shields.io/pypi/pyversions/setuptools.svg
|
| 88 |
+
|
| 89 |
+
.. |test-badge| image:: https://github.com/pypa/setuptools/actions/workflows/main.yml/badge.svg
|
| 90 |
+
:target: https://github.com/pypa/setuptools/actions?query=workflow%3A%22tests%22
|
| 91 |
+
:alt: tests
|
| 92 |
+
|
| 93 |
+
.. |ruff-badge| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json
|
| 94 |
+
:target: https://github.com/astral-sh/ruff
|
| 95 |
+
:alt: Ruff
|
| 96 |
+
|
| 97 |
+
.. |docs-badge| image:: https://img.shields.io/readthedocs/setuptools/latest.svg
|
| 98 |
+
:target: https://setuptools.pypa.io
|
| 99 |
+
|
| 100 |
+
.. |skeleton-badge| image:: https://img.shields.io/badge/skeleton-2025-informational
|
| 101 |
+
:target: https://blog.jaraco.com/skeleton
|
| 102 |
+
|
| 103 |
+
.. |codecov-badge| image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white
|
| 104 |
+
:target: https://codecov.io/gh/pypa/setuptools
|
| 105 |
+
|
| 106 |
+
.. |tidelift-badge| image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat
|
| 107 |
+
:target: https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=readme
|
| 108 |
+
|
| 109 |
+
.. |discord-badge| image:: https://img.shields.io/discord/803025117553754132
|
| 110 |
+
:target: https://discord.com/channels/803025117553754132/815945031150993468
|
| 111 |
+
:alt: Discord
|
| 112 |
+
|
| 113 |
+
|pypi-version| |py-version| |test-badge| |ruff-badge| |docs-badge| |skeleton-badge| |codecov-badge| |discord-badge|
|
| 114 |
+
|
| 115 |
+
See the `Quickstart <https://setuptools.pypa.io/en/latest/userguide/quickstart.html>`_
|
| 116 |
+
and the `User's Guide <https://setuptools.pypa.io/en/latest/userguide/>`_ for
|
| 117 |
+
instructions on how to use Setuptools.
|
| 118 |
+
|
| 119 |
+
Questions and comments should be directed to `GitHub Discussions
|
| 120 |
+
<https://github.com/pypa/setuptools/discussions>`_.
|
| 121 |
+
Bug reports and especially tested patches may be
|
| 122 |
+
submitted directly to the `bug tracker
|
| 123 |
+
<https://github.com/pypa/setuptools/issues>`_.
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
Code of Conduct
|
| 127 |
+
===============
|
| 128 |
+
|
| 129 |
+
Everyone interacting in the setuptools project's codebases, issue trackers,
|
| 130 |
+
chat rooms, and fora is expected to follow the
|
| 131 |
+
`PSF Code of Conduct <https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md>`_.
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
For Enterprise
|
| 135 |
+
==============
|
| 136 |
+
|
| 137 |
+
Available as part of the Tidelift Subscription.
|
| 138 |
+
|
| 139 |
+
Setuptools and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.
|
| 140 |
+
|
| 141 |
+
`Learn more <https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=referral&utm_campaign=github>`_.
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,527 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
LICENSE
|
| 2 |
+
MANIFEST.in
|
| 3 |
+
NEWS.rst
|
| 4 |
+
README.rst
|
| 5 |
+
conftest.py
|
| 6 |
+
exercises.py
|
| 7 |
+
launcher.c
|
| 8 |
+
mypy.ini
|
| 9 |
+
pyproject.toml
|
| 10 |
+
pytest.ini
|
| 11 |
+
setup.cfg
|
| 12 |
+
setup.py
|
| 13 |
+
tox.ini
|
| 14 |
+
_distutils_hack/__init__.py
|
| 15 |
+
_distutils_hack/override.py
|
| 16 |
+
docs/artwork.rst
|
| 17 |
+
docs/build_meta.rst
|
| 18 |
+
docs/conf.py
|
| 19 |
+
docs/history.rst
|
| 20 |
+
docs/index.rst
|
| 21 |
+
docs/pkg_resources.rst
|
| 22 |
+
docs/python 2 sunset.rst
|
| 23 |
+
docs/roadmap.rst
|
| 24 |
+
docs/setuptools.rst
|
| 25 |
+
docs/deprecated/changed_keywords.rst
|
| 26 |
+
docs/deprecated/commands.rst
|
| 27 |
+
docs/deprecated/dependency_links.rst
|
| 28 |
+
docs/deprecated/distutils-legacy.rst
|
| 29 |
+
docs/deprecated/easy_install.rst
|
| 30 |
+
docs/deprecated/functionalities.rst
|
| 31 |
+
docs/deprecated/index.rst
|
| 32 |
+
docs/deprecated/python_eggs.rst
|
| 33 |
+
docs/deprecated/resource_extraction.rst
|
| 34 |
+
docs/deprecated/zip_safe.rst
|
| 35 |
+
docs/deprecated/distutils/_setuptools_disclaimer.rst
|
| 36 |
+
docs/deprecated/distutils/apiref.rst
|
| 37 |
+
docs/deprecated/distutils/builtdist.rst
|
| 38 |
+
docs/deprecated/distutils/commandref.rst
|
| 39 |
+
docs/deprecated/distutils/configfile.rst
|
| 40 |
+
docs/deprecated/distutils/examples.rst
|
| 41 |
+
docs/deprecated/distutils/extending.rst
|
| 42 |
+
docs/deprecated/distutils/index.rst
|
| 43 |
+
docs/deprecated/distutils/introduction.rst
|
| 44 |
+
docs/deprecated/distutils/packageindex.rst
|
| 45 |
+
docs/deprecated/distutils/setupscript.rst
|
| 46 |
+
docs/deprecated/distutils/sourcedist.rst
|
| 47 |
+
docs/deprecated/distutils/uploading.rst
|
| 48 |
+
docs/development/developer-guide.rst
|
| 49 |
+
docs/development/index.rst
|
| 50 |
+
docs/development/releases.rst
|
| 51 |
+
docs/references/keywords.rst
|
| 52 |
+
docs/userguide/datafiles.rst
|
| 53 |
+
docs/userguide/declarative_config.rst
|
| 54 |
+
docs/userguide/dependency_management.rst
|
| 55 |
+
docs/userguide/development_mode.rst
|
| 56 |
+
docs/userguide/distribution.rst
|
| 57 |
+
docs/userguide/entry_point.rst
|
| 58 |
+
docs/userguide/ext_modules.rst
|
| 59 |
+
docs/userguide/extension.rst
|
| 60 |
+
docs/userguide/index.rst
|
| 61 |
+
docs/userguide/interfaces.rst
|
| 62 |
+
docs/userguide/miscellaneous.rst
|
| 63 |
+
docs/userguide/package_discovery.rst
|
| 64 |
+
docs/userguide/pyproject_config.rst
|
| 65 |
+
docs/userguide/quickstart.rst
|
| 66 |
+
newsfragments/.gitignore
|
| 67 |
+
newsfragments/README.rst
|
| 68 |
+
pkg_resources/__init__.py
|
| 69 |
+
pkg_resources/api_tests.txt
|
| 70 |
+
pkg_resources/py.typed
|
| 71 |
+
pkg_resources/tests/__init__.py
|
| 72 |
+
pkg_resources/tests/test_find_distributions.py
|
| 73 |
+
pkg_resources/tests/test_integration_zope_interface.py
|
| 74 |
+
pkg_resources/tests/test_markers.py
|
| 75 |
+
pkg_resources/tests/test_pkg_resources.py
|
| 76 |
+
pkg_resources/tests/test_resources.py
|
| 77 |
+
pkg_resources/tests/test_working_set.py
|
| 78 |
+
pkg_resources/tests/data/my-test-package-source/setup.cfg
|
| 79 |
+
pkg_resources/tests/data/my-test-package-source/setup.py
|
| 80 |
+
pkg_resources/tests/data/my-test-package-zip/my-test-package.zip
|
| 81 |
+
pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/PKG-INFO
|
| 82 |
+
pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/SOURCES.txt
|
| 83 |
+
pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/dependency_links.txt
|
| 84 |
+
pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/top_level.txt
|
| 85 |
+
pkg_resources/tests/data/my-test-package_unpacked-egg/my_test_package-1.0-py3.7.egg/EGG-INFO/zip-safe
|
| 86 |
+
pkg_resources/tests/data/my-test-package_zipped-egg/my_test_package-1.0-py3.7.egg
|
| 87 |
+
setuptools/__init__.py
|
| 88 |
+
setuptools/_core_metadata.py
|
| 89 |
+
setuptools/_discovery.py
|
| 90 |
+
setuptools/_entry_points.py
|
| 91 |
+
setuptools/_imp.py
|
| 92 |
+
setuptools/_importlib.py
|
| 93 |
+
setuptools/_itertools.py
|
| 94 |
+
setuptools/_normalization.py
|
| 95 |
+
setuptools/_path.py
|
| 96 |
+
setuptools/_reqs.py
|
| 97 |
+
setuptools/_scripts.py
|
| 98 |
+
setuptools/_shutil.py
|
| 99 |
+
setuptools/_static.py
|
| 100 |
+
setuptools/archive_util.py
|
| 101 |
+
setuptools/build_meta.py
|
| 102 |
+
setuptools/cli-32.exe
|
| 103 |
+
setuptools/cli-64.exe
|
| 104 |
+
setuptools/cli-arm64.exe
|
| 105 |
+
setuptools/cli.exe
|
| 106 |
+
setuptools/depends.py
|
| 107 |
+
setuptools/discovery.py
|
| 108 |
+
setuptools/dist.py
|
| 109 |
+
setuptools/errors.py
|
| 110 |
+
setuptools/extension.py
|
| 111 |
+
setuptools/glob.py
|
| 112 |
+
setuptools/gui-32.exe
|
| 113 |
+
setuptools/gui-64.exe
|
| 114 |
+
setuptools/gui-arm64.exe
|
| 115 |
+
setuptools/gui.exe
|
| 116 |
+
setuptools/installer.py
|
| 117 |
+
setuptools/launch.py
|
| 118 |
+
setuptools/logging.py
|
| 119 |
+
setuptools/modified.py
|
| 120 |
+
setuptools/monkey.py
|
| 121 |
+
setuptools/msvc.py
|
| 122 |
+
setuptools/namespaces.py
|
| 123 |
+
setuptools/script (dev).tmpl
|
| 124 |
+
setuptools/script.tmpl
|
| 125 |
+
setuptools/unicode_utils.py
|
| 126 |
+
setuptools/version.py
|
| 127 |
+
setuptools/warnings.py
|
| 128 |
+
setuptools/wheel.py
|
| 129 |
+
setuptools/windows_support.py
|
| 130 |
+
setuptools.egg-info/PKG-INFO
|
| 131 |
+
setuptools.egg-info/SOURCES.txt
|
| 132 |
+
setuptools.egg-info/dependency_links.txt
|
| 133 |
+
setuptools.egg-info/entry_points.txt
|
| 134 |
+
setuptools.egg-info/requires.txt
|
| 135 |
+
setuptools.egg-info/top_level.txt
|
| 136 |
+
setuptools/_distutils/__init__.py
|
| 137 |
+
setuptools/_distutils/_log.py
|
| 138 |
+
setuptools/_distutils/_macos_compat.py
|
| 139 |
+
setuptools/_distutils/_modified.py
|
| 140 |
+
setuptools/_distutils/_msvccompiler.py
|
| 141 |
+
setuptools/_distutils/archive_util.py
|
| 142 |
+
setuptools/_distutils/ccompiler.py
|
| 143 |
+
setuptools/_distutils/cmd.py
|
| 144 |
+
setuptools/_distutils/core.py
|
| 145 |
+
setuptools/_distutils/cygwinccompiler.py
|
| 146 |
+
setuptools/_distutils/debug.py
|
| 147 |
+
setuptools/_distutils/dep_util.py
|
| 148 |
+
setuptools/_distutils/dir_util.py
|
| 149 |
+
setuptools/_distutils/dist.py
|
| 150 |
+
setuptools/_distutils/errors.py
|
| 151 |
+
setuptools/_distutils/extension.py
|
| 152 |
+
setuptools/_distutils/fancy_getopt.py
|
| 153 |
+
setuptools/_distutils/file_util.py
|
| 154 |
+
setuptools/_distutils/filelist.py
|
| 155 |
+
setuptools/_distutils/log.py
|
| 156 |
+
setuptools/_distutils/spawn.py
|
| 157 |
+
setuptools/_distutils/sysconfig.py
|
| 158 |
+
setuptools/_distutils/text_file.py
|
| 159 |
+
setuptools/_distutils/unixccompiler.py
|
| 160 |
+
setuptools/_distutils/util.py
|
| 161 |
+
setuptools/_distutils/version.py
|
| 162 |
+
setuptools/_distutils/versionpredicate.py
|
| 163 |
+
setuptools/_distutils/zosccompiler.py
|
| 164 |
+
setuptools/_distutils/command/__init__.py
|
| 165 |
+
setuptools/_distutils/command/_framework_compat.py
|
| 166 |
+
setuptools/_distutils/command/bdist.py
|
| 167 |
+
setuptools/_distutils/command/bdist_dumb.py
|
| 168 |
+
setuptools/_distutils/command/bdist_rpm.py
|
| 169 |
+
setuptools/_distutils/command/build.py
|
| 170 |
+
setuptools/_distutils/command/build_clib.py
|
| 171 |
+
setuptools/_distutils/command/build_ext.py
|
| 172 |
+
setuptools/_distutils/command/build_py.py
|
| 173 |
+
setuptools/_distutils/command/build_scripts.py
|
| 174 |
+
setuptools/_distutils/command/check.py
|
| 175 |
+
setuptools/_distutils/command/clean.py
|
| 176 |
+
setuptools/_distutils/command/config.py
|
| 177 |
+
setuptools/_distutils/command/install.py
|
| 178 |
+
setuptools/_distutils/command/install_data.py
|
| 179 |
+
setuptools/_distutils/command/install_egg_info.py
|
| 180 |
+
setuptools/_distutils/command/install_headers.py
|
| 181 |
+
setuptools/_distutils/command/install_lib.py
|
| 182 |
+
setuptools/_distutils/command/install_scripts.py
|
| 183 |
+
setuptools/_distutils/command/sdist.py
|
| 184 |
+
setuptools/_distutils/compat/__init__.py
|
| 185 |
+
setuptools/_distutils/compat/numpy.py
|
| 186 |
+
setuptools/_distutils/compat/py39.py
|
| 187 |
+
setuptools/_distutils/compilers/C/base.py
|
| 188 |
+
setuptools/_distutils/compilers/C/cygwin.py
|
| 189 |
+
setuptools/_distutils/compilers/C/errors.py
|
| 190 |
+
setuptools/_distutils/compilers/C/msvc.py
|
| 191 |
+
setuptools/_distutils/compilers/C/unix.py
|
| 192 |
+
setuptools/_distutils/compilers/C/zos.py
|
| 193 |
+
setuptools/_distutils/compilers/C/tests/test_base.py
|
| 194 |
+
setuptools/_distutils/compilers/C/tests/test_cygwin.py
|
| 195 |
+
setuptools/_distutils/compilers/C/tests/test_mingw.py
|
| 196 |
+
setuptools/_distutils/compilers/C/tests/test_msvc.py
|
| 197 |
+
setuptools/_distutils/compilers/C/tests/test_unix.py
|
| 198 |
+
setuptools/_distutils/tests/__init__.py
|
| 199 |
+
setuptools/_distutils/tests/support.py
|
| 200 |
+
setuptools/_distutils/tests/test_archive_util.py
|
| 201 |
+
setuptools/_distutils/tests/test_bdist.py
|
| 202 |
+
setuptools/_distutils/tests/test_bdist_dumb.py
|
| 203 |
+
setuptools/_distutils/tests/test_bdist_rpm.py
|
| 204 |
+
setuptools/_distutils/tests/test_build.py
|
| 205 |
+
setuptools/_distutils/tests/test_build_clib.py
|
| 206 |
+
setuptools/_distutils/tests/test_build_ext.py
|
| 207 |
+
setuptools/_distutils/tests/test_build_py.py
|
| 208 |
+
setuptools/_distutils/tests/test_build_scripts.py
|
| 209 |
+
setuptools/_distutils/tests/test_check.py
|
| 210 |
+
setuptools/_distutils/tests/test_clean.py
|
| 211 |
+
setuptools/_distutils/tests/test_cmd.py
|
| 212 |
+
setuptools/_distutils/tests/test_config_cmd.py
|
| 213 |
+
setuptools/_distutils/tests/test_core.py
|
| 214 |
+
setuptools/_distutils/tests/test_dir_util.py
|
| 215 |
+
setuptools/_distutils/tests/test_dist.py
|
| 216 |
+
setuptools/_distutils/tests/test_extension.py
|
| 217 |
+
setuptools/_distutils/tests/test_file_util.py
|
| 218 |
+
setuptools/_distutils/tests/test_filelist.py
|
| 219 |
+
setuptools/_distutils/tests/test_install.py
|
| 220 |
+
setuptools/_distutils/tests/test_install_data.py
|
| 221 |
+
setuptools/_distutils/tests/test_install_headers.py
|
| 222 |
+
setuptools/_distutils/tests/test_install_lib.py
|
| 223 |
+
setuptools/_distutils/tests/test_install_scripts.py
|
| 224 |
+
setuptools/_distutils/tests/test_log.py
|
| 225 |
+
setuptools/_distutils/tests/test_modified.py
|
| 226 |
+
setuptools/_distutils/tests/test_sdist.py
|
| 227 |
+
setuptools/_distutils/tests/test_spawn.py
|
| 228 |
+
setuptools/_distutils/tests/test_sysconfig.py
|
| 229 |
+
setuptools/_distutils/tests/test_text_file.py
|
| 230 |
+
setuptools/_distutils/tests/test_util.py
|
| 231 |
+
setuptools/_distutils/tests/test_version.py
|
| 232 |
+
setuptools/_distutils/tests/test_versionpredicate.py
|
| 233 |
+
setuptools/_distutils/tests/unix_compat.py
|
| 234 |
+
setuptools/_distutils/tests/compat/__init__.py
|
| 235 |
+
setuptools/_distutils/tests/compat/py39.py
|
| 236 |
+
setuptools/_vendor/.lock
|
| 237 |
+
setuptools/_vendor/ruff.toml
|
| 238 |
+
setuptools/_vendor/autocommand/__init__.py
|
| 239 |
+
setuptools/_vendor/autocommand/autoasync.py
|
| 240 |
+
setuptools/_vendor/autocommand/autocommand.py
|
| 241 |
+
setuptools/_vendor/autocommand/automain.py
|
| 242 |
+
setuptools/_vendor/autocommand/autoparse.py
|
| 243 |
+
setuptools/_vendor/autocommand/errors.py
|
| 244 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/INSTALLER
|
| 245 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/LICENSE
|
| 246 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA
|
| 247 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/RECORD
|
| 248 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/REQUESTED
|
| 249 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/WHEEL
|
| 250 |
+
setuptools/_vendor/autocommand-2.2.2.dist-info/top_level.txt
|
| 251 |
+
setuptools/_vendor/backports/__init__.py
|
| 252 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/INSTALLER
|
| 253 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/LICENSE
|
| 254 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/METADATA
|
| 255 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/RECORD
|
| 256 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/REQUESTED
|
| 257 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/WHEEL
|
| 258 |
+
setuptools/_vendor/backports.tarfile-1.2.0.dist-info/top_level.txt
|
| 259 |
+
setuptools/_vendor/backports/tarfile/__init__.py
|
| 260 |
+
setuptools/_vendor/backports/tarfile/__main__.py
|
| 261 |
+
setuptools/_vendor/backports/tarfile/compat/__init__.py
|
| 262 |
+
setuptools/_vendor/backports/tarfile/compat/py38.py
|
| 263 |
+
setuptools/_vendor/importlib_metadata/__init__.py
|
| 264 |
+
setuptools/_vendor/importlib_metadata/_adapters.py
|
| 265 |
+
setuptools/_vendor/importlib_metadata/_collections.py
|
| 266 |
+
setuptools/_vendor/importlib_metadata/_compat.py
|
| 267 |
+
setuptools/_vendor/importlib_metadata/_functools.py
|
| 268 |
+
setuptools/_vendor/importlib_metadata/_itertools.py
|
| 269 |
+
setuptools/_vendor/importlib_metadata/_meta.py
|
| 270 |
+
setuptools/_vendor/importlib_metadata/_text.py
|
| 271 |
+
setuptools/_vendor/importlib_metadata/_typing.py
|
| 272 |
+
setuptools/_vendor/importlib_metadata/diagnose.py
|
| 273 |
+
setuptools/_vendor/importlib_metadata/py.typed
|
| 274 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/INSTALLER
|
| 275 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/METADATA
|
| 276 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/RECORD
|
| 277 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/REQUESTED
|
| 278 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/WHEEL
|
| 279 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/top_level.txt
|
| 280 |
+
setuptools/_vendor/importlib_metadata-8.7.1.dist-info/licenses/LICENSE
|
| 281 |
+
setuptools/_vendor/importlib_metadata/compat/__init__.py
|
| 282 |
+
setuptools/_vendor/importlib_metadata/compat/py311.py
|
| 283 |
+
setuptools/_vendor/importlib_metadata/compat/py39.py
|
| 284 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/INSTALLER
|
| 285 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/LICENSE
|
| 286 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/METADATA
|
| 287 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/RECORD
|
| 288 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/REQUESTED
|
| 289 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/WHEEL
|
| 290 |
+
setuptools/_vendor/jaraco.text-4.0.0.dist-info/top_level.txt
|
| 291 |
+
setuptools/_vendor/jaraco/context/__init__.py
|
| 292 |
+
setuptools/_vendor/jaraco/context/py.typed
|
| 293 |
+
setuptools/_vendor/jaraco/functools/__init__.py
|
| 294 |
+
setuptools/_vendor/jaraco/functools/__init__.pyi
|
| 295 |
+
setuptools/_vendor/jaraco/functools/py.typed
|
| 296 |
+
setuptools/_vendor/jaraco/text/Lorem ipsum.txt
|
| 297 |
+
setuptools/_vendor/jaraco/text/__init__.py
|
| 298 |
+
setuptools/_vendor/jaraco/text/layouts.py
|
| 299 |
+
setuptools/_vendor/jaraco/text/show-newlines.py
|
| 300 |
+
setuptools/_vendor/jaraco/text/strip-prefix.py
|
| 301 |
+
setuptools/_vendor/jaraco/text/to-dvorak.py
|
| 302 |
+
setuptools/_vendor/jaraco/text/to-qwerty.py
|
| 303 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/INSTALLER
|
| 304 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/METADATA
|
| 305 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/RECORD
|
| 306 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/REQUESTED
|
| 307 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/WHEEL
|
| 308 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/top_level.txt
|
| 309 |
+
setuptools/_vendor/jaraco_context-6.1.0.dist-info/licenses/LICENSE
|
| 310 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/INSTALLER
|
| 311 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/METADATA
|
| 312 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/RECORD
|
| 313 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/REQUESTED
|
| 314 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/WHEEL
|
| 315 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/top_level.txt
|
| 316 |
+
setuptools/_vendor/jaraco_functools-4.4.0.dist-info/licenses/LICENSE
|
| 317 |
+
setuptools/_vendor/more_itertools/__init__.py
|
| 318 |
+
setuptools/_vendor/more_itertools/__init__.pyi
|
| 319 |
+
setuptools/_vendor/more_itertools/more.py
|
| 320 |
+
setuptools/_vendor/more_itertools/more.pyi
|
| 321 |
+
setuptools/_vendor/more_itertools/py.typed
|
| 322 |
+
setuptools/_vendor/more_itertools/recipes.py
|
| 323 |
+
setuptools/_vendor/more_itertools/recipes.pyi
|
| 324 |
+
setuptools/_vendor/more_itertools-10.8.0.dist-info/INSTALLER
|
| 325 |
+
setuptools/_vendor/more_itertools-10.8.0.dist-info/METADATA
|
| 326 |
+
setuptools/_vendor/more_itertools-10.8.0.dist-info/RECORD
|
| 327 |
+
setuptools/_vendor/more_itertools-10.8.0.dist-info/REQUESTED
|
| 328 |
+
setuptools/_vendor/more_itertools-10.8.0.dist-info/WHEEL
|
| 329 |
+
setuptools/_vendor/more_itertools-10.8.0.dist-info/licenses/LICENSE
|
| 330 |
+
setuptools/_vendor/packaging/__init__.py
|
| 331 |
+
setuptools/_vendor/packaging/_elffile.py
|
| 332 |
+
setuptools/_vendor/packaging/_manylinux.py
|
| 333 |
+
setuptools/_vendor/packaging/_musllinux.py
|
| 334 |
+
setuptools/_vendor/packaging/_parser.py
|
| 335 |
+
setuptools/_vendor/packaging/_structures.py
|
| 336 |
+
setuptools/_vendor/packaging/_tokenizer.py
|
| 337 |
+
setuptools/_vendor/packaging/markers.py
|
| 338 |
+
setuptools/_vendor/packaging/metadata.py
|
| 339 |
+
setuptools/_vendor/packaging/py.typed
|
| 340 |
+
setuptools/_vendor/packaging/pylock.py
|
| 341 |
+
setuptools/_vendor/packaging/requirements.py
|
| 342 |
+
setuptools/_vendor/packaging/specifiers.py
|
| 343 |
+
setuptools/_vendor/packaging/tags.py
|
| 344 |
+
setuptools/_vendor/packaging/utils.py
|
| 345 |
+
setuptools/_vendor/packaging/version.py
|
| 346 |
+
setuptools/_vendor/packaging-26.0.dist-info/INSTALLER
|
| 347 |
+
setuptools/_vendor/packaging-26.0.dist-info/METADATA
|
| 348 |
+
setuptools/_vendor/packaging-26.0.dist-info/RECORD
|
| 349 |
+
setuptools/_vendor/packaging-26.0.dist-info/REQUESTED
|
| 350 |
+
setuptools/_vendor/packaging-26.0.dist-info/WHEEL
|
| 351 |
+
setuptools/_vendor/packaging-26.0.dist-info/licenses/LICENSE
|
| 352 |
+
setuptools/_vendor/packaging-26.0.dist-info/licenses/LICENSE.APACHE
|
| 353 |
+
setuptools/_vendor/packaging-26.0.dist-info/licenses/LICENSE.BSD
|
| 354 |
+
setuptools/_vendor/packaging/licenses/__init__.py
|
| 355 |
+
setuptools/_vendor/packaging/licenses/_spdx.py
|
| 356 |
+
setuptools/_vendor/platformdirs/__init__.py
|
| 357 |
+
setuptools/_vendor/platformdirs/__main__.py
|
| 358 |
+
setuptools/_vendor/platformdirs/android.py
|
| 359 |
+
setuptools/_vendor/platformdirs/api.py
|
| 360 |
+
setuptools/_vendor/platformdirs/macos.py
|
| 361 |
+
setuptools/_vendor/platformdirs/py.typed
|
| 362 |
+
setuptools/_vendor/platformdirs/unix.py
|
| 363 |
+
setuptools/_vendor/platformdirs/version.py
|
| 364 |
+
setuptools/_vendor/platformdirs/windows.py
|
| 365 |
+
setuptools/_vendor/platformdirs-4.4.0.dist-info/INSTALLER
|
| 366 |
+
setuptools/_vendor/platformdirs-4.4.0.dist-info/METADATA
|
| 367 |
+
setuptools/_vendor/platformdirs-4.4.0.dist-info/RECORD
|
| 368 |
+
setuptools/_vendor/platformdirs-4.4.0.dist-info/REQUESTED
|
| 369 |
+
setuptools/_vendor/platformdirs-4.4.0.dist-info/WHEEL
|
| 370 |
+
setuptools/_vendor/platformdirs-4.4.0.dist-info/licenses/LICENSE
|
| 371 |
+
setuptools/_vendor/tomli/__init__.py
|
| 372 |
+
setuptools/_vendor/tomli/_parser.py
|
| 373 |
+
setuptools/_vendor/tomli/_re.py
|
| 374 |
+
setuptools/_vendor/tomli/_types.py
|
| 375 |
+
setuptools/_vendor/tomli/py.typed
|
| 376 |
+
setuptools/_vendor/tomli-2.4.0.dist-info/INSTALLER
|
| 377 |
+
setuptools/_vendor/tomli-2.4.0.dist-info/METADATA
|
| 378 |
+
setuptools/_vendor/tomli-2.4.0.dist-info/RECORD
|
| 379 |
+
setuptools/_vendor/tomli-2.4.0.dist-info/REQUESTED
|
| 380 |
+
setuptools/_vendor/tomli-2.4.0.dist-info/WHEEL
|
| 381 |
+
setuptools/_vendor/tomli-2.4.0.dist-info/licenses/LICENSE
|
| 382 |
+
setuptools/_vendor/wheel/__init__.py
|
| 383 |
+
setuptools/_vendor/wheel/__main__.py
|
| 384 |
+
setuptools/_vendor/wheel/_bdist_wheel.py
|
| 385 |
+
setuptools/_vendor/wheel/_metadata.py
|
| 386 |
+
setuptools/_vendor/wheel/_setuptools_logging.py
|
| 387 |
+
setuptools/_vendor/wheel/bdist_wheel.py
|
| 388 |
+
setuptools/_vendor/wheel/macosx_libfile.py
|
| 389 |
+
setuptools/_vendor/wheel/metadata.py
|
| 390 |
+
setuptools/_vendor/wheel/wheelfile.py
|
| 391 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/INSTALLER
|
| 392 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/METADATA
|
| 393 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/RECORD
|
| 394 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/REQUESTED
|
| 395 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/WHEEL
|
| 396 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/entry_points.txt
|
| 397 |
+
setuptools/_vendor/wheel-0.46.3.dist-info/licenses/LICENSE.txt
|
| 398 |
+
setuptools/_vendor/wheel/_commands/__init__.py
|
| 399 |
+
setuptools/_vendor/wheel/_commands/convert.py
|
| 400 |
+
setuptools/_vendor/wheel/_commands/pack.py
|
| 401 |
+
setuptools/_vendor/wheel/_commands/tags.py
|
| 402 |
+
setuptools/_vendor/wheel/_commands/unpack.py
|
| 403 |
+
setuptools/_vendor/zipp/__init__.py
|
| 404 |
+
setuptools/_vendor/zipp/_functools.py
|
| 405 |
+
setuptools/_vendor/zipp/glob.py
|
| 406 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/INSTALLER
|
| 407 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/METADATA
|
| 408 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/RECORD
|
| 409 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/REQUESTED
|
| 410 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/WHEEL
|
| 411 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/top_level.txt
|
| 412 |
+
setuptools/_vendor/zipp-3.23.0.dist-info/licenses/LICENSE
|
| 413 |
+
setuptools/_vendor/zipp/compat/__init__.py
|
| 414 |
+
setuptools/_vendor/zipp/compat/overlay.py
|
| 415 |
+
setuptools/_vendor/zipp/compat/py310.py
|
| 416 |
+
setuptools/_vendor/zipp/compat/py313.py
|
| 417 |
+
setuptools/command/__init__.py
|
| 418 |
+
setuptools/command/_requirestxt.py
|
| 419 |
+
setuptools/command/alias.py
|
| 420 |
+
setuptools/command/bdist_egg.py
|
| 421 |
+
setuptools/command/bdist_rpm.py
|
| 422 |
+
setuptools/command/bdist_wheel.py
|
| 423 |
+
setuptools/command/build.py
|
| 424 |
+
setuptools/command/build_clib.py
|
| 425 |
+
setuptools/command/build_ext.py
|
| 426 |
+
setuptools/command/build_py.py
|
| 427 |
+
setuptools/command/develop.py
|
| 428 |
+
setuptools/command/dist_info.py
|
| 429 |
+
setuptools/command/easy_install.py
|
| 430 |
+
setuptools/command/editable_wheel.py
|
| 431 |
+
setuptools/command/egg_info.py
|
| 432 |
+
setuptools/command/install.py
|
| 433 |
+
setuptools/command/install_egg_info.py
|
| 434 |
+
setuptools/command/install_lib.py
|
| 435 |
+
setuptools/command/install_scripts.py
|
| 436 |
+
setuptools/command/launcher manifest.xml
|
| 437 |
+
setuptools/command/rotate.py
|
| 438 |
+
setuptools/command/saveopts.py
|
| 439 |
+
setuptools/command/sdist.py
|
| 440 |
+
setuptools/command/setopt.py
|
| 441 |
+
setuptools/command/test.py
|
| 442 |
+
setuptools/compat/__init__.py
|
| 443 |
+
setuptools/compat/py310.py
|
| 444 |
+
setuptools/compat/py311.py
|
| 445 |
+
setuptools/compat/py312.py
|
| 446 |
+
setuptools/compat/py39.py
|
| 447 |
+
setuptools/config/NOTICE
|
| 448 |
+
setuptools/config/__init__.py
|
| 449 |
+
setuptools/config/_apply_pyprojecttoml.py
|
| 450 |
+
setuptools/config/distutils.schema.json
|
| 451 |
+
setuptools/config/expand.py
|
| 452 |
+
setuptools/config/pyprojecttoml.py
|
| 453 |
+
setuptools/config/setupcfg.py
|
| 454 |
+
setuptools/config/setuptools.schema.json
|
| 455 |
+
setuptools/config/_validate_pyproject/NOTICE
|
| 456 |
+
setuptools/config/_validate_pyproject/__init__.py
|
| 457 |
+
setuptools/config/_validate_pyproject/error_reporting.py
|
| 458 |
+
setuptools/config/_validate_pyproject/extra_validations.py
|
| 459 |
+
setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py
|
| 460 |
+
setuptools/config/_validate_pyproject/fastjsonschema_validations.py
|
| 461 |
+
setuptools/config/_validate_pyproject/formats.py
|
| 462 |
+
setuptools/tests/__init__.py
|
| 463 |
+
setuptools/tests/contexts.py
|
| 464 |
+
setuptools/tests/environment.py
|
| 465 |
+
setuptools/tests/fixtures.py
|
| 466 |
+
setuptools/tests/mod_with_constant.py
|
| 467 |
+
setuptools/tests/namespaces.py
|
| 468 |
+
setuptools/tests/script-with-bom.py
|
| 469 |
+
setuptools/tests/test_archive_util.py
|
| 470 |
+
setuptools/tests/test_bdist_deprecations.py
|
| 471 |
+
setuptools/tests/test_bdist_egg.py
|
| 472 |
+
setuptools/tests/test_bdist_wheel.py
|
| 473 |
+
setuptools/tests/test_build.py
|
| 474 |
+
setuptools/tests/test_build_clib.py
|
| 475 |
+
setuptools/tests/test_build_ext.py
|
| 476 |
+
setuptools/tests/test_build_meta.py
|
| 477 |
+
setuptools/tests/test_build_py.py
|
| 478 |
+
setuptools/tests/test_config_discovery.py
|
| 479 |
+
setuptools/tests/test_core_metadata.py
|
| 480 |
+
setuptools/tests/test_depends.py
|
| 481 |
+
setuptools/tests/test_develop.py
|
| 482 |
+
setuptools/tests/test_dist.py
|
| 483 |
+
setuptools/tests/test_dist_info.py
|
| 484 |
+
setuptools/tests/test_distutils_adoption.py
|
| 485 |
+
setuptools/tests/test_editable_install.py
|
| 486 |
+
setuptools/tests/test_egg_info.py
|
| 487 |
+
setuptools/tests/test_extern.py
|
| 488 |
+
setuptools/tests/test_find_packages.py
|
| 489 |
+
setuptools/tests/test_find_py_modules.py
|
| 490 |
+
setuptools/tests/test_glob.py
|
| 491 |
+
setuptools/tests/test_install_scripts.py
|
| 492 |
+
setuptools/tests/test_logging.py
|
| 493 |
+
setuptools/tests/test_manifest.py
|
| 494 |
+
setuptools/tests/test_namespaces.py
|
| 495 |
+
setuptools/tests/test_scripts.py
|
| 496 |
+
setuptools/tests/test_sdist.py
|
| 497 |
+
setuptools/tests/test_setopt.py
|
| 498 |
+
setuptools/tests/test_setuptools.py
|
| 499 |
+
setuptools/tests/test_shutil_wrapper.py
|
| 500 |
+
setuptools/tests/test_unicode_utils.py
|
| 501 |
+
setuptools/tests/test_virtualenv.py
|
| 502 |
+
setuptools/tests/test_warnings.py
|
| 503 |
+
setuptools/tests/test_wheel.py
|
| 504 |
+
setuptools/tests/test_windows_wrappers.py
|
| 505 |
+
setuptools/tests/text.py
|
| 506 |
+
setuptools/tests/textwrap.py
|
| 507 |
+
setuptools/tests/compat/__init__.py
|
| 508 |
+
setuptools/tests/compat/py39.py
|
| 509 |
+
setuptools/tests/config/__init__.py
|
| 510 |
+
setuptools/tests/config/setupcfg_examples.txt
|
| 511 |
+
setuptools/tests/config/test_apply_pyprojecttoml.py
|
| 512 |
+
setuptools/tests/config/test_expand.py
|
| 513 |
+
setuptools/tests/config/test_pyprojecttoml.py
|
| 514 |
+
setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py
|
| 515 |
+
setuptools/tests/config/test_setupcfg.py
|
| 516 |
+
setuptools/tests/config/downloads/__init__.py
|
| 517 |
+
setuptools/tests/config/downloads/preload.py
|
| 518 |
+
setuptools/tests/indexes/test_links_priority/external.html
|
| 519 |
+
setuptools/tests/indexes/test_links_priority/simple/foobar/index.html
|
| 520 |
+
setuptools/tests/integration/__init__.py
|
| 521 |
+
setuptools/tests/integration/helpers.py
|
| 522 |
+
setuptools/tests/integration/test_pbr.py
|
| 523 |
+
setuptools/tests/integration/test_pip_install_sdist.py
|
| 524 |
+
tools/build_launchers.py
|
| 525 |
+
tools/finalize.py
|
| 526 |
+
tools/generate_validation_code.py
|
| 527 |
+
tools/vendored.py
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/entry_points.txt
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[distutils.commands]
|
| 2 |
+
alias = setuptools.command.alias:alias
|
| 3 |
+
bdist_egg = setuptools.command.bdist_egg:bdist_egg
|
| 4 |
+
bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
|
| 5 |
+
bdist_wheel = setuptools.command.bdist_wheel:bdist_wheel
|
| 6 |
+
build = setuptools.command.build:build
|
| 7 |
+
build_clib = setuptools.command.build_clib:build_clib
|
| 8 |
+
build_ext = setuptools.command.build_ext:build_ext
|
| 9 |
+
build_py = setuptools.command.build_py:build_py
|
| 10 |
+
develop = setuptools.command.develop:develop
|
| 11 |
+
dist_info = setuptools.command.dist_info:dist_info
|
| 12 |
+
easy_install = setuptools.command.easy_install:easy_install
|
| 13 |
+
editable_wheel = setuptools.command.editable_wheel:editable_wheel
|
| 14 |
+
egg_info = setuptools.command.egg_info:egg_info
|
| 15 |
+
install = setuptools.command.install:install
|
| 16 |
+
install_egg_info = setuptools.command.install_egg_info:install_egg_info
|
| 17 |
+
install_lib = setuptools.command.install_lib:install_lib
|
| 18 |
+
install_scripts = setuptools.command.install_scripts:install_scripts
|
| 19 |
+
rotate = setuptools.command.rotate:rotate
|
| 20 |
+
saveopts = setuptools.command.saveopts:saveopts
|
| 21 |
+
sdist = setuptools.command.sdist:sdist
|
| 22 |
+
setopt = setuptools.command.setopt:setopt
|
| 23 |
+
|
| 24 |
+
[distutils.setup_keywords]
|
| 25 |
+
dependency_links = setuptools.dist:assert_string_list
|
| 26 |
+
eager_resources = setuptools.dist:assert_string_list
|
| 27 |
+
entry_points = setuptools.dist:check_entry_points
|
| 28 |
+
exclude_package_data = setuptools.dist:check_package_data
|
| 29 |
+
extras_require = setuptools.dist:check_extras
|
| 30 |
+
include_package_data = setuptools.dist:assert_bool
|
| 31 |
+
install_requires = setuptools.dist:check_requirements
|
| 32 |
+
namespace_packages = setuptools.dist:check_nsp
|
| 33 |
+
package_data = setuptools.dist:check_package_data
|
| 34 |
+
packages = setuptools.dist:check_packages
|
| 35 |
+
python_requires = setuptools.dist:check_specifier
|
| 36 |
+
setup_requires = setuptools.dist:check_requirements
|
| 37 |
+
use_2to3 = setuptools.dist:invalid_unless_false
|
| 38 |
+
zip_safe = setuptools.dist:assert_bool
|
| 39 |
+
|
| 40 |
+
[egg_info.writers]
|
| 41 |
+
PKG-INFO = setuptools.command.egg_info:write_pkg_info
|
| 42 |
+
dependency_links.txt = setuptools.command.egg_info:overwrite_arg
|
| 43 |
+
eager_resources.txt = setuptools.command.egg_info:overwrite_arg
|
| 44 |
+
entry_points.txt = setuptools.command.egg_info:write_entries
|
| 45 |
+
namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
|
| 46 |
+
requires.txt = setuptools.command.egg_info:write_requirements
|
| 47 |
+
top_level.txt = setuptools.command.egg_info:write_toplevel_names
|
| 48 |
+
|
| 49 |
+
[setuptools.finalize_distribution_options]
|
| 50 |
+
keywords = setuptools.dist:Distribution._finalize_setup_keywords
|
| 51 |
+
parent_finalize = setuptools.dist:_Distribution.finalize_options
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/requires.txt
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
[certs]
|
| 3 |
+
|
| 4 |
+
[check]
|
| 5 |
+
pytest-checkdocs>=2.4
|
| 6 |
+
|
| 7 |
+
[check:sys_platform != "cygwin"]
|
| 8 |
+
pytest-ruff>=0.2.1
|
| 9 |
+
ruff>=0.8.0
|
| 10 |
+
|
| 11 |
+
[core]
|
| 12 |
+
packaging>=24.2
|
| 13 |
+
more_itertools>=8.8
|
| 14 |
+
jaraco.text>=3.7
|
| 15 |
+
wheel>=0.43.0
|
| 16 |
+
platformdirs>=4.2.2
|
| 17 |
+
jaraco.functools>=4
|
| 18 |
+
more_itertools
|
| 19 |
+
|
| 20 |
+
[core:python_version < "3.10"]
|
| 21 |
+
importlib_metadata>=6
|
| 22 |
+
|
| 23 |
+
[core:python_version < "3.11"]
|
| 24 |
+
tomli>=2.0.1
|
| 25 |
+
|
| 26 |
+
[cover]
|
| 27 |
+
pytest-cov
|
| 28 |
+
|
| 29 |
+
[doc]
|
| 30 |
+
sphinx>=3.5
|
| 31 |
+
jaraco.packaging>=9.3
|
| 32 |
+
rst.linker>=1.9
|
| 33 |
+
furo
|
| 34 |
+
sphinx-lint
|
| 35 |
+
jaraco.tidelift>=1.4
|
| 36 |
+
pygments-github-lexers==0.0.5
|
| 37 |
+
sphinx-favicon
|
| 38 |
+
sphinx-inline-tabs
|
| 39 |
+
sphinx-reredirects
|
| 40 |
+
sphinxcontrib-towncrier
|
| 41 |
+
sphinx-notfound-page<2,>=1
|
| 42 |
+
pyproject-hooks!=1.1
|
| 43 |
+
towncrier<24.7
|
| 44 |
+
|
| 45 |
+
[enabler]
|
| 46 |
+
pytest-enabler>=2.2
|
| 47 |
+
|
| 48 |
+
[ssl]
|
| 49 |
+
|
| 50 |
+
[test]
|
| 51 |
+
pytest!=8.1.*,>=6
|
| 52 |
+
virtualenv>=13.0.0
|
| 53 |
+
wheel>=0.44.0
|
| 54 |
+
pip>=19.1
|
| 55 |
+
packaging>=24.2
|
| 56 |
+
jaraco.envs>=2.2
|
| 57 |
+
pytest-xdist>=3
|
| 58 |
+
jaraco.path>=3.7.2
|
| 59 |
+
build[virtualenv]>=1.0.3
|
| 60 |
+
filelock>=3.4.0
|
| 61 |
+
ini2toml[lite]>=0.14
|
| 62 |
+
tomli-w>=1.0.0
|
| 63 |
+
pytest-timeout
|
| 64 |
+
pytest-home>=0.5
|
| 65 |
+
pytest-subprocess
|
| 66 |
+
pyproject-hooks!=1.1
|
| 67 |
+
jaraco.test>=5.5
|
| 68 |
+
|
| 69 |
+
[test:python_version >= "3.9" and sys_platform != "cygwin"]
|
| 70 |
+
jaraco.develop>=7.21
|
| 71 |
+
|
| 72 |
+
[test:sys_platform != "cygwin"]
|
| 73 |
+
pytest-perf
|
| 74 |
+
|
| 75 |
+
[type]
|
| 76 |
+
pytest-mypy
|
| 77 |
+
mypy==1.14.*
|
| 78 |
+
|
| 79 |
+
[type:python_version < "3.10"]
|
| 80 |
+
importlib_metadata>=7.0.2
|
| 81 |
+
|
| 82 |
+
[type:sys_platform != "cygwin"]
|
| 83 |
+
jaraco.develop>=7.21
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools-80.10.2-py3.10.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_distutils_hack
|
| 2 |
+
pkg_resources
|
| 3 |
+
setuptools
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/__init__.py
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Extensions to the 'distutils' for large or complex distributions"""
|
| 2 |
+
# mypy: disable_error_code=override
|
| 3 |
+
# Command.reinitialize_command has an extra **kw param that distutils doesn't have
|
| 4 |
+
# Can't disable on the exact line because distutils doesn't exists on Python 3.12
|
| 5 |
+
# and mypy isn't aware of distutils_hack, causing distutils.core.Command to be Any,
|
| 6 |
+
# and a [unused-ignore] to be raised on 3.12+
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import functools
|
| 11 |
+
import os
|
| 12 |
+
import sys
|
| 13 |
+
from abc import abstractmethod
|
| 14 |
+
from collections.abc import Mapping
|
| 15 |
+
from typing import TYPE_CHECKING, TypeVar, overload
|
| 16 |
+
|
| 17 |
+
sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
|
| 18 |
+
# workaround for #4476
|
| 19 |
+
sys.modules.pop('backports', None)
|
| 20 |
+
|
| 21 |
+
import _distutils_hack.override # noqa: F401
|
| 22 |
+
|
| 23 |
+
from . import logging, monkey
|
| 24 |
+
from .depends import Require
|
| 25 |
+
from .discovery import PackageFinder, PEP420PackageFinder
|
| 26 |
+
from .dist import Distribution
|
| 27 |
+
from .extension import Extension
|
| 28 |
+
from .version import __version__ as __version__
|
| 29 |
+
from .warnings import SetuptoolsDeprecationWarning
|
| 30 |
+
|
| 31 |
+
import distutils.core
|
| 32 |
+
|
| 33 |
+
__all__ = [
|
| 34 |
+
'setup',
|
| 35 |
+
'Distribution',
|
| 36 |
+
'Command',
|
| 37 |
+
'Extension',
|
| 38 |
+
'Require',
|
| 39 |
+
'SetuptoolsDeprecationWarning',
|
| 40 |
+
'find_packages',
|
| 41 |
+
'find_namespace_packages',
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
_CommandT = TypeVar("_CommandT", bound="_Command")
|
| 45 |
+
|
| 46 |
+
bootstrap_install_from = None
|
| 47 |
+
|
| 48 |
+
find_packages = PackageFinder.find
|
| 49 |
+
find_namespace_packages = PEP420PackageFinder.find
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _install_setup_requires(attrs):
|
| 53 |
+
# Note: do not use `setuptools.Distribution` directly, as
|
| 54 |
+
# our PEP 517 backend patch `distutils.core.Distribution`.
|
| 55 |
+
class MinimalDistribution(distutils.core.Distribution):
|
| 56 |
+
"""
|
| 57 |
+
A minimal version of a distribution for supporting the
|
| 58 |
+
fetch_build_eggs interface.
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
def __init__(self, attrs: Mapping[str, object]) -> None:
|
| 62 |
+
_incl = 'dependency_links', 'setup_requires'
|
| 63 |
+
filtered = {k: attrs[k] for k in set(_incl) & set(attrs)}
|
| 64 |
+
super().__init__(filtered)
|
| 65 |
+
# Prevent accidentally triggering discovery with incomplete set of attrs
|
| 66 |
+
self.set_defaults._disable()
|
| 67 |
+
|
| 68 |
+
def _get_project_config_files(self, filenames=None):
|
| 69 |
+
"""Ignore ``pyproject.toml``, they are not related to setup_requires"""
|
| 70 |
+
try:
|
| 71 |
+
cfg, _toml = super()._split_standard_project_metadata(filenames)
|
| 72 |
+
except Exception:
|
| 73 |
+
return filenames, ()
|
| 74 |
+
return cfg, ()
|
| 75 |
+
|
| 76 |
+
def finalize_options(self):
|
| 77 |
+
"""
|
| 78 |
+
Disable finalize_options to avoid building the working set.
|
| 79 |
+
Ref #2158.
|
| 80 |
+
"""
|
| 81 |
+
|
| 82 |
+
dist = MinimalDistribution(attrs)
|
| 83 |
+
|
| 84 |
+
# Honor setup.cfg's options.
|
| 85 |
+
dist.parse_config_files(ignore_option_errors=True)
|
| 86 |
+
if dist.setup_requires:
|
| 87 |
+
_fetch_build_eggs(dist)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def _fetch_build_eggs(dist: Distribution):
|
| 91 |
+
try:
|
| 92 |
+
dist.fetch_build_eggs(dist.setup_requires)
|
| 93 |
+
except Exception as ex:
|
| 94 |
+
msg = """
|
| 95 |
+
It is possible a package already installed in your system
|
| 96 |
+
contains an version that is invalid according to PEP 440.
|
| 97 |
+
You can try `pip install --use-pep517` as a workaround for this problem,
|
| 98 |
+
or rely on a new virtual environment.
|
| 99 |
+
|
| 100 |
+
If the problem refers to a package that is not installed yet,
|
| 101 |
+
please contact that package's maintainers or distributors.
|
| 102 |
+
"""
|
| 103 |
+
if "InvalidVersion" in ex.__class__.__name__:
|
| 104 |
+
if hasattr(ex, "add_note"):
|
| 105 |
+
ex.add_note(msg) # PEP 678
|
| 106 |
+
else:
|
| 107 |
+
dist.announce(f"\n{msg}\n")
|
| 108 |
+
raise
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def setup(**attrs) -> Distribution:
|
| 112 |
+
logging.configure()
|
| 113 |
+
# Make sure we have any requirements needed to interpret 'attrs'.
|
| 114 |
+
_install_setup_requires(attrs)
|
| 115 |
+
# Override return type of distutils.core.Distribution with setuptools.dist.Distribution
|
| 116 |
+
# (implicitly implemented via `setuptools.monkey.patch_all`).
|
| 117 |
+
return distutils.core.setup(**attrs) # type: ignore[return-value]
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
setup.__doc__ = distutils.core.setup.__doc__
|
| 121 |
+
|
| 122 |
+
if TYPE_CHECKING:
|
| 123 |
+
# Work around a mypy issue where type[T] can't be used as a base: https://github.com/python/mypy/issues/10962
|
| 124 |
+
from distutils.core import Command as _Command
|
| 125 |
+
else:
|
| 126 |
+
_Command = monkey.get_unpatched(distutils.core.Command)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
class Command(_Command):
|
| 130 |
+
"""
|
| 131 |
+
Setuptools internal actions are organized using a *command design pattern*.
|
| 132 |
+
This means that each action (or group of closely related actions) executed during
|
| 133 |
+
the build should be implemented as a ``Command`` subclass.
|
| 134 |
+
|
| 135 |
+
These commands are abstractions and do not necessarily correspond to a command that
|
| 136 |
+
can (or should) be executed via a terminal, in a CLI fashion (although historically
|
| 137 |
+
they would).
|
| 138 |
+
|
| 139 |
+
When creating a new command from scratch, custom defined classes **SHOULD** inherit
|
| 140 |
+
from ``setuptools.Command`` and implement a few mandatory methods.
|
| 141 |
+
Between these mandatory methods, are listed:
|
| 142 |
+
:meth:`initialize_options`, :meth:`finalize_options` and :meth:`run`.
|
| 143 |
+
|
| 144 |
+
A useful analogy for command classes is to think of them as subroutines with local
|
| 145 |
+
variables called "options". The options are "declared" in :meth:`initialize_options`
|
| 146 |
+
and "defined" (given their final values, aka "finalized") in :meth:`finalize_options`,
|
| 147 |
+
both of which must be defined by every command class. The "body" of the subroutine,
|
| 148 |
+
(where it does all the work) is the :meth:`run` method.
|
| 149 |
+
Between :meth:`initialize_options` and :meth:`finalize_options`, ``setuptools`` may set
|
| 150 |
+
the values for options/attributes based on user's input (or circumstance),
|
| 151 |
+
which means that the implementation should be careful to not overwrite values in
|
| 152 |
+
:meth:`finalize_options` unless necessary.
|
| 153 |
+
|
| 154 |
+
Please note that other commands (or other parts of setuptools) may also overwrite
|
| 155 |
+
the values of the command's options/attributes multiple times during the build
|
| 156 |
+
process.
|
| 157 |
+
Therefore it is important to consistently implement :meth:`initialize_options` and
|
| 158 |
+
:meth:`finalize_options`. For example, all derived attributes (or attributes that
|
| 159 |
+
depend on the value of other attributes) **SHOULD** be recomputed in
|
| 160 |
+
:meth:`finalize_options`.
|
| 161 |
+
|
| 162 |
+
When overwriting existing commands, custom defined classes **MUST** abide by the
|
| 163 |
+
same APIs implemented by the original class. They also **SHOULD** inherit from the
|
| 164 |
+
original class.
|
| 165 |
+
"""
|
| 166 |
+
|
| 167 |
+
command_consumes_arguments = False
|
| 168 |
+
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
| 169 |
+
|
| 170 |
+
def __init__(self, dist: Distribution, **kw) -> None:
|
| 171 |
+
"""
|
| 172 |
+
Construct the command for dist, updating
|
| 173 |
+
vars(self) with any keyword parameters.
|
| 174 |
+
"""
|
| 175 |
+
super().__init__(dist)
|
| 176 |
+
vars(self).update(kw)
|
| 177 |
+
|
| 178 |
+
@overload
|
| 179 |
+
def reinitialize_command(
|
| 180 |
+
self, command: str, reinit_subcommands: bool = False, **kw
|
| 181 |
+
) -> Command: ... # override distutils.cmd.Command with setuptools.Command
|
| 182 |
+
@overload
|
| 183 |
+
def reinitialize_command(
|
| 184 |
+
self, command: _CommandT, reinit_subcommands: bool = False, **kw
|
| 185 |
+
) -> _CommandT: ...
|
| 186 |
+
def reinitialize_command(
|
| 187 |
+
self, command: str | _Command, reinit_subcommands: bool = False, **kw
|
| 188 |
+
) -> Command | _Command:
|
| 189 |
+
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
|
| 190 |
+
vars(cmd).update(kw)
|
| 191 |
+
return cmd # pyright: ignore[reportReturnType] # pypa/distutils#307
|
| 192 |
+
|
| 193 |
+
@abstractmethod
|
| 194 |
+
def initialize_options(self) -> None:
|
| 195 |
+
"""
|
| 196 |
+
Set or (reset) all options/attributes/caches used by the command
|
| 197 |
+
to their default values. Note that these values may be overwritten during
|
| 198 |
+
the build.
|
| 199 |
+
"""
|
| 200 |
+
raise NotImplementedError
|
| 201 |
+
|
| 202 |
+
@abstractmethod
|
| 203 |
+
def finalize_options(self) -> None:
|
| 204 |
+
"""
|
| 205 |
+
Set final values for all options/attributes used by the command.
|
| 206 |
+
Most of the time, each option/attribute/cache should only be set if it does not
|
| 207 |
+
have any value yet (e.g. ``if self.attr is None: self.attr = val``).
|
| 208 |
+
"""
|
| 209 |
+
raise NotImplementedError
|
| 210 |
+
|
| 211 |
+
@abstractmethod
|
| 212 |
+
def run(self) -> None:
|
| 213 |
+
"""
|
| 214 |
+
Execute the actions intended by the command.
|
| 215 |
+
(Side effects **SHOULD** only take place when :meth:`run` is executed,
|
| 216 |
+
for example, creating new files or writing to the terminal output).
|
| 217 |
+
"""
|
| 218 |
+
raise NotImplementedError
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def _find_all_simple(path):
|
| 222 |
+
"""
|
| 223 |
+
Find all files under 'path'
|
| 224 |
+
"""
|
| 225 |
+
results = (
|
| 226 |
+
os.path.join(base, file)
|
| 227 |
+
for base, dirs, files in os.walk(path, followlinks=True)
|
| 228 |
+
for file in files
|
| 229 |
+
)
|
| 230 |
+
return filter(os.path.isfile, results)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def findall(dir=os.curdir):
|
| 234 |
+
"""
|
| 235 |
+
Find all files under 'dir' and return the list of full filenames.
|
| 236 |
+
Unless dir is '.', return full filenames with dir prepended.
|
| 237 |
+
"""
|
| 238 |
+
files = _find_all_simple(dir)
|
| 239 |
+
if dir == os.curdir:
|
| 240 |
+
make_rel = functools.partial(os.path.relpath, start=dir)
|
| 241 |
+
files = map(make_rel, files)
|
| 242 |
+
return list(files)
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
class sic(str):
|
| 246 |
+
"""Treat this string as-is (https://en.wikipedia.org/wiki/Sic)"""
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
# Apply monkey patches
|
| 250 |
+
monkey.patch_all()
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_core_metadata.py
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Handling of Core Metadata for Python packages (including reading and writing).
|
| 3 |
+
|
| 4 |
+
See: https://packaging.python.org/en/latest/specifications/core-metadata/
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import os
|
| 10 |
+
import stat
|
| 11 |
+
import textwrap
|
| 12 |
+
from email import message_from_file
|
| 13 |
+
from email.message import Message
|
| 14 |
+
from tempfile import NamedTemporaryFile
|
| 15 |
+
|
| 16 |
+
from packaging.markers import Marker
|
| 17 |
+
from packaging.requirements import Requirement
|
| 18 |
+
from packaging.utils import canonicalize_name, canonicalize_version
|
| 19 |
+
from packaging.version import Version
|
| 20 |
+
|
| 21 |
+
from . import _normalization, _reqs
|
| 22 |
+
from ._static import is_static
|
| 23 |
+
from .warnings import SetuptoolsDeprecationWarning
|
| 24 |
+
|
| 25 |
+
from distutils.util import rfc822_escape
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def get_metadata_version(self):
|
| 29 |
+
mv = getattr(self, 'metadata_version', None)
|
| 30 |
+
if mv is None:
|
| 31 |
+
mv = Version('2.4')
|
| 32 |
+
self.metadata_version = mv
|
| 33 |
+
return mv
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def rfc822_unescape(content: str) -> str:
|
| 37 |
+
"""Reverse RFC-822 escaping by removing leading whitespaces from content."""
|
| 38 |
+
lines = content.splitlines()
|
| 39 |
+
if len(lines) == 1:
|
| 40 |
+
return lines[0].lstrip()
|
| 41 |
+
return '\n'.join((lines[0].lstrip(), textwrap.dedent('\n'.join(lines[1:]))))
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _read_field_from_msg(msg: Message, field: str) -> str | None:
|
| 45 |
+
"""Read Message header field."""
|
| 46 |
+
value = msg[field]
|
| 47 |
+
if value == 'UNKNOWN':
|
| 48 |
+
return None
|
| 49 |
+
return value
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _read_field_unescaped_from_msg(msg: Message, field: str) -> str | None:
|
| 53 |
+
"""Read Message header field and apply rfc822_unescape."""
|
| 54 |
+
value = _read_field_from_msg(msg, field)
|
| 55 |
+
if value is None:
|
| 56 |
+
return value
|
| 57 |
+
return rfc822_unescape(value)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _read_list_from_msg(msg: Message, field: str) -> list[str] | None:
|
| 61 |
+
"""Read Message header field and return all results as list."""
|
| 62 |
+
values = msg.get_all(field, None)
|
| 63 |
+
if values == []:
|
| 64 |
+
return None
|
| 65 |
+
return values
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _read_payload_from_msg(msg: Message) -> str | None:
|
| 69 |
+
value = str(msg.get_payload()).strip()
|
| 70 |
+
if value == 'UNKNOWN' or not value:
|
| 71 |
+
return None
|
| 72 |
+
return value
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def read_pkg_file(self, file):
|
| 76 |
+
"""Reads the metadata values from a file object."""
|
| 77 |
+
msg = message_from_file(file)
|
| 78 |
+
|
| 79 |
+
self.metadata_version = Version(msg['metadata-version'])
|
| 80 |
+
self.name = _read_field_from_msg(msg, 'name')
|
| 81 |
+
self.version = _read_field_from_msg(msg, 'version')
|
| 82 |
+
self.description = _read_field_from_msg(msg, 'summary')
|
| 83 |
+
# we are filling author only.
|
| 84 |
+
self.author = _read_field_from_msg(msg, 'author')
|
| 85 |
+
self.maintainer = None
|
| 86 |
+
self.author_email = _read_field_from_msg(msg, 'author-email')
|
| 87 |
+
self.maintainer_email = None
|
| 88 |
+
self.url = _read_field_from_msg(msg, 'home-page')
|
| 89 |
+
self.download_url = _read_field_from_msg(msg, 'download-url')
|
| 90 |
+
self.license = _read_field_unescaped_from_msg(msg, 'license')
|
| 91 |
+
self.license_expression = _read_field_unescaped_from_msg(msg, 'license-expression')
|
| 92 |
+
|
| 93 |
+
self.long_description = _read_field_unescaped_from_msg(msg, 'description')
|
| 94 |
+
if self.long_description is None and self.metadata_version >= Version('2.1'):
|
| 95 |
+
self.long_description = _read_payload_from_msg(msg)
|
| 96 |
+
self.description = _read_field_from_msg(msg, 'summary')
|
| 97 |
+
|
| 98 |
+
if 'keywords' in msg:
|
| 99 |
+
self.keywords = _read_field_from_msg(msg, 'keywords').split(',')
|
| 100 |
+
|
| 101 |
+
self.platforms = _read_list_from_msg(msg, 'platform')
|
| 102 |
+
self.classifiers = _read_list_from_msg(msg, 'classifier')
|
| 103 |
+
|
| 104 |
+
# PEP 314 - these fields only exist in 1.1
|
| 105 |
+
if self.metadata_version == Version('1.1'):
|
| 106 |
+
self.requires = _read_list_from_msg(msg, 'requires')
|
| 107 |
+
self.provides = _read_list_from_msg(msg, 'provides')
|
| 108 |
+
self.obsoletes = _read_list_from_msg(msg, 'obsoletes')
|
| 109 |
+
else:
|
| 110 |
+
self.requires = None
|
| 111 |
+
self.provides = None
|
| 112 |
+
self.obsoletes = None
|
| 113 |
+
|
| 114 |
+
self.license_files = _read_list_from_msg(msg, 'license-file')
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def single_line(val):
|
| 118 |
+
"""
|
| 119 |
+
Quick and dirty validation for Summary pypa/setuptools#1390.
|
| 120 |
+
"""
|
| 121 |
+
if '\n' in val:
|
| 122 |
+
# TODO: Replace with `raise ValueError("newlines not allowed")`
|
| 123 |
+
# after reviewing #2893.
|
| 124 |
+
msg = "newlines are not allowed in `summary` and will break in the future"
|
| 125 |
+
SetuptoolsDeprecationWarning.emit("Invalid config.", msg)
|
| 126 |
+
# due_date is undefined. Controversial change, there was a lot of push back.
|
| 127 |
+
val = val.strip().split('\n')[0]
|
| 128 |
+
return val
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def write_pkg_info(self, base_dir):
|
| 132 |
+
"""Write the PKG-INFO file into the release tree."""
|
| 133 |
+
temp = ""
|
| 134 |
+
final = os.path.join(base_dir, 'PKG-INFO')
|
| 135 |
+
try:
|
| 136 |
+
# Use a temporary file while writing to avoid race conditions
|
| 137 |
+
# (e.g. `importlib.metadata` reading `.egg-info/PKG-INFO`):
|
| 138 |
+
with NamedTemporaryFile("w", encoding="utf-8", dir=base_dir, delete=False) as f:
|
| 139 |
+
temp = f.name
|
| 140 |
+
self.write_pkg_file(f)
|
| 141 |
+
permissions = stat.S_IMODE(os.lstat(temp).st_mode)
|
| 142 |
+
os.chmod(temp, permissions | stat.S_IRGRP | stat.S_IROTH)
|
| 143 |
+
os.replace(temp, final) # atomic operation.
|
| 144 |
+
finally:
|
| 145 |
+
if temp and os.path.exists(temp):
|
| 146 |
+
os.remove(temp)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
# Based on Python 3.5 version
|
| 150 |
+
def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME
|
| 151 |
+
"""Write the PKG-INFO format data to a file object."""
|
| 152 |
+
version = self.get_metadata_version()
|
| 153 |
+
|
| 154 |
+
def write_field(key, value):
|
| 155 |
+
file.write(f"{key}: {value}\n")
|
| 156 |
+
|
| 157 |
+
write_field('Metadata-Version', str(version))
|
| 158 |
+
write_field('Name', self.get_name())
|
| 159 |
+
write_field('Version', self.get_version())
|
| 160 |
+
|
| 161 |
+
summary = self.get_description()
|
| 162 |
+
if summary:
|
| 163 |
+
write_field('Summary', single_line(summary))
|
| 164 |
+
|
| 165 |
+
optional_fields = (
|
| 166 |
+
('Home-page', 'url'),
|
| 167 |
+
('Download-URL', 'download_url'),
|
| 168 |
+
('Author', 'author'),
|
| 169 |
+
('Author-email', 'author_email'),
|
| 170 |
+
('Maintainer', 'maintainer'),
|
| 171 |
+
('Maintainer-email', 'maintainer_email'),
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
for field, attr in optional_fields:
|
| 175 |
+
attr_val = getattr(self, attr, None)
|
| 176 |
+
if attr_val is not None:
|
| 177 |
+
write_field(field, attr_val)
|
| 178 |
+
|
| 179 |
+
if license_expression := self.license_expression:
|
| 180 |
+
write_field('License-Expression', license_expression)
|
| 181 |
+
elif license := self.get_license():
|
| 182 |
+
write_field('License', rfc822_escape(license))
|
| 183 |
+
|
| 184 |
+
for label, url in self.project_urls.items():
|
| 185 |
+
write_field('Project-URL', f'{label}, {url}')
|
| 186 |
+
|
| 187 |
+
keywords = ','.join(self.get_keywords())
|
| 188 |
+
if keywords:
|
| 189 |
+
write_field('Keywords', keywords)
|
| 190 |
+
|
| 191 |
+
platforms = self.get_platforms() or []
|
| 192 |
+
for platform in platforms:
|
| 193 |
+
write_field('Platform', platform)
|
| 194 |
+
|
| 195 |
+
self._write_list(file, 'Classifier', self.get_classifiers())
|
| 196 |
+
|
| 197 |
+
# PEP 314
|
| 198 |
+
self._write_list(file, 'Requires', self.get_requires())
|
| 199 |
+
self._write_list(file, 'Provides', self.get_provides())
|
| 200 |
+
self._write_list(file, 'Obsoletes', self.get_obsoletes())
|
| 201 |
+
|
| 202 |
+
# Setuptools specific for PEP 345
|
| 203 |
+
if hasattr(self, 'python_requires'):
|
| 204 |
+
write_field('Requires-Python', self.python_requires)
|
| 205 |
+
|
| 206 |
+
# PEP 566
|
| 207 |
+
if self.long_description_content_type:
|
| 208 |
+
write_field('Description-Content-Type', self.long_description_content_type)
|
| 209 |
+
|
| 210 |
+
safe_license_files = map(_safe_license_file, self.license_files or [])
|
| 211 |
+
self._write_list(file, 'License-File', safe_license_files)
|
| 212 |
+
_write_requirements(self, file)
|
| 213 |
+
|
| 214 |
+
for field, attr in _POSSIBLE_DYNAMIC_FIELDS.items():
|
| 215 |
+
if (val := getattr(self, attr, None)) and not is_static(val):
|
| 216 |
+
write_field('Dynamic', field)
|
| 217 |
+
|
| 218 |
+
long_description = self.get_long_description()
|
| 219 |
+
if long_description:
|
| 220 |
+
file.write(f"\n{long_description}")
|
| 221 |
+
if not long_description.endswith("\n"):
|
| 222 |
+
file.write("\n")
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def _write_requirements(self, file):
|
| 226 |
+
for req in _reqs.parse(self.install_requires):
|
| 227 |
+
file.write(f"Requires-Dist: {req}\n")
|
| 228 |
+
|
| 229 |
+
processed_extras = {}
|
| 230 |
+
for augmented_extra, reqs in self.extras_require.items():
|
| 231 |
+
# Historically, setuptools allows "augmented extras": `<extra>:<condition>`
|
| 232 |
+
unsafe_extra, _, condition = augmented_extra.partition(":")
|
| 233 |
+
unsafe_extra = unsafe_extra.strip()
|
| 234 |
+
extra = _normalization.safe_extra(unsafe_extra)
|
| 235 |
+
|
| 236 |
+
if extra:
|
| 237 |
+
_write_provides_extra(file, processed_extras, extra, unsafe_extra)
|
| 238 |
+
for req in _reqs.parse_strings(reqs):
|
| 239 |
+
r = _include_extra(req, extra, condition.strip())
|
| 240 |
+
file.write(f"Requires-Dist: {r}\n")
|
| 241 |
+
|
| 242 |
+
return processed_extras
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def _include_extra(req: str, extra: str, condition: str) -> Requirement:
|
| 246 |
+
r = Requirement(req) # create a fresh object that can be modified
|
| 247 |
+
parts = (
|
| 248 |
+
f"({r.marker})" if r.marker else None,
|
| 249 |
+
f"({condition})" if condition else None,
|
| 250 |
+
f"extra == {extra!r}" if extra else None,
|
| 251 |
+
)
|
| 252 |
+
r.marker = Marker(" and ".join(x for x in parts if x))
|
| 253 |
+
return r
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
def _write_provides_extra(file, processed_extras, safe, unsafe):
|
| 257 |
+
previous = processed_extras.get(safe)
|
| 258 |
+
if previous == unsafe:
|
| 259 |
+
SetuptoolsDeprecationWarning.emit(
|
| 260 |
+
'Ambiguity during "extra" normalization for dependencies.',
|
| 261 |
+
f"""
|
| 262 |
+
{previous!r} and {unsafe!r} normalize to the same value:\n
|
| 263 |
+
{safe!r}\n
|
| 264 |
+
In future versions, setuptools might halt the build process.
|
| 265 |
+
""",
|
| 266 |
+
see_url="https://peps.python.org/pep-0685/",
|
| 267 |
+
)
|
| 268 |
+
else:
|
| 269 |
+
processed_extras[safe] = unsafe
|
| 270 |
+
file.write(f"Provides-Extra: {safe}\n")
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
# from pypa/distutils#244; needed only until that logic is always available
|
| 274 |
+
def get_fullname(self):
|
| 275 |
+
return _distribution_fullname(self.get_name(), self.get_version())
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def _distribution_fullname(name: str, version: str) -> str:
|
| 279 |
+
"""
|
| 280 |
+
>>> _distribution_fullname('setup.tools', '1.0-2')
|
| 281 |
+
'setup_tools-1.0.post2'
|
| 282 |
+
>>> _distribution_fullname('setup-tools', '1.2post2')
|
| 283 |
+
'setup_tools-1.2.post2'
|
| 284 |
+
>>> _distribution_fullname('setup-tools', '1.0-r2')
|
| 285 |
+
'setup_tools-1.0.post2'
|
| 286 |
+
>>> _distribution_fullname('setup.tools', '1.0.post')
|
| 287 |
+
'setup_tools-1.0.post0'
|
| 288 |
+
>>> _distribution_fullname('setup.tools', '1.0+ubuntu-1')
|
| 289 |
+
'setup_tools-1.0+ubuntu.1'
|
| 290 |
+
"""
|
| 291 |
+
return "{}-{}".format(
|
| 292 |
+
canonicalize_name(name).replace('-', '_'),
|
| 293 |
+
canonicalize_version(version, strip_trailing_zero=False),
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def _safe_license_file(file):
|
| 298 |
+
# XXX: Do we need this after the deprecation discussed in #4892, #4896??
|
| 299 |
+
normalized = os.path.normpath(file).replace(os.sep, "/")
|
| 300 |
+
if "../" in normalized:
|
| 301 |
+
return os.path.basename(normalized) # Temporarily restore pre PEP639 behaviour
|
| 302 |
+
return normalized
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
_POSSIBLE_DYNAMIC_FIELDS = {
|
| 306 |
+
# Core Metadata Field x related Distribution attribute
|
| 307 |
+
"author": "author",
|
| 308 |
+
"author-email": "author_email",
|
| 309 |
+
"classifier": "classifiers",
|
| 310 |
+
"description": "long_description",
|
| 311 |
+
"description-content-type": "long_description_content_type",
|
| 312 |
+
"download-url": "download_url",
|
| 313 |
+
"home-page": "url",
|
| 314 |
+
"keywords": "keywords",
|
| 315 |
+
"license": "license",
|
| 316 |
+
# XXX: License-File is complicated because the user gives globs that are expanded
|
| 317 |
+
# during the build. Without special handling it is likely always
|
| 318 |
+
# marked as Dynamic, which is an acceptable outcome according to:
|
| 319 |
+
# https://github.com/pypa/setuptools/issues/4629#issuecomment-2331233677
|
| 320 |
+
"license-file": "license_files",
|
| 321 |
+
"license-expression": "license_expression", # PEP 639
|
| 322 |
+
"maintainer": "maintainer",
|
| 323 |
+
"maintainer-email": "maintainer_email",
|
| 324 |
+
"obsoletes": "obsoletes",
|
| 325 |
+
# "obsoletes-dist": "obsoletes_dist", # NOT USED
|
| 326 |
+
"platform": "platforms",
|
| 327 |
+
"project-url": "project_urls",
|
| 328 |
+
"provides": "provides",
|
| 329 |
+
# "provides-dist": "provides_dist", # NOT USED
|
| 330 |
+
"provides-extra": "extras_require",
|
| 331 |
+
"requires": "requires",
|
| 332 |
+
"requires-dist": "install_requires",
|
| 333 |
+
# "requires-external": "requires_external", # NOT USED
|
| 334 |
+
"requires-python": "python_requires",
|
| 335 |
+
"summary": "description",
|
| 336 |
+
# "supported-platform": "supported_platforms", # NOT USED
|
| 337 |
+
}
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_discovery.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
import operator
|
| 3 |
+
|
| 4 |
+
import packaging.requirements
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# from coherent.build.discovery
|
| 8 |
+
def extras_from_dep(dep):
|
| 9 |
+
try:
|
| 10 |
+
markers = packaging.requirements.Requirement(dep).marker._markers
|
| 11 |
+
except AttributeError:
|
| 12 |
+
markers = ()
|
| 13 |
+
return set(
|
| 14 |
+
marker[2].value
|
| 15 |
+
for marker in markers
|
| 16 |
+
if isinstance(marker, tuple) and marker[0].value == 'extra'
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def extras_from_deps(deps):
|
| 21 |
+
"""
|
| 22 |
+
>>> extras_from_deps(['requests'])
|
| 23 |
+
set()
|
| 24 |
+
>>> extras_from_deps(['pytest; extra == "test"'])
|
| 25 |
+
{'test'}
|
| 26 |
+
>>> sorted(extras_from_deps([
|
| 27 |
+
... 'requests',
|
| 28 |
+
... 'pytest; extra == "test"',
|
| 29 |
+
... 'pytest-cov; extra == "test"',
|
| 30 |
+
... 'sphinx; extra=="doc"']))
|
| 31 |
+
['doc', 'test']
|
| 32 |
+
"""
|
| 33 |
+
return functools.reduce(operator.or_, map(extras_from_dep, deps), set())
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import importlib
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
__version__, _, _ = sys.version.partition(' ')
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
# Allow Debian and pkgsrc (only) to customize system
|
| 9 |
+
# behavior. Ref pypa/distutils#2 and pypa/distutils#16.
|
| 10 |
+
# This hook is deprecated and no other environments
|
| 11 |
+
# should use it.
|
| 12 |
+
importlib.import_module('_distutils_system_mod')
|
| 13 |
+
except ImportError:
|
| 14 |
+
pass
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_log.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
|
| 3 |
+
log = logging.getLogger()
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_macos_compat.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import importlib
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def bypass_compiler_fixup(cmd, args):
|
| 6 |
+
return cmd
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
if sys.platform == 'darwin':
|
| 10 |
+
compiler_fixup = importlib.import_module('_osx_support').compiler_fixup
|
| 11 |
+
else:
|
| 12 |
+
compiler_fixup = bypass_compiler_fixup
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_modified.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Timestamp comparison of files and groups of files."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import functools
|
| 6 |
+
import os.path
|
| 7 |
+
from collections.abc import Callable, Iterable
|
| 8 |
+
from typing import Literal, TypeVar
|
| 9 |
+
|
| 10 |
+
from jaraco.functools import splat
|
| 11 |
+
|
| 12 |
+
from .compat.py39 import zip_strict
|
| 13 |
+
from .errors import DistutilsFileError
|
| 14 |
+
|
| 15 |
+
_SourcesT = TypeVar(
|
| 16 |
+
"_SourcesT", bound="str | bytes | os.PathLike[str] | os.PathLike[bytes]"
|
| 17 |
+
)
|
| 18 |
+
_TargetsT = TypeVar(
|
| 19 |
+
"_TargetsT", bound="str | bytes | os.PathLike[str] | os.PathLike[bytes]"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _newer(source, target):
|
| 24 |
+
return not os.path.exists(target) or (
|
| 25 |
+
os.path.getmtime(source) > os.path.getmtime(target)
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def newer(
|
| 30 |
+
source: str | bytes | os.PathLike[str] | os.PathLike[bytes],
|
| 31 |
+
target: str | bytes | os.PathLike[str] | os.PathLike[bytes],
|
| 32 |
+
) -> bool:
|
| 33 |
+
"""
|
| 34 |
+
Is source modified more recently than target.
|
| 35 |
+
|
| 36 |
+
Returns True if 'source' is modified more recently than
|
| 37 |
+
'target' or if 'target' does not exist.
|
| 38 |
+
|
| 39 |
+
Raises DistutilsFileError if 'source' does not exist.
|
| 40 |
+
"""
|
| 41 |
+
if not os.path.exists(source):
|
| 42 |
+
raise DistutilsFileError(f"file {os.path.abspath(source)!r} does not exist")
|
| 43 |
+
|
| 44 |
+
return _newer(source, target)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def newer_pairwise(
|
| 48 |
+
sources: Iterable[_SourcesT],
|
| 49 |
+
targets: Iterable[_TargetsT],
|
| 50 |
+
newer: Callable[[_SourcesT, _TargetsT], bool] = newer,
|
| 51 |
+
) -> tuple[list[_SourcesT], list[_TargetsT]]:
|
| 52 |
+
"""
|
| 53 |
+
Filter filenames where sources are newer than targets.
|
| 54 |
+
|
| 55 |
+
Walk two filename iterables in parallel, testing if each source is newer
|
| 56 |
+
than its corresponding target. Returns a pair of lists (sources,
|
| 57 |
+
targets) where source is newer than target, according to the semantics
|
| 58 |
+
of 'newer()'.
|
| 59 |
+
"""
|
| 60 |
+
newer_pairs = filter(splat(newer), zip_strict(sources, targets))
|
| 61 |
+
return tuple(map(list, zip(*newer_pairs))) or ([], [])
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def newer_group(
|
| 65 |
+
sources: Iterable[str | bytes | os.PathLike[str] | os.PathLike[bytes]],
|
| 66 |
+
target: str | bytes | os.PathLike[str] | os.PathLike[bytes],
|
| 67 |
+
missing: Literal["error", "ignore", "newer"] = "error",
|
| 68 |
+
) -> bool:
|
| 69 |
+
"""
|
| 70 |
+
Is target out-of-date with respect to any file in sources.
|
| 71 |
+
|
| 72 |
+
Return True if 'target' is out-of-date with respect to any file
|
| 73 |
+
listed in 'sources'. In other words, if 'target' exists and is newer
|
| 74 |
+
than every file in 'sources', return False; otherwise return True.
|
| 75 |
+
``missing`` controls how to handle a missing source file:
|
| 76 |
+
|
| 77 |
+
- error (default): allow the ``stat()`` call to fail.
|
| 78 |
+
- ignore: silently disregard any missing source files.
|
| 79 |
+
- newer: treat missing source files as "target out of date". This
|
| 80 |
+
mode is handy in "dry-run" mode: it will pretend to carry out
|
| 81 |
+
commands that wouldn't work because inputs are missing, but
|
| 82 |
+
that doesn't matter because dry-run won't run the commands.
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
def missing_as_newer(source):
|
| 86 |
+
return missing == 'newer' and not os.path.exists(source)
|
| 87 |
+
|
| 88 |
+
ignored = os.path.exists if missing == 'ignore' else None
|
| 89 |
+
return not os.path.exists(target) or any(
|
| 90 |
+
missing_as_newer(source) or _newer(source, target)
|
| 91 |
+
for source in filter(ignored, sources)
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
newer_pairwise_group = functools.partial(newer_pairwise, newer=newer_group)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/_msvccompiler.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import warnings
|
| 2 |
+
|
| 3 |
+
from .compilers.C import msvc
|
| 4 |
+
|
| 5 |
+
__all__ = ["MSVCCompiler"]
|
| 6 |
+
|
| 7 |
+
MSVCCompiler = msvc.Compiler
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def __getattr__(name):
|
| 11 |
+
if name == '_get_vc_env':
|
| 12 |
+
warnings.warn(
|
| 13 |
+
"_get_vc_env is private; find an alternative (pypa/distutils#340)"
|
| 14 |
+
)
|
| 15 |
+
return msvc._get_vc_env
|
| 16 |
+
raise AttributeError(name)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/archive_util.py
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.archive_util
|
| 2 |
+
|
| 3 |
+
Utility functions for creating archive files (tarballs, zip files,
|
| 4 |
+
that sort of thing)."""
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
from typing import Literal, overload
|
| 10 |
+
|
| 11 |
+
try:
|
| 12 |
+
import zipfile
|
| 13 |
+
except ImportError:
|
| 14 |
+
zipfile = None
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
from ._log import log
|
| 18 |
+
from .dir_util import mkpath
|
| 19 |
+
from .errors import DistutilsExecError
|
| 20 |
+
from .spawn import spawn
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
from pwd import getpwnam
|
| 24 |
+
except ImportError:
|
| 25 |
+
getpwnam = None
|
| 26 |
+
|
| 27 |
+
try:
|
| 28 |
+
from grp import getgrnam
|
| 29 |
+
except ImportError:
|
| 30 |
+
getgrnam = None
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _get_gid(name):
|
| 34 |
+
"""Returns a gid, given a group name."""
|
| 35 |
+
if getgrnam is None or name is None:
|
| 36 |
+
return None
|
| 37 |
+
try:
|
| 38 |
+
result = getgrnam(name)
|
| 39 |
+
except KeyError:
|
| 40 |
+
result = None
|
| 41 |
+
if result is not None:
|
| 42 |
+
return result[2]
|
| 43 |
+
return None
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def _get_uid(name):
|
| 47 |
+
"""Returns an uid, given a user name."""
|
| 48 |
+
if getpwnam is None or name is None:
|
| 49 |
+
return None
|
| 50 |
+
try:
|
| 51 |
+
result = getpwnam(name)
|
| 52 |
+
except KeyError:
|
| 53 |
+
result = None
|
| 54 |
+
if result is not None:
|
| 55 |
+
return result[2]
|
| 56 |
+
return None
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def make_tarball(
|
| 60 |
+
base_name: str,
|
| 61 |
+
base_dir: str | os.PathLike[str],
|
| 62 |
+
compress: Literal["gzip", "bzip2", "xz"] | None = "gzip",
|
| 63 |
+
verbose: bool = False,
|
| 64 |
+
dry_run: bool = False,
|
| 65 |
+
owner: str | None = None,
|
| 66 |
+
group: str | None = None,
|
| 67 |
+
) -> str:
|
| 68 |
+
"""Create a (possibly compressed) tar file from all the files under
|
| 69 |
+
'base_dir'.
|
| 70 |
+
|
| 71 |
+
'compress' must be "gzip" (the default), "bzip2", "xz", or None.
|
| 72 |
+
|
| 73 |
+
'owner' and 'group' can be used to define an owner and a group for the
|
| 74 |
+
archive that is being built. If not provided, the current owner and group
|
| 75 |
+
will be used.
|
| 76 |
+
|
| 77 |
+
The output tar file will be named 'base_dir' + ".tar", possibly plus
|
| 78 |
+
the appropriate compression extension (".gz", ".bz2", ".xz" or ".Z").
|
| 79 |
+
|
| 80 |
+
Returns the output filename.
|
| 81 |
+
"""
|
| 82 |
+
tar_compression = {
|
| 83 |
+
'gzip': 'gz',
|
| 84 |
+
'bzip2': 'bz2',
|
| 85 |
+
'xz': 'xz',
|
| 86 |
+
None: '',
|
| 87 |
+
}
|
| 88 |
+
compress_ext = {'gzip': '.gz', 'bzip2': '.bz2', 'xz': '.xz'}
|
| 89 |
+
|
| 90 |
+
# flags for compression program, each element of list will be an argument
|
| 91 |
+
if compress is not None and compress not in compress_ext.keys():
|
| 92 |
+
raise ValueError(
|
| 93 |
+
"bad value for 'compress': must be None, 'gzip', 'bzip2', 'xz'"
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
archive_name = base_name + '.tar'
|
| 97 |
+
archive_name += compress_ext.get(compress, '')
|
| 98 |
+
|
| 99 |
+
mkpath(os.path.dirname(archive_name), dry_run=dry_run)
|
| 100 |
+
|
| 101 |
+
# creating the tarball
|
| 102 |
+
import tarfile # late import so Python build itself doesn't break
|
| 103 |
+
|
| 104 |
+
log.info('Creating tar archive')
|
| 105 |
+
|
| 106 |
+
uid = _get_uid(owner)
|
| 107 |
+
gid = _get_gid(group)
|
| 108 |
+
|
| 109 |
+
def _set_uid_gid(tarinfo):
|
| 110 |
+
if gid is not None:
|
| 111 |
+
tarinfo.gid = gid
|
| 112 |
+
tarinfo.gname = group
|
| 113 |
+
if uid is not None:
|
| 114 |
+
tarinfo.uid = uid
|
| 115 |
+
tarinfo.uname = owner
|
| 116 |
+
return tarinfo
|
| 117 |
+
|
| 118 |
+
if not dry_run:
|
| 119 |
+
tar = tarfile.open(archive_name, f'w|{tar_compression[compress]}')
|
| 120 |
+
try:
|
| 121 |
+
tar.add(base_dir, filter=_set_uid_gid)
|
| 122 |
+
finally:
|
| 123 |
+
tar.close()
|
| 124 |
+
|
| 125 |
+
return archive_name
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def make_zipfile( # noqa: C901
|
| 129 |
+
base_name: str,
|
| 130 |
+
base_dir: str | os.PathLike[str],
|
| 131 |
+
verbose: bool = False,
|
| 132 |
+
dry_run: bool = False,
|
| 133 |
+
) -> str:
|
| 134 |
+
"""Create a zip file from all the files under 'base_dir'.
|
| 135 |
+
|
| 136 |
+
The output zip file will be named 'base_name' + ".zip". Uses either the
|
| 137 |
+
"zipfile" Python module (if available) or the InfoZIP "zip" utility
|
| 138 |
+
(if installed and found on the default search path). If neither tool is
|
| 139 |
+
available, raises DistutilsExecError. Returns the name of the output zip
|
| 140 |
+
file.
|
| 141 |
+
"""
|
| 142 |
+
zip_filename = base_name + ".zip"
|
| 143 |
+
mkpath(os.path.dirname(zip_filename), dry_run=dry_run)
|
| 144 |
+
|
| 145 |
+
# If zipfile module is not available, try spawning an external
|
| 146 |
+
# 'zip' command.
|
| 147 |
+
if zipfile is None:
|
| 148 |
+
if verbose:
|
| 149 |
+
zipoptions = "-r"
|
| 150 |
+
else:
|
| 151 |
+
zipoptions = "-rq"
|
| 152 |
+
|
| 153 |
+
try:
|
| 154 |
+
spawn(["zip", zipoptions, zip_filename, base_dir], dry_run=dry_run)
|
| 155 |
+
except DistutilsExecError:
|
| 156 |
+
# XXX really should distinguish between "couldn't find
|
| 157 |
+
# external 'zip' command" and "zip failed".
|
| 158 |
+
raise DistutilsExecError(
|
| 159 |
+
f"unable to create zip file '{zip_filename}': "
|
| 160 |
+
"could neither import the 'zipfile' module nor "
|
| 161 |
+
"find a standalone zip utility"
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
else:
|
| 165 |
+
log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir)
|
| 166 |
+
|
| 167 |
+
if not dry_run:
|
| 168 |
+
try:
|
| 169 |
+
zip = zipfile.ZipFile(
|
| 170 |
+
zip_filename, "w", compression=zipfile.ZIP_DEFLATED
|
| 171 |
+
)
|
| 172 |
+
except RuntimeError:
|
| 173 |
+
zip = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_STORED)
|
| 174 |
+
|
| 175 |
+
with zip:
|
| 176 |
+
if base_dir != os.curdir:
|
| 177 |
+
path = os.path.normpath(os.path.join(base_dir, ''))
|
| 178 |
+
zip.write(path, path)
|
| 179 |
+
log.info("adding '%s'", path)
|
| 180 |
+
for dirpath, dirnames, filenames in os.walk(base_dir):
|
| 181 |
+
for name in dirnames:
|
| 182 |
+
path = os.path.normpath(os.path.join(dirpath, name, ''))
|
| 183 |
+
zip.write(path, path)
|
| 184 |
+
log.info("adding '%s'", path)
|
| 185 |
+
for name in filenames:
|
| 186 |
+
path = os.path.normpath(os.path.join(dirpath, name))
|
| 187 |
+
if os.path.isfile(path):
|
| 188 |
+
zip.write(path, path)
|
| 189 |
+
log.info("adding '%s'", path)
|
| 190 |
+
|
| 191 |
+
return zip_filename
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
ARCHIVE_FORMATS = {
|
| 195 |
+
'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
|
| 196 |
+
'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
|
| 197 |
+
'xztar': (make_tarball, [('compress', 'xz')], "xz'ed tar-file"),
|
| 198 |
+
'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"),
|
| 199 |
+
'tar': (make_tarball, [('compress', None)], "uncompressed tar file"),
|
| 200 |
+
'zip': (make_zipfile, [], "ZIP file"),
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def check_archive_formats(formats):
|
| 205 |
+
"""Returns the first format from the 'format' list that is unknown.
|
| 206 |
+
|
| 207 |
+
If all formats are known, returns None
|
| 208 |
+
"""
|
| 209 |
+
for format in formats:
|
| 210 |
+
if format not in ARCHIVE_FORMATS:
|
| 211 |
+
return format
|
| 212 |
+
return None
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
@overload
|
| 216 |
+
def make_archive(
|
| 217 |
+
base_name: str,
|
| 218 |
+
format: str,
|
| 219 |
+
root_dir: str | os.PathLike[str] | bytes | os.PathLike[bytes] | None = None,
|
| 220 |
+
base_dir: str | None = None,
|
| 221 |
+
verbose: bool = False,
|
| 222 |
+
dry_run: bool = False,
|
| 223 |
+
owner: str | None = None,
|
| 224 |
+
group: str | None = None,
|
| 225 |
+
) -> str: ...
|
| 226 |
+
@overload
|
| 227 |
+
def make_archive(
|
| 228 |
+
base_name: str | os.PathLike[str],
|
| 229 |
+
format: str,
|
| 230 |
+
root_dir: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 231 |
+
base_dir: str | None = None,
|
| 232 |
+
verbose: bool = False,
|
| 233 |
+
dry_run: bool = False,
|
| 234 |
+
owner: str | None = None,
|
| 235 |
+
group: str | None = None,
|
| 236 |
+
) -> str: ...
|
| 237 |
+
def make_archive(
|
| 238 |
+
base_name: str | os.PathLike[str],
|
| 239 |
+
format: str,
|
| 240 |
+
root_dir: str | os.PathLike[str] | bytes | os.PathLike[bytes] | None = None,
|
| 241 |
+
base_dir: str | None = None,
|
| 242 |
+
verbose: bool = False,
|
| 243 |
+
dry_run: bool = False,
|
| 244 |
+
owner: str | None = None,
|
| 245 |
+
group: str | None = None,
|
| 246 |
+
) -> str:
|
| 247 |
+
"""Create an archive file (eg. zip or tar).
|
| 248 |
+
|
| 249 |
+
'base_name' is the name of the file to create, minus any format-specific
|
| 250 |
+
extension; 'format' is the archive format: one of "zip", "tar", "gztar",
|
| 251 |
+
"bztar", "xztar", or "ztar".
|
| 252 |
+
|
| 253 |
+
'root_dir' is a directory that will be the root directory of the
|
| 254 |
+
archive; ie. we typically chdir into 'root_dir' before creating the
|
| 255 |
+
archive. 'base_dir' is the directory where we start archiving from;
|
| 256 |
+
ie. 'base_dir' will be the common prefix of all files and
|
| 257 |
+
directories in the archive. 'root_dir' and 'base_dir' both default
|
| 258 |
+
to the current directory. Returns the name of the archive file.
|
| 259 |
+
|
| 260 |
+
'owner' and 'group' are used when creating a tar archive. By default,
|
| 261 |
+
uses the current owner and group.
|
| 262 |
+
"""
|
| 263 |
+
save_cwd = os.getcwd()
|
| 264 |
+
if root_dir is not None:
|
| 265 |
+
log.debug("changing into '%s'", root_dir)
|
| 266 |
+
base_name = os.path.abspath(base_name)
|
| 267 |
+
if not dry_run:
|
| 268 |
+
os.chdir(root_dir)
|
| 269 |
+
|
| 270 |
+
if base_dir is None:
|
| 271 |
+
base_dir = os.curdir
|
| 272 |
+
|
| 273 |
+
kwargs = {'dry_run': dry_run}
|
| 274 |
+
|
| 275 |
+
try:
|
| 276 |
+
format_info = ARCHIVE_FORMATS[format]
|
| 277 |
+
except KeyError:
|
| 278 |
+
raise ValueError(f"unknown archive format '{format}'")
|
| 279 |
+
|
| 280 |
+
func = format_info[0]
|
| 281 |
+
kwargs.update(format_info[1])
|
| 282 |
+
|
| 283 |
+
if format != 'zip':
|
| 284 |
+
kwargs['owner'] = owner
|
| 285 |
+
kwargs['group'] = group
|
| 286 |
+
|
| 287 |
+
try:
|
| 288 |
+
filename = func(base_name, base_dir, **kwargs)
|
| 289 |
+
finally:
|
| 290 |
+
if root_dir is not None:
|
| 291 |
+
log.debug("changing back to '%s'", save_cwd)
|
| 292 |
+
os.chdir(save_cwd)
|
| 293 |
+
|
| 294 |
+
return filename
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .compat.numpy import ( # noqa: F401
|
| 2 |
+
_default_compilers,
|
| 3 |
+
compiler_class,
|
| 4 |
+
)
|
| 5 |
+
from .compilers.C import base
|
| 6 |
+
from .compilers.C.base import (
|
| 7 |
+
gen_lib_options,
|
| 8 |
+
gen_preprocess_options,
|
| 9 |
+
get_default_compiler,
|
| 10 |
+
new_compiler,
|
| 11 |
+
show_compilers,
|
| 12 |
+
)
|
| 13 |
+
from .compilers.C.errors import CompileError, LinkError
|
| 14 |
+
|
| 15 |
+
__all__ = [
|
| 16 |
+
'CompileError',
|
| 17 |
+
'LinkError',
|
| 18 |
+
'gen_lib_options',
|
| 19 |
+
'gen_preprocess_options',
|
| 20 |
+
'get_default_compiler',
|
| 21 |
+
'new_compiler',
|
| 22 |
+
'show_compilers',
|
| 23 |
+
]
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.cmd
|
| 2 |
+
|
| 3 |
+
Provides the Command class, the base class for the command classes
|
| 4 |
+
in the distutils.command package.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import logging
|
| 10 |
+
import os
|
| 11 |
+
import re
|
| 12 |
+
import sys
|
| 13 |
+
from abc import abstractmethod
|
| 14 |
+
from collections.abc import Callable, MutableSequence
|
| 15 |
+
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, overload
|
| 16 |
+
|
| 17 |
+
from . import _modified, archive_util, dir_util, file_util, util
|
| 18 |
+
from ._log import log
|
| 19 |
+
from .errors import DistutilsOptionError
|
| 20 |
+
|
| 21 |
+
if TYPE_CHECKING:
|
| 22 |
+
# type-only import because of mutual dependence between these classes
|
| 23 |
+
from distutils.dist import Distribution
|
| 24 |
+
|
| 25 |
+
from typing_extensions import TypeVarTuple, Unpack
|
| 26 |
+
|
| 27 |
+
_Ts = TypeVarTuple("_Ts")
|
| 28 |
+
|
| 29 |
+
_StrPathT = TypeVar("_StrPathT", bound="str | os.PathLike[str]")
|
| 30 |
+
_BytesPathT = TypeVar("_BytesPathT", bound="bytes | os.PathLike[bytes]")
|
| 31 |
+
_CommandT = TypeVar("_CommandT", bound="Command")
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class Command:
|
| 35 |
+
"""Abstract base class for defining command classes, the "worker bees"
|
| 36 |
+
of the Distutils. A useful analogy for command classes is to think of
|
| 37 |
+
them as subroutines with local variables called "options". The options
|
| 38 |
+
are "declared" in 'initialize_options()' and "defined" (given their
|
| 39 |
+
final values, aka "finalized") in 'finalize_options()', both of which
|
| 40 |
+
must be defined by every command class. The distinction between the
|
| 41 |
+
two is necessary because option values might come from the outside
|
| 42 |
+
world (command line, config file, ...), and any options dependent on
|
| 43 |
+
other options must be computed *after* these outside influences have
|
| 44 |
+
been processed -- hence 'finalize_options()'. The "body" of the
|
| 45 |
+
subroutine, where it does all its work based on the values of its
|
| 46 |
+
options, is the 'run()' method, which must also be implemented by every
|
| 47 |
+
command class.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
# 'sub_commands' formalizes the notion of a "family" of commands,
|
| 51 |
+
# eg. "install" as the parent with sub-commands "install_lib",
|
| 52 |
+
# "install_headers", etc. The parent of a family of commands
|
| 53 |
+
# defines 'sub_commands' as a class attribute; it's a list of
|
| 54 |
+
# (command_name : string, predicate : unbound_method | string | None)
|
| 55 |
+
# tuples, where 'predicate' is a method of the parent command that
|
| 56 |
+
# determines whether the corresponding command is applicable in the
|
| 57 |
+
# current situation. (Eg. we "install_headers" is only applicable if
|
| 58 |
+
# we have any C header files to install.) If 'predicate' is None,
|
| 59 |
+
# that command is always applicable.
|
| 60 |
+
#
|
| 61 |
+
# 'sub_commands' is usually defined at the *end* of a class, because
|
| 62 |
+
# predicates can be unbound methods, so they must already have been
|
| 63 |
+
# defined. The canonical example is the "install" command.
|
| 64 |
+
sub_commands: ClassVar[ # Any to work around variance issues
|
| 65 |
+
list[tuple[str, Callable[[Any], bool] | None]]
|
| 66 |
+
] = []
|
| 67 |
+
|
| 68 |
+
user_options: ClassVar[
|
| 69 |
+
# Specifying both because list is invariant. Avoids mypy override assignment issues
|
| 70 |
+
list[tuple[str, str, str]] | list[tuple[str, str | None, str]]
|
| 71 |
+
] = []
|
| 72 |
+
|
| 73 |
+
# -- Creation/initialization methods -------------------------------
|
| 74 |
+
|
| 75 |
+
def __init__(self, dist: Distribution) -> None:
|
| 76 |
+
"""Create and initialize a new Command object. Most importantly,
|
| 77 |
+
invokes the 'initialize_options()' method, which is the real
|
| 78 |
+
initializer and depends on the actual command being
|
| 79 |
+
instantiated.
|
| 80 |
+
"""
|
| 81 |
+
# late import because of mutual dependence between these classes
|
| 82 |
+
from distutils.dist import Distribution
|
| 83 |
+
|
| 84 |
+
if not isinstance(dist, Distribution):
|
| 85 |
+
raise TypeError("dist must be a Distribution instance")
|
| 86 |
+
if self.__class__ is Command:
|
| 87 |
+
raise RuntimeError("Command is an abstract class")
|
| 88 |
+
|
| 89 |
+
self.distribution = dist
|
| 90 |
+
self.initialize_options()
|
| 91 |
+
|
| 92 |
+
# Per-command versions of the global flags, so that the user can
|
| 93 |
+
# customize Distutils' behaviour command-by-command and let some
|
| 94 |
+
# commands fall back on the Distribution's behaviour. None means
|
| 95 |
+
# "not defined, check self.distribution's copy", while 0 or 1 mean
|
| 96 |
+
# false and true (duh). Note that this means figuring out the real
|
| 97 |
+
# value of each flag is a touch complicated -- hence "self._dry_run"
|
| 98 |
+
# will be handled by __getattr__, below.
|
| 99 |
+
# XXX This needs to be fixed.
|
| 100 |
+
self._dry_run = None
|
| 101 |
+
|
| 102 |
+
# verbose is largely ignored, but needs to be set for
|
| 103 |
+
# backwards compatibility (I think)?
|
| 104 |
+
self.verbose = dist.verbose
|
| 105 |
+
|
| 106 |
+
# Some commands define a 'self.force' option to ignore file
|
| 107 |
+
# timestamps, but methods defined *here* assume that
|
| 108 |
+
# 'self.force' exists for all commands. So define it here
|
| 109 |
+
# just to be safe.
|
| 110 |
+
self.force = None
|
| 111 |
+
|
| 112 |
+
# The 'help' flag is just used for command-line parsing, so
|
| 113 |
+
# none of that complicated bureaucracy is needed.
|
| 114 |
+
self.help = False
|
| 115 |
+
|
| 116 |
+
# 'finalized' records whether or not 'finalize_options()' has been
|
| 117 |
+
# called. 'finalize_options()' itself should not pay attention to
|
| 118 |
+
# this flag: it is the business of 'ensure_finalized()', which
|
| 119 |
+
# always calls 'finalize_options()', to respect/update it.
|
| 120 |
+
self.finalized = False
|
| 121 |
+
|
| 122 |
+
# XXX A more explicit way to customize dry_run would be better.
|
| 123 |
+
def __getattr__(self, attr):
|
| 124 |
+
if attr == 'dry_run':
|
| 125 |
+
myval = getattr(self, "_" + attr)
|
| 126 |
+
if myval is None:
|
| 127 |
+
return getattr(self.distribution, attr)
|
| 128 |
+
else:
|
| 129 |
+
return myval
|
| 130 |
+
else:
|
| 131 |
+
raise AttributeError(attr)
|
| 132 |
+
|
| 133 |
+
def ensure_finalized(self) -> None:
|
| 134 |
+
if not self.finalized:
|
| 135 |
+
self.finalize_options()
|
| 136 |
+
self.finalized = True
|
| 137 |
+
|
| 138 |
+
# Subclasses must define:
|
| 139 |
+
# initialize_options()
|
| 140 |
+
# provide default values for all options; may be customized by
|
| 141 |
+
# setup script, by options from config file(s), or by command-line
|
| 142 |
+
# options
|
| 143 |
+
# finalize_options()
|
| 144 |
+
# decide on the final values for all options; this is called
|
| 145 |
+
# after all possible intervention from the outside world
|
| 146 |
+
# (command-line, option file, etc.) has been processed
|
| 147 |
+
# run()
|
| 148 |
+
# run the command: do whatever it is we're here to do,
|
| 149 |
+
# controlled by the command's various option values
|
| 150 |
+
|
| 151 |
+
@abstractmethod
|
| 152 |
+
def initialize_options(self) -> None:
|
| 153 |
+
"""Set default values for all the options that this command
|
| 154 |
+
supports. Note that these defaults may be overridden by other
|
| 155 |
+
commands, by the setup script, by config files, or by the
|
| 156 |
+
command-line. Thus, this is not the place to code dependencies
|
| 157 |
+
between options; generally, 'initialize_options()' implementations
|
| 158 |
+
are just a bunch of "self.foo = None" assignments.
|
| 159 |
+
|
| 160 |
+
This method must be implemented by all command classes.
|
| 161 |
+
"""
|
| 162 |
+
raise RuntimeError(
|
| 163 |
+
f"abstract method -- subclass {self.__class__} must override"
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
@abstractmethod
|
| 167 |
+
def finalize_options(self) -> None:
|
| 168 |
+
"""Set final values for all the options that this command supports.
|
| 169 |
+
This is always called as late as possible, ie. after any option
|
| 170 |
+
assignments from the command-line or from other commands have been
|
| 171 |
+
done. Thus, this is the place to code option dependencies: if
|
| 172 |
+
'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as
|
| 173 |
+
long as 'foo' still has the same value it was assigned in
|
| 174 |
+
'initialize_options()'.
|
| 175 |
+
|
| 176 |
+
This method must be implemented by all command classes.
|
| 177 |
+
"""
|
| 178 |
+
raise RuntimeError(
|
| 179 |
+
f"abstract method -- subclass {self.__class__} must override"
|
| 180 |
+
)
|
| 181 |
+
|
| 182 |
+
def dump_options(self, header=None, indent=""):
|
| 183 |
+
from distutils.fancy_getopt import longopt_xlate
|
| 184 |
+
|
| 185 |
+
if header is None:
|
| 186 |
+
header = f"command options for '{self.get_command_name()}':"
|
| 187 |
+
self.announce(indent + header, level=logging.INFO)
|
| 188 |
+
indent = indent + " "
|
| 189 |
+
for option, _, _ in self.user_options:
|
| 190 |
+
option = option.translate(longopt_xlate)
|
| 191 |
+
if option[-1] == "=":
|
| 192 |
+
option = option[:-1]
|
| 193 |
+
value = getattr(self, option)
|
| 194 |
+
self.announce(indent + f"{option} = {value}", level=logging.INFO)
|
| 195 |
+
|
| 196 |
+
@abstractmethod
|
| 197 |
+
def run(self) -> None:
|
| 198 |
+
"""A command's raison d'etre: carry out the action it exists to
|
| 199 |
+
perform, controlled by the options initialized in
|
| 200 |
+
'initialize_options()', customized by other commands, the setup
|
| 201 |
+
script, the command-line, and config files, and finalized in
|
| 202 |
+
'finalize_options()'. All terminal output and filesystem
|
| 203 |
+
interaction should be done by 'run()'.
|
| 204 |
+
|
| 205 |
+
This method must be implemented by all command classes.
|
| 206 |
+
"""
|
| 207 |
+
raise RuntimeError(
|
| 208 |
+
f"abstract method -- subclass {self.__class__} must override"
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
def announce(self, msg: object, level: int = logging.DEBUG) -> None:
|
| 212 |
+
log.log(level, msg)
|
| 213 |
+
|
| 214 |
+
def debug_print(self, msg: object) -> None:
|
| 215 |
+
"""Print 'msg' to stdout if the global DEBUG (taken from the
|
| 216 |
+
DISTUTILS_DEBUG environment variable) flag is true.
|
| 217 |
+
"""
|
| 218 |
+
from distutils.debug import DEBUG
|
| 219 |
+
|
| 220 |
+
if DEBUG:
|
| 221 |
+
print(msg)
|
| 222 |
+
sys.stdout.flush()
|
| 223 |
+
|
| 224 |
+
# -- Option validation methods -------------------------------------
|
| 225 |
+
# (these are very handy in writing the 'finalize_options()' method)
|
| 226 |
+
#
|
| 227 |
+
# NB. the general philosophy here is to ensure that a particular option
|
| 228 |
+
# value meets certain type and value constraints. If not, we try to
|
| 229 |
+
# force it into conformance (eg. if we expect a list but have a string,
|
| 230 |
+
# split the string on comma and/or whitespace). If we can't force the
|
| 231 |
+
# option into conformance, raise DistutilsOptionError. Thus, command
|
| 232 |
+
# classes need do nothing more than (eg.)
|
| 233 |
+
# self.ensure_string_list('foo')
|
| 234 |
+
# and they can be guaranteed that thereafter, self.foo will be
|
| 235 |
+
# a list of strings.
|
| 236 |
+
|
| 237 |
+
def _ensure_stringlike(self, option, what, default=None):
|
| 238 |
+
val = getattr(self, option)
|
| 239 |
+
if val is None:
|
| 240 |
+
setattr(self, option, default)
|
| 241 |
+
return default
|
| 242 |
+
elif not isinstance(val, str):
|
| 243 |
+
raise DistutilsOptionError(f"'{option}' must be a {what} (got `{val}`)")
|
| 244 |
+
return val
|
| 245 |
+
|
| 246 |
+
def ensure_string(self, option: str, default: str | None = None) -> None:
|
| 247 |
+
"""Ensure that 'option' is a string; if not defined, set it to
|
| 248 |
+
'default'.
|
| 249 |
+
"""
|
| 250 |
+
self._ensure_stringlike(option, "string", default)
|
| 251 |
+
|
| 252 |
+
def ensure_string_list(self, option: str) -> None:
|
| 253 |
+
r"""Ensure that 'option' is a list of strings. If 'option' is
|
| 254 |
+
currently a string, we split it either on /,\s*/ or /\s+/, so
|
| 255 |
+
"foo bar baz", "foo,bar,baz", and "foo, bar baz" all become
|
| 256 |
+
["foo", "bar", "baz"].
|
| 257 |
+
"""
|
| 258 |
+
val = getattr(self, option)
|
| 259 |
+
if val is None:
|
| 260 |
+
return
|
| 261 |
+
elif isinstance(val, str):
|
| 262 |
+
setattr(self, option, re.split(r',\s*|\s+', val))
|
| 263 |
+
else:
|
| 264 |
+
if isinstance(val, list):
|
| 265 |
+
ok = all(isinstance(v, str) for v in val)
|
| 266 |
+
else:
|
| 267 |
+
ok = False
|
| 268 |
+
if not ok:
|
| 269 |
+
raise DistutilsOptionError(
|
| 270 |
+
f"'{option}' must be a list of strings (got {val!r})"
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
def _ensure_tested_string(self, option, tester, what, error_fmt, default=None):
|
| 274 |
+
val = self._ensure_stringlike(option, what, default)
|
| 275 |
+
if val is not None and not tester(val):
|
| 276 |
+
raise DistutilsOptionError(
|
| 277 |
+
("error in '%s' option: " + error_fmt) % (option, val)
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
def ensure_filename(self, option: str) -> None:
|
| 281 |
+
"""Ensure that 'option' is the name of an existing file."""
|
| 282 |
+
self._ensure_tested_string(
|
| 283 |
+
option, os.path.isfile, "filename", "'%s' does not exist or is not a file"
|
| 284 |
+
)
|
| 285 |
+
|
| 286 |
+
def ensure_dirname(self, option: str) -> None:
|
| 287 |
+
self._ensure_tested_string(
|
| 288 |
+
option,
|
| 289 |
+
os.path.isdir,
|
| 290 |
+
"directory name",
|
| 291 |
+
"'%s' does not exist or is not a directory",
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
+
# -- Convenience methods for commands ------------------------------
|
| 295 |
+
|
| 296 |
+
def get_command_name(self) -> str:
|
| 297 |
+
if hasattr(self, 'command_name'):
|
| 298 |
+
return self.command_name
|
| 299 |
+
else:
|
| 300 |
+
return self.__class__.__name__
|
| 301 |
+
|
| 302 |
+
def set_undefined_options(
|
| 303 |
+
self, src_cmd: str, *option_pairs: tuple[str, str]
|
| 304 |
+
) -> None:
|
| 305 |
+
"""Set the values of any "undefined" options from corresponding
|
| 306 |
+
option values in some other command object. "Undefined" here means
|
| 307 |
+
"is None", which is the convention used to indicate that an option
|
| 308 |
+
has not been changed between 'initialize_options()' and
|
| 309 |
+
'finalize_options()'. Usually called from 'finalize_options()' for
|
| 310 |
+
options that depend on some other command rather than another
|
| 311 |
+
option of the same command. 'src_cmd' is the other command from
|
| 312 |
+
which option values will be taken (a command object will be created
|
| 313 |
+
for it if necessary); the remaining arguments are
|
| 314 |
+
'(src_option,dst_option)' tuples which mean "take the value of
|
| 315 |
+
'src_option' in the 'src_cmd' command object, and copy it to
|
| 316 |
+
'dst_option' in the current command object".
|
| 317 |
+
"""
|
| 318 |
+
# Option_pairs: list of (src_option, dst_option) tuples
|
| 319 |
+
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
|
| 320 |
+
src_cmd_obj.ensure_finalized()
|
| 321 |
+
for src_option, dst_option in option_pairs:
|
| 322 |
+
if getattr(self, dst_option) is None:
|
| 323 |
+
setattr(self, dst_option, getattr(src_cmd_obj, src_option))
|
| 324 |
+
|
| 325 |
+
# NOTE: Because distutils is private to Setuptools and not all commands are exposed here,
|
| 326 |
+
# not every possible command is enumerated in the signature.
|
| 327 |
+
def get_finalized_command(self, command: str, create: bool = True) -> Command:
|
| 328 |
+
"""Wrapper around Distribution's 'get_command_obj()' method: find
|
| 329 |
+
(create if necessary and 'create' is true) the command object for
|
| 330 |
+
'command', call its 'ensure_finalized()' method, and return the
|
| 331 |
+
finalized command object.
|
| 332 |
+
"""
|
| 333 |
+
cmd_obj = self.distribution.get_command_obj(command, create)
|
| 334 |
+
cmd_obj.ensure_finalized()
|
| 335 |
+
return cmd_obj
|
| 336 |
+
|
| 337 |
+
# XXX rename to 'get_reinitialized_command()'? (should do the
|
| 338 |
+
# same in dist.py, if so)
|
| 339 |
+
@overload
|
| 340 |
+
def reinitialize_command(
|
| 341 |
+
self, command: str, reinit_subcommands: bool = False
|
| 342 |
+
) -> Command: ...
|
| 343 |
+
@overload
|
| 344 |
+
def reinitialize_command(
|
| 345 |
+
self, command: _CommandT, reinit_subcommands: bool = False
|
| 346 |
+
) -> _CommandT: ...
|
| 347 |
+
def reinitialize_command(
|
| 348 |
+
self, command: str | Command, reinit_subcommands=False
|
| 349 |
+
) -> Command:
|
| 350 |
+
return self.distribution.reinitialize_command(command, reinit_subcommands)
|
| 351 |
+
|
| 352 |
+
def run_command(self, command: str) -> None:
|
| 353 |
+
"""Run some other command: uses the 'run_command()' method of
|
| 354 |
+
Distribution, which creates and finalizes the command object if
|
| 355 |
+
necessary and then invokes its 'run()' method.
|
| 356 |
+
"""
|
| 357 |
+
self.distribution.run_command(command)
|
| 358 |
+
|
| 359 |
+
def get_sub_commands(self) -> list[str]:
|
| 360 |
+
"""Determine the sub-commands that are relevant in the current
|
| 361 |
+
distribution (ie., that need to be run). This is based on the
|
| 362 |
+
'sub_commands' class attribute: each tuple in that list may include
|
| 363 |
+
a method that we call to determine if the subcommand needs to be
|
| 364 |
+
run for the current distribution. Return a list of command names.
|
| 365 |
+
"""
|
| 366 |
+
commands = []
|
| 367 |
+
for cmd_name, method in self.sub_commands:
|
| 368 |
+
if method is None or method(self):
|
| 369 |
+
commands.append(cmd_name)
|
| 370 |
+
return commands
|
| 371 |
+
|
| 372 |
+
# -- External world manipulation -----------------------------------
|
| 373 |
+
|
| 374 |
+
def warn(self, msg: object) -> None:
|
| 375 |
+
log.warning("warning: %s: %s\n", self.get_command_name(), msg)
|
| 376 |
+
|
| 377 |
+
def execute(
|
| 378 |
+
self,
|
| 379 |
+
func: Callable[[Unpack[_Ts]], object],
|
| 380 |
+
args: tuple[Unpack[_Ts]],
|
| 381 |
+
msg: object = None,
|
| 382 |
+
level: int = 1,
|
| 383 |
+
) -> None:
|
| 384 |
+
util.execute(func, args, msg, dry_run=self.dry_run)
|
| 385 |
+
|
| 386 |
+
def mkpath(self, name: str, mode: int = 0o777) -> None:
|
| 387 |
+
dir_util.mkpath(name, mode, dry_run=self.dry_run)
|
| 388 |
+
|
| 389 |
+
@overload
|
| 390 |
+
def copy_file(
|
| 391 |
+
self,
|
| 392 |
+
infile: str | os.PathLike[str],
|
| 393 |
+
outfile: _StrPathT,
|
| 394 |
+
preserve_mode: bool = True,
|
| 395 |
+
preserve_times: bool = True,
|
| 396 |
+
link: str | None = None,
|
| 397 |
+
level: int = 1,
|
| 398 |
+
) -> tuple[_StrPathT | str, bool]: ...
|
| 399 |
+
@overload
|
| 400 |
+
def copy_file(
|
| 401 |
+
self,
|
| 402 |
+
infile: bytes | os.PathLike[bytes],
|
| 403 |
+
outfile: _BytesPathT,
|
| 404 |
+
preserve_mode: bool = True,
|
| 405 |
+
preserve_times: bool = True,
|
| 406 |
+
link: str | None = None,
|
| 407 |
+
level: int = 1,
|
| 408 |
+
) -> tuple[_BytesPathT | bytes, bool]: ...
|
| 409 |
+
def copy_file(
|
| 410 |
+
self,
|
| 411 |
+
infile: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 412 |
+
outfile: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 413 |
+
preserve_mode: bool = True,
|
| 414 |
+
preserve_times: bool = True,
|
| 415 |
+
link: str | None = None,
|
| 416 |
+
level: int = 1,
|
| 417 |
+
) -> tuple[str | os.PathLike[str] | bytes | os.PathLike[bytes], bool]:
|
| 418 |
+
"""Copy a file respecting verbose, dry-run and force flags. (The
|
| 419 |
+
former two default to whatever is in the Distribution object, and
|
| 420 |
+
the latter defaults to false for commands that don't define it.)"""
|
| 421 |
+
return file_util.copy_file(
|
| 422 |
+
infile,
|
| 423 |
+
outfile,
|
| 424 |
+
preserve_mode,
|
| 425 |
+
preserve_times,
|
| 426 |
+
not self.force,
|
| 427 |
+
link,
|
| 428 |
+
dry_run=self.dry_run,
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
def copy_tree(
|
| 432 |
+
self,
|
| 433 |
+
infile: str | os.PathLike[str],
|
| 434 |
+
outfile: str,
|
| 435 |
+
preserve_mode: bool = True,
|
| 436 |
+
preserve_times: bool = True,
|
| 437 |
+
preserve_symlinks: bool = False,
|
| 438 |
+
level: int = 1,
|
| 439 |
+
) -> list[str]:
|
| 440 |
+
"""Copy an entire directory tree respecting verbose, dry-run,
|
| 441 |
+
and force flags.
|
| 442 |
+
"""
|
| 443 |
+
return dir_util.copy_tree(
|
| 444 |
+
infile,
|
| 445 |
+
outfile,
|
| 446 |
+
preserve_mode,
|
| 447 |
+
preserve_times,
|
| 448 |
+
preserve_symlinks,
|
| 449 |
+
not self.force,
|
| 450 |
+
dry_run=self.dry_run,
|
| 451 |
+
)
|
| 452 |
+
|
| 453 |
+
@overload
|
| 454 |
+
def move_file(
|
| 455 |
+
self, src: str | os.PathLike[str], dst: _StrPathT, level: int = 1
|
| 456 |
+
) -> _StrPathT | str: ...
|
| 457 |
+
@overload
|
| 458 |
+
def move_file(
|
| 459 |
+
self, src: bytes | os.PathLike[bytes], dst: _BytesPathT, level: int = 1
|
| 460 |
+
) -> _BytesPathT | bytes: ...
|
| 461 |
+
def move_file(
|
| 462 |
+
self,
|
| 463 |
+
src: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 464 |
+
dst: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 465 |
+
level: int = 1,
|
| 466 |
+
) -> str | os.PathLike[str] | bytes | os.PathLike[bytes]:
|
| 467 |
+
"""Move a file respecting dry-run flag."""
|
| 468 |
+
return file_util.move_file(src, dst, dry_run=self.dry_run)
|
| 469 |
+
|
| 470 |
+
def spawn(
|
| 471 |
+
self, cmd: MutableSequence[str], search_path: bool = True, level: int = 1
|
| 472 |
+
) -> None:
|
| 473 |
+
"""Spawn an external command respecting dry-run flag."""
|
| 474 |
+
from distutils.spawn import spawn
|
| 475 |
+
|
| 476 |
+
spawn(cmd, search_path, dry_run=self.dry_run)
|
| 477 |
+
|
| 478 |
+
@overload
|
| 479 |
+
def make_archive(
|
| 480 |
+
self,
|
| 481 |
+
base_name: str,
|
| 482 |
+
format: str,
|
| 483 |
+
root_dir: str | os.PathLike[str] | bytes | os.PathLike[bytes] | None = None,
|
| 484 |
+
base_dir: str | None = None,
|
| 485 |
+
owner: str | None = None,
|
| 486 |
+
group: str | None = None,
|
| 487 |
+
) -> str: ...
|
| 488 |
+
@overload
|
| 489 |
+
def make_archive(
|
| 490 |
+
self,
|
| 491 |
+
base_name: str | os.PathLike[str],
|
| 492 |
+
format: str,
|
| 493 |
+
root_dir: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 494 |
+
base_dir: str | None = None,
|
| 495 |
+
owner: str | None = None,
|
| 496 |
+
group: str | None = None,
|
| 497 |
+
) -> str: ...
|
| 498 |
+
def make_archive(
|
| 499 |
+
self,
|
| 500 |
+
base_name: str | os.PathLike[str],
|
| 501 |
+
format: str,
|
| 502 |
+
root_dir: str | os.PathLike[str] | bytes | os.PathLike[bytes] | None = None,
|
| 503 |
+
base_dir: str | None = None,
|
| 504 |
+
owner: str | None = None,
|
| 505 |
+
group: str | None = None,
|
| 506 |
+
) -> str:
|
| 507 |
+
return archive_util.make_archive(
|
| 508 |
+
base_name,
|
| 509 |
+
format,
|
| 510 |
+
root_dir,
|
| 511 |
+
base_dir,
|
| 512 |
+
dry_run=self.dry_run,
|
| 513 |
+
owner=owner,
|
| 514 |
+
group=group,
|
| 515 |
+
)
|
| 516 |
+
|
| 517 |
+
def make_file(
|
| 518 |
+
self,
|
| 519 |
+
infiles: str | list[str] | tuple[str, ...],
|
| 520 |
+
outfile: str | os.PathLike[str] | bytes | os.PathLike[bytes],
|
| 521 |
+
func: Callable[[Unpack[_Ts]], object],
|
| 522 |
+
args: tuple[Unpack[_Ts]],
|
| 523 |
+
exec_msg: object = None,
|
| 524 |
+
skip_msg: object = None,
|
| 525 |
+
level: int = 1,
|
| 526 |
+
) -> None:
|
| 527 |
+
"""Special case of 'execute()' for operations that process one or
|
| 528 |
+
more input files and generate one output file. Works just like
|
| 529 |
+
'execute()', except the operation is skipped and a different
|
| 530 |
+
message printed if 'outfile' already exists and is newer than all
|
| 531 |
+
files listed in 'infiles'. If the command defined 'self.force',
|
| 532 |
+
and it is true, then the command is unconditionally run -- does no
|
| 533 |
+
timestamp checks.
|
| 534 |
+
"""
|
| 535 |
+
if skip_msg is None:
|
| 536 |
+
skip_msg = f"skipping {outfile} (inputs unchanged)"
|
| 537 |
+
|
| 538 |
+
# Allow 'infiles' to be a single string
|
| 539 |
+
if isinstance(infiles, str):
|
| 540 |
+
infiles = (infiles,)
|
| 541 |
+
elif not isinstance(infiles, (list, tuple)):
|
| 542 |
+
raise TypeError("'infiles' must be a string, or a list or tuple of strings")
|
| 543 |
+
|
| 544 |
+
if exec_msg is None:
|
| 545 |
+
exec_msg = "generating {} from {}".format(outfile, ', '.join(infiles))
|
| 546 |
+
|
| 547 |
+
# If 'outfile' must be regenerated (either because it doesn't
|
| 548 |
+
# exist, is out-of-date, or the 'force' flag is true) then
|
| 549 |
+
# perform the action that presumably regenerates it
|
| 550 |
+
if self.force or _modified.newer_group(infiles, outfile):
|
| 551 |
+
self.execute(func, args, exec_msg, level)
|
| 552 |
+
# Otherwise, print the "skip" message
|
| 553 |
+
else:
|
| 554 |
+
log.debug(skip_msg)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/__init__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command
|
| 2 |
+
|
| 3 |
+
Package containing implementation of all the standard Distutils
|
| 4 |
+
commands."""
|
| 5 |
+
|
| 6 |
+
__all__ = [
|
| 7 |
+
'build',
|
| 8 |
+
'build_py',
|
| 9 |
+
'build_ext',
|
| 10 |
+
'build_clib',
|
| 11 |
+
'build_scripts',
|
| 12 |
+
'clean',
|
| 13 |
+
'install',
|
| 14 |
+
'install_lib',
|
| 15 |
+
'install_headers',
|
| 16 |
+
'install_scripts',
|
| 17 |
+
'install_data',
|
| 18 |
+
'sdist',
|
| 19 |
+
'bdist',
|
| 20 |
+
'bdist_dumb',
|
| 21 |
+
'bdist_rpm',
|
| 22 |
+
'check',
|
| 23 |
+
]
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/_framework_compat.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Backward compatibility for homebrew builds on macOS.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import functools
|
| 6 |
+
import os
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
import sysconfig
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@functools.lru_cache
|
| 13 |
+
def enabled():
|
| 14 |
+
"""
|
| 15 |
+
Only enabled for Python 3.9 framework homebrew builds
|
| 16 |
+
except ensurepip and venv.
|
| 17 |
+
"""
|
| 18 |
+
PY39 = (3, 9) < sys.version_info < (3, 10)
|
| 19 |
+
framework = sys.platform == 'darwin' and sys._framework
|
| 20 |
+
homebrew = "Cellar" in sysconfig.get_config_var('projectbase')
|
| 21 |
+
venv = sys.prefix != sys.base_prefix
|
| 22 |
+
ensurepip = os.environ.get("ENSUREPIP_OPTIONS")
|
| 23 |
+
return PY39 and framework and homebrew and not venv and not ensurepip
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
schemes = dict(
|
| 27 |
+
osx_framework_library=dict(
|
| 28 |
+
stdlib='{installed_base}/{platlibdir}/python{py_version_short}',
|
| 29 |
+
platstdlib='{platbase}/{platlibdir}/python{py_version_short}',
|
| 30 |
+
purelib='{homebrew_prefix}/lib/python{py_version_short}/site-packages',
|
| 31 |
+
platlib='{homebrew_prefix}/{platlibdir}/python{py_version_short}/site-packages',
|
| 32 |
+
include='{installed_base}/include/python{py_version_short}{abiflags}',
|
| 33 |
+
platinclude='{installed_platbase}/include/python{py_version_short}{abiflags}',
|
| 34 |
+
scripts='{homebrew_prefix}/bin',
|
| 35 |
+
data='{homebrew_prefix}',
|
| 36 |
+
)
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@functools.lru_cache
|
| 41 |
+
def vars():
|
| 42 |
+
if not enabled():
|
| 43 |
+
return {}
|
| 44 |
+
homebrew_prefix = subprocess.check_output(['brew', '--prefix'], text=True).strip()
|
| 45 |
+
return locals()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def scheme(name):
|
| 49 |
+
"""
|
| 50 |
+
Override the selected scheme for posix_prefix.
|
| 51 |
+
"""
|
| 52 |
+
if not enabled() or not name.endswith('_prefix'):
|
| 53 |
+
return name
|
| 54 |
+
return 'osx_framework_library'
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/bdist.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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distutils 'bdist' command (create a built [binary]
|
| 4 |
+
distribution)."""
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
import warnings
|
| 10 |
+
from collections.abc import Callable
|
| 11 |
+
from typing import TYPE_CHECKING, ClassVar
|
| 12 |
+
|
| 13 |
+
from ..core import Command
|
| 14 |
+
from ..errors import DistutilsOptionError, DistutilsPlatformError
|
| 15 |
+
from ..util import get_platform
|
| 16 |
+
|
| 17 |
+
if TYPE_CHECKING:
|
| 18 |
+
from typing_extensions import deprecated
|
| 19 |
+
else:
|
| 20 |
+
|
| 21 |
+
def deprecated(message):
|
| 22 |
+
return lambda fn: fn
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def show_formats():
|
| 26 |
+
"""Print list of available formats (arguments to "--format" option)."""
|
| 27 |
+
from ..fancy_getopt import FancyGetopt
|
| 28 |
+
|
| 29 |
+
formats = [
|
| 30 |
+
("formats=" + format, None, bdist.format_commands[format][1])
|
| 31 |
+
for format in bdist.format_commands
|
| 32 |
+
]
|
| 33 |
+
pretty_printer = FancyGetopt(formats)
|
| 34 |
+
pretty_printer.print_help("List of available distribution formats:")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class ListCompat(dict[str, tuple[str, str]]):
|
| 38 |
+
# adapter to allow for Setuptools compatibility in format_commands
|
| 39 |
+
@deprecated("format_commands is now a dict. append is deprecated.")
|
| 40 |
+
def append(self, item: object) -> None:
|
| 41 |
+
warnings.warn(
|
| 42 |
+
"format_commands is now a dict. append is deprecated.",
|
| 43 |
+
DeprecationWarning,
|
| 44 |
+
stacklevel=2,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class bdist(Command):
|
| 49 |
+
description = "create a built (binary) distribution"
|
| 50 |
+
|
| 51 |
+
user_options = [
|
| 52 |
+
('bdist-base=', 'b', "temporary directory for creating built distributions"),
|
| 53 |
+
(
|
| 54 |
+
'plat-name=',
|
| 55 |
+
'p',
|
| 56 |
+
"platform name to embed in generated filenames "
|
| 57 |
+
f"[default: {get_platform()}]",
|
| 58 |
+
),
|
| 59 |
+
('formats=', None, "formats for distribution (comma-separated list)"),
|
| 60 |
+
(
|
| 61 |
+
'dist-dir=',
|
| 62 |
+
'd',
|
| 63 |
+
"directory to put final built distributions in [default: dist]",
|
| 64 |
+
),
|
| 65 |
+
('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
|
| 66 |
+
(
|
| 67 |
+
'owner=',
|
| 68 |
+
'u',
|
| 69 |
+
"Owner name used when creating a tar file [default: current user]",
|
| 70 |
+
),
|
| 71 |
+
(
|
| 72 |
+
'group=',
|
| 73 |
+
'g',
|
| 74 |
+
"Group name used when creating a tar file [default: current group]",
|
| 75 |
+
),
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
boolean_options: ClassVar[list[str]] = ['skip-build']
|
| 79 |
+
|
| 80 |
+
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], object]]]] = [
|
| 81 |
+
('help-formats', None, "lists available distribution formats", show_formats),
|
| 82 |
+
]
|
| 83 |
+
|
| 84 |
+
# The following commands do not take a format option from bdist
|
| 85 |
+
no_format_option: ClassVar[tuple[str, ...]] = ('bdist_rpm',)
|
| 86 |
+
|
| 87 |
+
# This won't do in reality: will need to distinguish RPM-ish Linux,
|
| 88 |
+
# Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
|
| 89 |
+
default_format: ClassVar[dict[str, str]] = {'posix': 'gztar', 'nt': 'zip'}
|
| 90 |
+
|
| 91 |
+
# Define commands in preferred order for the --help-formats option
|
| 92 |
+
format_commands = ListCompat({
|
| 93 |
+
'rpm': ('bdist_rpm', "RPM distribution"),
|
| 94 |
+
'gztar': ('bdist_dumb', "gzip'ed tar file"),
|
| 95 |
+
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
|
| 96 |
+
'xztar': ('bdist_dumb', "xz'ed tar file"),
|
| 97 |
+
'ztar': ('bdist_dumb', "compressed tar file"),
|
| 98 |
+
'tar': ('bdist_dumb', "tar file"),
|
| 99 |
+
'zip': ('bdist_dumb', "ZIP file"),
|
| 100 |
+
})
|
| 101 |
+
|
| 102 |
+
# for compatibility until consumers only reference format_commands
|
| 103 |
+
format_command = format_commands
|
| 104 |
+
|
| 105 |
+
def initialize_options(self):
|
| 106 |
+
self.bdist_base = None
|
| 107 |
+
self.plat_name = None
|
| 108 |
+
self.formats = None
|
| 109 |
+
self.dist_dir = None
|
| 110 |
+
self.skip_build = False
|
| 111 |
+
self.group = None
|
| 112 |
+
self.owner = None
|
| 113 |
+
|
| 114 |
+
def finalize_options(self) -> None:
|
| 115 |
+
# have to finalize 'plat_name' before 'bdist_base'
|
| 116 |
+
if self.plat_name is None:
|
| 117 |
+
if self.skip_build:
|
| 118 |
+
self.plat_name = get_platform()
|
| 119 |
+
else:
|
| 120 |
+
self.plat_name = self.get_finalized_command('build').plat_name
|
| 121 |
+
|
| 122 |
+
# 'bdist_base' -- parent of per-built-distribution-format
|
| 123 |
+
# temporary directories (eg. we'll probably have
|
| 124 |
+
# "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.)
|
| 125 |
+
if self.bdist_base is None:
|
| 126 |
+
build_base = self.get_finalized_command('build').build_base
|
| 127 |
+
self.bdist_base = os.path.join(build_base, 'bdist.' + self.plat_name)
|
| 128 |
+
|
| 129 |
+
self.ensure_string_list('formats')
|
| 130 |
+
if self.formats is None:
|
| 131 |
+
try:
|
| 132 |
+
self.formats = [self.default_format[os.name]]
|
| 133 |
+
except KeyError:
|
| 134 |
+
raise DistutilsPlatformError(
|
| 135 |
+
"don't know how to create built distributions "
|
| 136 |
+
f"on platform {os.name}"
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
if self.dist_dir is None:
|
| 140 |
+
self.dist_dir = "dist"
|
| 141 |
+
|
| 142 |
+
def run(self) -> None:
|
| 143 |
+
# Figure out which sub-commands we need to run.
|
| 144 |
+
commands = []
|
| 145 |
+
for format in self.formats:
|
| 146 |
+
try:
|
| 147 |
+
commands.append(self.format_commands[format][0])
|
| 148 |
+
except KeyError:
|
| 149 |
+
raise DistutilsOptionError(f"invalid format '{format}'")
|
| 150 |
+
|
| 151 |
+
# Reinitialize and run each command.
|
| 152 |
+
for i in range(len(self.formats)):
|
| 153 |
+
cmd_name = commands[i]
|
| 154 |
+
sub_cmd = self.reinitialize_command(cmd_name)
|
| 155 |
+
if cmd_name not in self.no_format_option:
|
| 156 |
+
sub_cmd.format = self.formats[i]
|
| 157 |
+
|
| 158 |
+
# passing the owner and group names for tar archiving
|
| 159 |
+
if cmd_name == 'bdist_dumb':
|
| 160 |
+
sub_cmd.owner = self.owner
|
| 161 |
+
sub_cmd.group = self.group
|
| 162 |
+
|
| 163 |
+
# If we're going to need to run this command again, tell it to
|
| 164 |
+
# keep its temporary files around so subsequent runs go faster.
|
| 165 |
+
if cmd_name in commands[i + 1 :]:
|
| 166 |
+
sub_cmd.keep_temp = True
|
| 167 |
+
self.run_command(cmd_name)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_dumb.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.bdist_dumb
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'bdist_dumb' command (create a "dumb" built
|
| 4 |
+
distribution -- i.e., just an archive to be unpacked under $prefix or
|
| 5 |
+
$exec_prefix)."""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
from distutils._log import log
|
| 9 |
+
from typing import ClassVar
|
| 10 |
+
|
| 11 |
+
from ..core import Command
|
| 12 |
+
from ..dir_util import ensure_relative, remove_tree
|
| 13 |
+
from ..errors import DistutilsPlatformError
|
| 14 |
+
from ..sysconfig import get_python_version
|
| 15 |
+
from ..util import get_platform
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class bdist_dumb(Command):
|
| 19 |
+
description = "create a \"dumb\" built distribution"
|
| 20 |
+
|
| 21 |
+
user_options = [
|
| 22 |
+
('bdist-dir=', 'd', "temporary directory for creating the distribution"),
|
| 23 |
+
(
|
| 24 |
+
'plat-name=',
|
| 25 |
+
'p',
|
| 26 |
+
"platform name to embed in generated filenames "
|
| 27 |
+
f"[default: {get_platform()}]",
|
| 28 |
+
),
|
| 29 |
+
(
|
| 30 |
+
'format=',
|
| 31 |
+
'f',
|
| 32 |
+
"archive format to create (tar, gztar, bztar, xztar, ztar, zip)",
|
| 33 |
+
),
|
| 34 |
+
(
|
| 35 |
+
'keep-temp',
|
| 36 |
+
'k',
|
| 37 |
+
"keep the pseudo-installation tree around after creating the distribution archive",
|
| 38 |
+
),
|
| 39 |
+
('dist-dir=', 'd', "directory to put final built distributions in"),
|
| 40 |
+
('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
|
| 41 |
+
(
|
| 42 |
+
'relative',
|
| 43 |
+
None,
|
| 44 |
+
"build the archive using relative paths [default: false]",
|
| 45 |
+
),
|
| 46 |
+
(
|
| 47 |
+
'owner=',
|
| 48 |
+
'u',
|
| 49 |
+
"Owner name used when creating a tar file [default: current user]",
|
| 50 |
+
),
|
| 51 |
+
(
|
| 52 |
+
'group=',
|
| 53 |
+
'g',
|
| 54 |
+
"Group name used when creating a tar file [default: current group]",
|
| 55 |
+
),
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
+
boolean_options: ClassVar[list[str]] = ['keep-temp', 'skip-build', 'relative']
|
| 59 |
+
|
| 60 |
+
default_format = {'posix': 'gztar', 'nt': 'zip'}
|
| 61 |
+
|
| 62 |
+
def initialize_options(self):
|
| 63 |
+
self.bdist_dir = None
|
| 64 |
+
self.plat_name = None
|
| 65 |
+
self.format = None
|
| 66 |
+
self.keep_temp = False
|
| 67 |
+
self.dist_dir = None
|
| 68 |
+
self.skip_build = None
|
| 69 |
+
self.relative = False
|
| 70 |
+
self.owner = None
|
| 71 |
+
self.group = None
|
| 72 |
+
|
| 73 |
+
def finalize_options(self):
|
| 74 |
+
if self.bdist_dir is None:
|
| 75 |
+
bdist_base = self.get_finalized_command('bdist').bdist_base
|
| 76 |
+
self.bdist_dir = os.path.join(bdist_base, 'dumb')
|
| 77 |
+
|
| 78 |
+
if self.format is None:
|
| 79 |
+
try:
|
| 80 |
+
self.format = self.default_format[os.name]
|
| 81 |
+
except KeyError:
|
| 82 |
+
raise DistutilsPlatformError(
|
| 83 |
+
"don't know how to create dumb built distributions "
|
| 84 |
+
f"on platform {os.name}"
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
self.set_undefined_options(
|
| 88 |
+
'bdist',
|
| 89 |
+
('dist_dir', 'dist_dir'),
|
| 90 |
+
('plat_name', 'plat_name'),
|
| 91 |
+
('skip_build', 'skip_build'),
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
def run(self):
|
| 95 |
+
if not self.skip_build:
|
| 96 |
+
self.run_command('build')
|
| 97 |
+
|
| 98 |
+
install = self.reinitialize_command('install', reinit_subcommands=True)
|
| 99 |
+
install.root = self.bdist_dir
|
| 100 |
+
install.skip_build = self.skip_build
|
| 101 |
+
install.warn_dir = False
|
| 102 |
+
|
| 103 |
+
log.info("installing to %s", self.bdist_dir)
|
| 104 |
+
self.run_command('install')
|
| 105 |
+
|
| 106 |
+
# And make an archive relative to the root of the
|
| 107 |
+
# pseudo-installation tree.
|
| 108 |
+
archive_basename = f"{self.distribution.get_fullname()}.{self.plat_name}"
|
| 109 |
+
|
| 110 |
+
pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
|
| 111 |
+
if not self.relative:
|
| 112 |
+
archive_root = self.bdist_dir
|
| 113 |
+
else:
|
| 114 |
+
if self.distribution.has_ext_modules() and (
|
| 115 |
+
install.install_base != install.install_platbase
|
| 116 |
+
):
|
| 117 |
+
raise DistutilsPlatformError(
|
| 118 |
+
"can't make a dumb built distribution where "
|
| 119 |
+
f"base and platbase are different ({install.install_base!r}, {install.install_platbase!r})"
|
| 120 |
+
)
|
| 121 |
+
else:
|
| 122 |
+
archive_root = os.path.join(
|
| 123 |
+
self.bdist_dir, ensure_relative(install.install_base)
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
# Make the archive
|
| 127 |
+
filename = self.make_archive(
|
| 128 |
+
pseudoinstall_root,
|
| 129 |
+
self.format,
|
| 130 |
+
root_dir=archive_root,
|
| 131 |
+
owner=self.owner,
|
| 132 |
+
group=self.group,
|
| 133 |
+
)
|
| 134 |
+
if self.distribution.has_ext_modules():
|
| 135 |
+
pyversion = get_python_version()
|
| 136 |
+
else:
|
| 137 |
+
pyversion = 'any'
|
| 138 |
+
self.distribution.dist_files.append(('bdist_dumb', pyversion, filename))
|
| 139 |
+
|
| 140 |
+
if not self.keep_temp:
|
| 141 |
+
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_rpm.py
ADDED
|
@@ -0,0 +1,598 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.bdist_rpm
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
|
| 4 |
+
distributions)."""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
from distutils._log import log
|
| 10 |
+
from typing import ClassVar
|
| 11 |
+
|
| 12 |
+
from ..core import Command
|
| 13 |
+
from ..debug import DEBUG
|
| 14 |
+
from ..errors import (
|
| 15 |
+
DistutilsExecError,
|
| 16 |
+
DistutilsFileError,
|
| 17 |
+
DistutilsOptionError,
|
| 18 |
+
DistutilsPlatformError,
|
| 19 |
+
)
|
| 20 |
+
from ..file_util import write_file
|
| 21 |
+
from ..sysconfig import get_python_version
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class bdist_rpm(Command):
|
| 25 |
+
description = "create an RPM distribution"
|
| 26 |
+
|
| 27 |
+
user_options = [
|
| 28 |
+
('bdist-base=', None, "base directory for creating built distributions"),
|
| 29 |
+
(
|
| 30 |
+
'rpm-base=',
|
| 31 |
+
None,
|
| 32 |
+
"base directory for creating RPMs (defaults to \"rpm\" under "
|
| 33 |
+
"--bdist-base; must be specified for RPM 2)",
|
| 34 |
+
),
|
| 35 |
+
(
|
| 36 |
+
'dist-dir=',
|
| 37 |
+
'd',
|
| 38 |
+
"directory to put final RPM files in (and .spec files if --spec-only)",
|
| 39 |
+
),
|
| 40 |
+
(
|
| 41 |
+
'python=',
|
| 42 |
+
None,
|
| 43 |
+
"path to Python interpreter to hard-code in the .spec file "
|
| 44 |
+
"[default: \"python\"]",
|
| 45 |
+
),
|
| 46 |
+
(
|
| 47 |
+
'fix-python',
|
| 48 |
+
None,
|
| 49 |
+
"hard-code the exact path to the current Python interpreter in "
|
| 50 |
+
"the .spec file",
|
| 51 |
+
),
|
| 52 |
+
('spec-only', None, "only regenerate spec file"),
|
| 53 |
+
('source-only', None, "only generate source RPM"),
|
| 54 |
+
('binary-only', None, "only generate binary RPM"),
|
| 55 |
+
('use-bzip2', None, "use bzip2 instead of gzip to create source distribution"),
|
| 56 |
+
# More meta-data: too RPM-specific to put in the setup script,
|
| 57 |
+
# but needs to go in the .spec file -- so we make these options
|
| 58 |
+
# to "bdist_rpm". The idea is that packagers would put this
|
| 59 |
+
# info in setup.cfg, although they are of course free to
|
| 60 |
+
# supply it on the command line.
|
| 61 |
+
(
|
| 62 |
+
'distribution-name=',
|
| 63 |
+
None,
|
| 64 |
+
"name of the (Linux) distribution to which this "
|
| 65 |
+
"RPM applies (*not* the name of the module distribution!)",
|
| 66 |
+
),
|
| 67 |
+
('group=', None, "package classification [default: \"Development/Libraries\"]"),
|
| 68 |
+
('release=', None, "RPM release number"),
|
| 69 |
+
('serial=', None, "RPM serial number"),
|
| 70 |
+
(
|
| 71 |
+
'vendor=',
|
| 72 |
+
None,
|
| 73 |
+
"RPM \"vendor\" (eg. \"Joe Blow <joe@example.com>\") "
|
| 74 |
+
"[default: maintainer or author from setup script]",
|
| 75 |
+
),
|
| 76 |
+
(
|
| 77 |
+
'packager=',
|
| 78 |
+
None,
|
| 79 |
+
"RPM packager (eg. \"Jane Doe <jane@example.net>\") [default: vendor]",
|
| 80 |
+
),
|
| 81 |
+
('doc-files=', None, "list of documentation files (space or comma-separated)"),
|
| 82 |
+
('changelog=', None, "RPM changelog"),
|
| 83 |
+
('icon=', None, "name of icon file"),
|
| 84 |
+
('provides=', None, "capabilities provided by this package"),
|
| 85 |
+
('requires=', None, "capabilities required by this package"),
|
| 86 |
+
('conflicts=', None, "capabilities which conflict with this package"),
|
| 87 |
+
('build-requires=', None, "capabilities required to build this package"),
|
| 88 |
+
('obsoletes=', None, "capabilities made obsolete by this package"),
|
| 89 |
+
('no-autoreq', None, "do not automatically calculate dependencies"),
|
| 90 |
+
# Actions to take when building RPM
|
| 91 |
+
('keep-temp', 'k', "don't clean up RPM build directory"),
|
| 92 |
+
('no-keep-temp', None, "clean up RPM build directory [default]"),
|
| 93 |
+
(
|
| 94 |
+
'use-rpm-opt-flags',
|
| 95 |
+
None,
|
| 96 |
+
"compile with RPM_OPT_FLAGS when building from source RPM",
|
| 97 |
+
),
|
| 98 |
+
('no-rpm-opt-flags', None, "do not pass any RPM CFLAGS to compiler"),
|
| 99 |
+
('rpm3-mode', None, "RPM 3 compatibility mode (default)"),
|
| 100 |
+
('rpm2-mode', None, "RPM 2 compatibility mode"),
|
| 101 |
+
# Add the hooks necessary for specifying custom scripts
|
| 102 |
+
('prep-script=', None, "Specify a script for the PREP phase of RPM building"),
|
| 103 |
+
('build-script=', None, "Specify a script for the BUILD phase of RPM building"),
|
| 104 |
+
(
|
| 105 |
+
'pre-install=',
|
| 106 |
+
None,
|
| 107 |
+
"Specify a script for the pre-INSTALL phase of RPM building",
|
| 108 |
+
),
|
| 109 |
+
(
|
| 110 |
+
'install-script=',
|
| 111 |
+
None,
|
| 112 |
+
"Specify a script for the INSTALL phase of RPM building",
|
| 113 |
+
),
|
| 114 |
+
(
|
| 115 |
+
'post-install=',
|
| 116 |
+
None,
|
| 117 |
+
"Specify a script for the post-INSTALL phase of RPM building",
|
| 118 |
+
),
|
| 119 |
+
(
|
| 120 |
+
'pre-uninstall=',
|
| 121 |
+
None,
|
| 122 |
+
"Specify a script for the pre-UNINSTALL phase of RPM building",
|
| 123 |
+
),
|
| 124 |
+
(
|
| 125 |
+
'post-uninstall=',
|
| 126 |
+
None,
|
| 127 |
+
"Specify a script for the post-UNINSTALL phase of RPM building",
|
| 128 |
+
),
|
| 129 |
+
('clean-script=', None, "Specify a script for the CLEAN phase of RPM building"),
|
| 130 |
+
(
|
| 131 |
+
'verify-script=',
|
| 132 |
+
None,
|
| 133 |
+
"Specify a script for the VERIFY phase of the RPM build",
|
| 134 |
+
),
|
| 135 |
+
# Allow a packager to explicitly force an architecture
|
| 136 |
+
('force-arch=', None, "Force an architecture onto the RPM build process"),
|
| 137 |
+
('quiet', 'q', "Run the INSTALL phase of RPM building in quiet mode"),
|
| 138 |
+
]
|
| 139 |
+
|
| 140 |
+
boolean_options: ClassVar[list[str]] = [
|
| 141 |
+
'keep-temp',
|
| 142 |
+
'use-rpm-opt-flags',
|
| 143 |
+
'rpm3-mode',
|
| 144 |
+
'no-autoreq',
|
| 145 |
+
'quiet',
|
| 146 |
+
]
|
| 147 |
+
|
| 148 |
+
negative_opt: ClassVar[dict[str, str]] = {
|
| 149 |
+
'no-keep-temp': 'keep-temp',
|
| 150 |
+
'no-rpm-opt-flags': 'use-rpm-opt-flags',
|
| 151 |
+
'rpm2-mode': 'rpm3-mode',
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
def initialize_options(self):
|
| 155 |
+
self.bdist_base = None
|
| 156 |
+
self.rpm_base = None
|
| 157 |
+
self.dist_dir = None
|
| 158 |
+
self.python = None
|
| 159 |
+
self.fix_python = None
|
| 160 |
+
self.spec_only = None
|
| 161 |
+
self.binary_only = None
|
| 162 |
+
self.source_only = None
|
| 163 |
+
self.use_bzip2 = None
|
| 164 |
+
|
| 165 |
+
self.distribution_name = None
|
| 166 |
+
self.group = None
|
| 167 |
+
self.release = None
|
| 168 |
+
self.serial = None
|
| 169 |
+
self.vendor = None
|
| 170 |
+
self.packager = None
|
| 171 |
+
self.doc_files = None
|
| 172 |
+
self.changelog = None
|
| 173 |
+
self.icon = None
|
| 174 |
+
|
| 175 |
+
self.prep_script = None
|
| 176 |
+
self.build_script = None
|
| 177 |
+
self.install_script = None
|
| 178 |
+
self.clean_script = None
|
| 179 |
+
self.verify_script = None
|
| 180 |
+
self.pre_install = None
|
| 181 |
+
self.post_install = None
|
| 182 |
+
self.pre_uninstall = None
|
| 183 |
+
self.post_uninstall = None
|
| 184 |
+
self.prep = None
|
| 185 |
+
self.provides = None
|
| 186 |
+
self.requires = None
|
| 187 |
+
self.conflicts = None
|
| 188 |
+
self.build_requires = None
|
| 189 |
+
self.obsoletes = None
|
| 190 |
+
|
| 191 |
+
self.keep_temp = False
|
| 192 |
+
self.use_rpm_opt_flags = True
|
| 193 |
+
self.rpm3_mode = True
|
| 194 |
+
self.no_autoreq = False
|
| 195 |
+
|
| 196 |
+
self.force_arch = None
|
| 197 |
+
self.quiet = False
|
| 198 |
+
|
| 199 |
+
def finalize_options(self) -> None:
|
| 200 |
+
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
|
| 201 |
+
if self.rpm_base is None:
|
| 202 |
+
if not self.rpm3_mode:
|
| 203 |
+
raise DistutilsOptionError("you must specify --rpm-base in RPM 2 mode")
|
| 204 |
+
self.rpm_base = os.path.join(self.bdist_base, "rpm")
|
| 205 |
+
|
| 206 |
+
if self.python is None:
|
| 207 |
+
if self.fix_python:
|
| 208 |
+
self.python = sys.executable
|
| 209 |
+
else:
|
| 210 |
+
self.python = "python3"
|
| 211 |
+
elif self.fix_python:
|
| 212 |
+
raise DistutilsOptionError(
|
| 213 |
+
"--python and --fix-python are mutually exclusive options"
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
if os.name != 'posix':
|
| 217 |
+
raise DistutilsPlatformError(
|
| 218 |
+
f"don't know how to create RPM distributions on platform {os.name}"
|
| 219 |
+
)
|
| 220 |
+
if self.binary_only and self.source_only:
|
| 221 |
+
raise DistutilsOptionError(
|
| 222 |
+
"cannot supply both '--source-only' and '--binary-only'"
|
| 223 |
+
)
|
| 224 |
+
|
| 225 |
+
# don't pass CFLAGS to pure python distributions
|
| 226 |
+
if not self.distribution.has_ext_modules():
|
| 227 |
+
self.use_rpm_opt_flags = False
|
| 228 |
+
|
| 229 |
+
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
| 230 |
+
self.finalize_package_data()
|
| 231 |
+
|
| 232 |
+
def finalize_package_data(self) -> None:
|
| 233 |
+
self.ensure_string('group', "Development/Libraries")
|
| 234 |
+
self.ensure_string(
|
| 235 |
+
'vendor',
|
| 236 |
+
f"{self.distribution.get_contact()} <{self.distribution.get_contact_email()}>",
|
| 237 |
+
)
|
| 238 |
+
self.ensure_string('packager')
|
| 239 |
+
self.ensure_string_list('doc_files')
|
| 240 |
+
if isinstance(self.doc_files, list):
|
| 241 |
+
for readme in ('README', 'README.txt'):
|
| 242 |
+
if os.path.exists(readme) and readme not in self.doc_files:
|
| 243 |
+
self.doc_files.append(readme)
|
| 244 |
+
|
| 245 |
+
self.ensure_string('release', "1")
|
| 246 |
+
self.ensure_string('serial') # should it be an int?
|
| 247 |
+
|
| 248 |
+
self.ensure_string('distribution_name')
|
| 249 |
+
|
| 250 |
+
self.ensure_string('changelog')
|
| 251 |
+
# Format changelog correctly
|
| 252 |
+
self.changelog = self._format_changelog(self.changelog)
|
| 253 |
+
|
| 254 |
+
self.ensure_filename('icon')
|
| 255 |
+
|
| 256 |
+
self.ensure_filename('prep_script')
|
| 257 |
+
self.ensure_filename('build_script')
|
| 258 |
+
self.ensure_filename('install_script')
|
| 259 |
+
self.ensure_filename('clean_script')
|
| 260 |
+
self.ensure_filename('verify_script')
|
| 261 |
+
self.ensure_filename('pre_install')
|
| 262 |
+
self.ensure_filename('post_install')
|
| 263 |
+
self.ensure_filename('pre_uninstall')
|
| 264 |
+
self.ensure_filename('post_uninstall')
|
| 265 |
+
|
| 266 |
+
# XXX don't forget we punted on summaries and descriptions -- they
|
| 267 |
+
# should be handled here eventually!
|
| 268 |
+
|
| 269 |
+
# Now *this* is some meta-data that belongs in the setup script...
|
| 270 |
+
self.ensure_string_list('provides')
|
| 271 |
+
self.ensure_string_list('requires')
|
| 272 |
+
self.ensure_string_list('conflicts')
|
| 273 |
+
self.ensure_string_list('build_requires')
|
| 274 |
+
self.ensure_string_list('obsoletes')
|
| 275 |
+
|
| 276 |
+
self.ensure_string('force_arch')
|
| 277 |
+
|
| 278 |
+
def run(self) -> None: # noqa: C901
|
| 279 |
+
if DEBUG:
|
| 280 |
+
print("before _get_package_data():")
|
| 281 |
+
print("vendor =", self.vendor)
|
| 282 |
+
print("packager =", self.packager)
|
| 283 |
+
print("doc_files =", self.doc_files)
|
| 284 |
+
print("changelog =", self.changelog)
|
| 285 |
+
|
| 286 |
+
# make directories
|
| 287 |
+
if self.spec_only:
|
| 288 |
+
spec_dir = self.dist_dir
|
| 289 |
+
self.mkpath(spec_dir)
|
| 290 |
+
else:
|
| 291 |
+
rpm_dir = {}
|
| 292 |
+
for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'):
|
| 293 |
+
rpm_dir[d] = os.path.join(self.rpm_base, d)
|
| 294 |
+
self.mkpath(rpm_dir[d])
|
| 295 |
+
spec_dir = rpm_dir['SPECS']
|
| 296 |
+
|
| 297 |
+
# Spec file goes into 'dist_dir' if '--spec-only specified',
|
| 298 |
+
# build/rpm.<plat> otherwise.
|
| 299 |
+
spec_path = os.path.join(spec_dir, f"{self.distribution.get_name()}.spec")
|
| 300 |
+
self.execute(
|
| 301 |
+
write_file, (spec_path, self._make_spec_file()), f"writing '{spec_path}'"
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
if self.spec_only: # stop if requested
|
| 305 |
+
return
|
| 306 |
+
|
| 307 |
+
# Make a source distribution and copy to SOURCES directory with
|
| 308 |
+
# optional icon.
|
| 309 |
+
saved_dist_files = self.distribution.dist_files[:]
|
| 310 |
+
sdist = self.reinitialize_command('sdist')
|
| 311 |
+
if self.use_bzip2:
|
| 312 |
+
sdist.formats = ['bztar']
|
| 313 |
+
else:
|
| 314 |
+
sdist.formats = ['gztar']
|
| 315 |
+
self.run_command('sdist')
|
| 316 |
+
self.distribution.dist_files = saved_dist_files
|
| 317 |
+
|
| 318 |
+
source = sdist.get_archive_files()[0]
|
| 319 |
+
source_dir = rpm_dir['SOURCES']
|
| 320 |
+
self.copy_file(source, source_dir)
|
| 321 |
+
|
| 322 |
+
if self.icon:
|
| 323 |
+
if os.path.exists(self.icon):
|
| 324 |
+
self.copy_file(self.icon, source_dir)
|
| 325 |
+
else:
|
| 326 |
+
raise DistutilsFileError(f"icon file '{self.icon}' does not exist")
|
| 327 |
+
|
| 328 |
+
# build package
|
| 329 |
+
log.info("building RPMs")
|
| 330 |
+
rpm_cmd = ['rpmbuild']
|
| 331 |
+
|
| 332 |
+
if self.source_only: # what kind of RPMs?
|
| 333 |
+
rpm_cmd.append('-bs')
|
| 334 |
+
elif self.binary_only:
|
| 335 |
+
rpm_cmd.append('-bb')
|
| 336 |
+
else:
|
| 337 |
+
rpm_cmd.append('-ba')
|
| 338 |
+
rpm_cmd.extend(['--define', f'__python {self.python}'])
|
| 339 |
+
if self.rpm3_mode:
|
| 340 |
+
rpm_cmd.extend(['--define', f'_topdir {os.path.abspath(self.rpm_base)}'])
|
| 341 |
+
if not self.keep_temp:
|
| 342 |
+
rpm_cmd.append('--clean')
|
| 343 |
+
|
| 344 |
+
if self.quiet:
|
| 345 |
+
rpm_cmd.append('--quiet')
|
| 346 |
+
|
| 347 |
+
rpm_cmd.append(spec_path)
|
| 348 |
+
# Determine the binary rpm names that should be built out of this spec
|
| 349 |
+
# file
|
| 350 |
+
# Note that some of these may not be really built (if the file
|
| 351 |
+
# list is empty)
|
| 352 |
+
nvr_string = "%{name}-%{version}-%{release}"
|
| 353 |
+
src_rpm = nvr_string + ".src.rpm"
|
| 354 |
+
non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm"
|
| 355 |
+
q_cmd = rf"rpm -q --qf '{src_rpm} {non_src_rpm}\n' --specfile '{spec_path}'"
|
| 356 |
+
|
| 357 |
+
out = os.popen(q_cmd)
|
| 358 |
+
try:
|
| 359 |
+
binary_rpms = []
|
| 360 |
+
source_rpm = None
|
| 361 |
+
while True:
|
| 362 |
+
line = out.readline()
|
| 363 |
+
if not line:
|
| 364 |
+
break
|
| 365 |
+
ell = line.strip().split()
|
| 366 |
+
assert len(ell) == 2
|
| 367 |
+
binary_rpms.append(ell[1])
|
| 368 |
+
# The source rpm is named after the first entry in the spec file
|
| 369 |
+
if source_rpm is None:
|
| 370 |
+
source_rpm = ell[0]
|
| 371 |
+
|
| 372 |
+
status = out.close()
|
| 373 |
+
if status:
|
| 374 |
+
raise DistutilsExecError(f"Failed to execute: {q_cmd!r}")
|
| 375 |
+
|
| 376 |
+
finally:
|
| 377 |
+
out.close()
|
| 378 |
+
|
| 379 |
+
self.spawn(rpm_cmd)
|
| 380 |
+
|
| 381 |
+
if not self.dry_run:
|
| 382 |
+
if self.distribution.has_ext_modules():
|
| 383 |
+
pyversion = get_python_version()
|
| 384 |
+
else:
|
| 385 |
+
pyversion = 'any'
|
| 386 |
+
|
| 387 |
+
if not self.binary_only:
|
| 388 |
+
srpm = os.path.join(rpm_dir['SRPMS'], source_rpm)
|
| 389 |
+
assert os.path.exists(srpm)
|
| 390 |
+
self.move_file(srpm, self.dist_dir)
|
| 391 |
+
filename = os.path.join(self.dist_dir, source_rpm)
|
| 392 |
+
self.distribution.dist_files.append(('bdist_rpm', pyversion, filename))
|
| 393 |
+
|
| 394 |
+
if not self.source_only:
|
| 395 |
+
for rpm in binary_rpms:
|
| 396 |
+
rpm = os.path.join(rpm_dir['RPMS'], rpm)
|
| 397 |
+
if os.path.exists(rpm):
|
| 398 |
+
self.move_file(rpm, self.dist_dir)
|
| 399 |
+
filename = os.path.join(self.dist_dir, os.path.basename(rpm))
|
| 400 |
+
self.distribution.dist_files.append((
|
| 401 |
+
'bdist_rpm',
|
| 402 |
+
pyversion,
|
| 403 |
+
filename,
|
| 404 |
+
))
|
| 405 |
+
|
| 406 |
+
def _dist_path(self, path):
|
| 407 |
+
return os.path.join(self.dist_dir, os.path.basename(path))
|
| 408 |
+
|
| 409 |
+
def _make_spec_file(self): # noqa: C901
|
| 410 |
+
"""Generate the text of an RPM spec file and return it as a
|
| 411 |
+
list of strings (one per line).
|
| 412 |
+
"""
|
| 413 |
+
# definitions and headers
|
| 414 |
+
spec_file = [
|
| 415 |
+
'%define name ' + self.distribution.get_name(),
|
| 416 |
+
'%define version ' + self.distribution.get_version().replace('-', '_'),
|
| 417 |
+
'%define unmangled_version ' + self.distribution.get_version(),
|
| 418 |
+
'%define release ' + self.release.replace('-', '_'),
|
| 419 |
+
'',
|
| 420 |
+
'Summary: ' + (self.distribution.get_description() or "UNKNOWN"),
|
| 421 |
+
]
|
| 422 |
+
|
| 423 |
+
# Workaround for #14443 which affects some RPM based systems such as
|
| 424 |
+
# RHEL6 (and probably derivatives)
|
| 425 |
+
vendor_hook = subprocess.getoutput('rpm --eval %{__os_install_post}')
|
| 426 |
+
# Generate a potential replacement value for __os_install_post (whilst
|
| 427 |
+
# normalizing the whitespace to simplify the test for whether the
|
| 428 |
+
# invocation of brp-python-bytecompile passes in __python):
|
| 429 |
+
vendor_hook = '\n'.join([
|
| 430 |
+
f' {line.strip()} \\' for line in vendor_hook.splitlines()
|
| 431 |
+
])
|
| 432 |
+
problem = "brp-python-bytecompile \\\n"
|
| 433 |
+
fixed = "brp-python-bytecompile %{__python} \\\n"
|
| 434 |
+
fixed_hook = vendor_hook.replace(problem, fixed)
|
| 435 |
+
if fixed_hook != vendor_hook:
|
| 436 |
+
spec_file.append('# Workaround for https://bugs.python.org/issue14443')
|
| 437 |
+
spec_file.append('%define __os_install_post ' + fixed_hook + '\n')
|
| 438 |
+
|
| 439 |
+
# put locale summaries into spec file
|
| 440 |
+
# XXX not supported for now (hard to put a dictionary
|
| 441 |
+
# in a config file -- arg!)
|
| 442 |
+
# for locale in self.summaries.keys():
|
| 443 |
+
# spec_file.append('Summary(%s): %s' % (locale,
|
| 444 |
+
# self.summaries[locale]))
|
| 445 |
+
|
| 446 |
+
spec_file.extend([
|
| 447 |
+
'Name: %{name}',
|
| 448 |
+
'Version: %{version}',
|
| 449 |
+
'Release: %{release}',
|
| 450 |
+
])
|
| 451 |
+
|
| 452 |
+
# XXX yuck! this filename is available from the "sdist" command,
|
| 453 |
+
# but only after it has run: and we create the spec file before
|
| 454 |
+
# running "sdist", in case of --spec-only.
|
| 455 |
+
if self.use_bzip2:
|
| 456 |
+
spec_file.append('Source0: %{name}-%{unmangled_version}.tar.bz2')
|
| 457 |
+
else:
|
| 458 |
+
spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz')
|
| 459 |
+
|
| 460 |
+
spec_file.extend([
|
| 461 |
+
'License: ' + (self.distribution.get_license() or "UNKNOWN"),
|
| 462 |
+
'Group: ' + self.group,
|
| 463 |
+
'BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot',
|
| 464 |
+
'Prefix: %{_prefix}',
|
| 465 |
+
])
|
| 466 |
+
|
| 467 |
+
if not self.force_arch:
|
| 468 |
+
# noarch if no extension modules
|
| 469 |
+
if not self.distribution.has_ext_modules():
|
| 470 |
+
spec_file.append('BuildArch: noarch')
|
| 471 |
+
else:
|
| 472 |
+
spec_file.append(f'BuildArch: {self.force_arch}')
|
| 473 |
+
|
| 474 |
+
for field in (
|
| 475 |
+
'Vendor',
|
| 476 |
+
'Packager',
|
| 477 |
+
'Provides',
|
| 478 |
+
'Requires',
|
| 479 |
+
'Conflicts',
|
| 480 |
+
'Obsoletes',
|
| 481 |
+
):
|
| 482 |
+
val = getattr(self, field.lower())
|
| 483 |
+
if isinstance(val, list):
|
| 484 |
+
spec_file.append('{}: {}'.format(field, ' '.join(val)))
|
| 485 |
+
elif val is not None:
|
| 486 |
+
spec_file.append(f'{field}: {val}')
|
| 487 |
+
|
| 488 |
+
if self.distribution.get_url():
|
| 489 |
+
spec_file.append('Url: ' + self.distribution.get_url())
|
| 490 |
+
|
| 491 |
+
if self.distribution_name:
|
| 492 |
+
spec_file.append('Distribution: ' + self.distribution_name)
|
| 493 |
+
|
| 494 |
+
if self.build_requires:
|
| 495 |
+
spec_file.append('BuildRequires: ' + ' '.join(self.build_requires))
|
| 496 |
+
|
| 497 |
+
if self.icon:
|
| 498 |
+
spec_file.append('Icon: ' + os.path.basename(self.icon))
|
| 499 |
+
|
| 500 |
+
if self.no_autoreq:
|
| 501 |
+
spec_file.append('AutoReq: 0')
|
| 502 |
+
|
| 503 |
+
spec_file.extend([
|
| 504 |
+
'',
|
| 505 |
+
'%description',
|
| 506 |
+
self.distribution.get_long_description() or "",
|
| 507 |
+
])
|
| 508 |
+
|
| 509 |
+
# put locale descriptions into spec file
|
| 510 |
+
# XXX again, suppressed because config file syntax doesn't
|
| 511 |
+
# easily support this ;-(
|
| 512 |
+
# for locale in self.descriptions.keys():
|
| 513 |
+
# spec_file.extend([
|
| 514 |
+
# '',
|
| 515 |
+
# '%description -l ' + locale,
|
| 516 |
+
# self.descriptions[locale],
|
| 517 |
+
# ])
|
| 518 |
+
|
| 519 |
+
# rpm scripts
|
| 520 |
+
# figure out default build script
|
| 521 |
+
def_setup_call = f"{self.python} {os.path.basename(sys.argv[0])}"
|
| 522 |
+
def_build = f"{def_setup_call} build"
|
| 523 |
+
if self.use_rpm_opt_flags:
|
| 524 |
+
def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
|
| 525 |
+
|
| 526 |
+
# insert contents of files
|
| 527 |
+
|
| 528 |
+
# XXX this is kind of misleading: user-supplied options are files
|
| 529 |
+
# that we open and interpolate into the spec file, but the defaults
|
| 530 |
+
# are just text that we drop in as-is. Hmmm.
|
| 531 |
+
|
| 532 |
+
install_cmd = f'{def_setup_call} install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES'
|
| 533 |
+
|
| 534 |
+
script_options = [
|
| 535 |
+
('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"),
|
| 536 |
+
('build', 'build_script', def_build),
|
| 537 |
+
('install', 'install_script', install_cmd),
|
| 538 |
+
('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
|
| 539 |
+
('verifyscript', 'verify_script', None),
|
| 540 |
+
('pre', 'pre_install', None),
|
| 541 |
+
('post', 'post_install', None),
|
| 542 |
+
('preun', 'pre_uninstall', None),
|
| 543 |
+
('postun', 'post_uninstall', None),
|
| 544 |
+
]
|
| 545 |
+
|
| 546 |
+
for rpm_opt, attr, default in script_options:
|
| 547 |
+
# Insert contents of file referred to, if no file is referred to
|
| 548 |
+
# use 'default' as contents of script
|
| 549 |
+
val = getattr(self, attr)
|
| 550 |
+
if val or default:
|
| 551 |
+
spec_file.extend([
|
| 552 |
+
'',
|
| 553 |
+
'%' + rpm_opt,
|
| 554 |
+
])
|
| 555 |
+
if val:
|
| 556 |
+
with open(val) as f:
|
| 557 |
+
spec_file.extend(f.read().split('\n'))
|
| 558 |
+
else:
|
| 559 |
+
spec_file.append(default)
|
| 560 |
+
|
| 561 |
+
# files section
|
| 562 |
+
spec_file.extend([
|
| 563 |
+
'',
|
| 564 |
+
'%files -f INSTALLED_FILES',
|
| 565 |
+
'%defattr(-,root,root)',
|
| 566 |
+
])
|
| 567 |
+
|
| 568 |
+
if self.doc_files:
|
| 569 |
+
spec_file.append('%doc ' + ' '.join(self.doc_files))
|
| 570 |
+
|
| 571 |
+
if self.changelog:
|
| 572 |
+
spec_file.extend([
|
| 573 |
+
'',
|
| 574 |
+
'%changelog',
|
| 575 |
+
])
|
| 576 |
+
spec_file.extend(self.changelog)
|
| 577 |
+
|
| 578 |
+
return spec_file
|
| 579 |
+
|
| 580 |
+
def _format_changelog(self, changelog):
|
| 581 |
+
"""Format the changelog correctly and convert it to a list of strings"""
|
| 582 |
+
if not changelog:
|
| 583 |
+
return changelog
|
| 584 |
+
new_changelog = []
|
| 585 |
+
for line in changelog.strip().split('\n'):
|
| 586 |
+
line = line.strip()
|
| 587 |
+
if line[0] == '*':
|
| 588 |
+
new_changelog.extend(['', line])
|
| 589 |
+
elif line[0] == '-':
|
| 590 |
+
new_changelog.append(line)
|
| 591 |
+
else:
|
| 592 |
+
new_changelog.append(' ' + line)
|
| 593 |
+
|
| 594 |
+
# strip trailing newline inserted by first changelog entry
|
| 595 |
+
if not new_changelog[0]:
|
| 596 |
+
del new_changelog[0]
|
| 597 |
+
|
| 598 |
+
return new_changelog
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build.py
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.build
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'build' command."""
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
import sysconfig
|
| 10 |
+
from collections.abc import Callable
|
| 11 |
+
from typing import ClassVar
|
| 12 |
+
|
| 13 |
+
from ..ccompiler import show_compilers
|
| 14 |
+
from ..core import Command
|
| 15 |
+
from ..errors import DistutilsOptionError
|
| 16 |
+
from ..util import get_platform
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class build(Command):
|
| 20 |
+
description = "build everything needed to install"
|
| 21 |
+
|
| 22 |
+
user_options = [
|
| 23 |
+
('build-base=', 'b', "base directory for build library"),
|
| 24 |
+
('build-purelib=', None, "build directory for platform-neutral distributions"),
|
| 25 |
+
('build-platlib=', None, "build directory for platform-specific distributions"),
|
| 26 |
+
(
|
| 27 |
+
'build-lib=',
|
| 28 |
+
None,
|
| 29 |
+
"build directory for all distribution (defaults to either build-purelib or build-platlib",
|
| 30 |
+
),
|
| 31 |
+
('build-scripts=', None, "build directory for scripts"),
|
| 32 |
+
('build-temp=', 't', "temporary build directory"),
|
| 33 |
+
(
|
| 34 |
+
'plat-name=',
|
| 35 |
+
'p',
|
| 36 |
+
f"platform name to build for, if supported [default: {get_platform()}]",
|
| 37 |
+
),
|
| 38 |
+
('compiler=', 'c', "specify the compiler type"),
|
| 39 |
+
('parallel=', 'j', "number of parallel build jobs"),
|
| 40 |
+
('debug', 'g', "compile extensions and libraries with debugging information"),
|
| 41 |
+
('force', 'f', "forcibly build everything (ignore file timestamps)"),
|
| 42 |
+
('executable=', 'e', "specify final destination interpreter path (build.py)"),
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
boolean_options: ClassVar[list[str]] = ['debug', 'force']
|
| 46 |
+
|
| 47 |
+
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], object]]]] = [
|
| 48 |
+
('help-compiler', None, "list available compilers", show_compilers),
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
def initialize_options(self):
|
| 52 |
+
self.build_base = 'build'
|
| 53 |
+
# these are decided only after 'build_base' has its final value
|
| 54 |
+
# (unless overridden by the user or client)
|
| 55 |
+
self.build_purelib = None
|
| 56 |
+
self.build_platlib = None
|
| 57 |
+
self.build_lib = None
|
| 58 |
+
self.build_temp = None
|
| 59 |
+
self.build_scripts = None
|
| 60 |
+
self.compiler = None
|
| 61 |
+
self.plat_name = None
|
| 62 |
+
self.debug = None
|
| 63 |
+
self.force = False
|
| 64 |
+
self.executable = None
|
| 65 |
+
self.parallel = None
|
| 66 |
+
|
| 67 |
+
def finalize_options(self) -> None: # noqa: C901
|
| 68 |
+
if self.plat_name is None:
|
| 69 |
+
self.plat_name = get_platform()
|
| 70 |
+
else:
|
| 71 |
+
# plat-name only supported for windows (other platforms are
|
| 72 |
+
# supported via ./configure flags, if at all). Avoid misleading
|
| 73 |
+
# other platforms.
|
| 74 |
+
if os.name != 'nt':
|
| 75 |
+
raise DistutilsOptionError(
|
| 76 |
+
"--plat-name only supported on Windows (try "
|
| 77 |
+
"using './configure --help' on your platform)"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
plat_specifier = f".{self.plat_name}-{sys.implementation.cache_tag}"
|
| 81 |
+
|
| 82 |
+
# Python 3.13+ with --disable-gil shouldn't share build directories
|
| 83 |
+
if sysconfig.get_config_var('Py_GIL_DISABLED'):
|
| 84 |
+
plat_specifier += 't'
|
| 85 |
+
|
| 86 |
+
# Make it so Python 2.x and Python 2.x with --with-pydebug don't
|
| 87 |
+
# share the same build directories. Doing so confuses the build
|
| 88 |
+
# process for C modules
|
| 89 |
+
if hasattr(sys, 'gettotalrefcount'):
|
| 90 |
+
plat_specifier += '-pydebug'
|
| 91 |
+
|
| 92 |
+
# 'build_purelib' and 'build_platlib' just default to 'lib' and
|
| 93 |
+
# 'lib.<plat>' under the base build directory. We only use one of
|
| 94 |
+
# them for a given distribution, though --
|
| 95 |
+
if self.build_purelib is None:
|
| 96 |
+
self.build_purelib = os.path.join(self.build_base, 'lib')
|
| 97 |
+
if self.build_platlib is None:
|
| 98 |
+
self.build_platlib = os.path.join(self.build_base, 'lib' + plat_specifier)
|
| 99 |
+
|
| 100 |
+
# 'build_lib' is the actual directory that we will use for this
|
| 101 |
+
# particular module distribution -- if user didn't supply it, pick
|
| 102 |
+
# one of 'build_purelib' or 'build_platlib'.
|
| 103 |
+
if self.build_lib is None:
|
| 104 |
+
if self.distribution.has_ext_modules():
|
| 105 |
+
self.build_lib = self.build_platlib
|
| 106 |
+
else:
|
| 107 |
+
self.build_lib = self.build_purelib
|
| 108 |
+
|
| 109 |
+
# 'build_temp' -- temporary directory for compiler turds,
|
| 110 |
+
# "build/temp.<plat>"
|
| 111 |
+
if self.build_temp is None:
|
| 112 |
+
self.build_temp = os.path.join(self.build_base, 'temp' + plat_specifier)
|
| 113 |
+
if self.build_scripts is None:
|
| 114 |
+
self.build_scripts = os.path.join(
|
| 115 |
+
self.build_base,
|
| 116 |
+
f'scripts-{sys.version_info.major}.{sys.version_info.minor}',
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
if self.executable is None and sys.executable:
|
| 120 |
+
self.executable = os.path.normpath(sys.executable)
|
| 121 |
+
|
| 122 |
+
if isinstance(self.parallel, str):
|
| 123 |
+
try:
|
| 124 |
+
self.parallel = int(self.parallel)
|
| 125 |
+
except ValueError:
|
| 126 |
+
raise DistutilsOptionError("parallel should be an integer")
|
| 127 |
+
|
| 128 |
+
def run(self) -> None:
|
| 129 |
+
# Run all relevant sub-commands. This will be some subset of:
|
| 130 |
+
# - build_py - pure Python modules
|
| 131 |
+
# - build_clib - standalone C libraries
|
| 132 |
+
# - build_ext - Python extensions
|
| 133 |
+
# - build_scripts - (Python) scripts
|
| 134 |
+
for cmd_name in self.get_sub_commands():
|
| 135 |
+
self.run_command(cmd_name)
|
| 136 |
+
|
| 137 |
+
# -- Predicates for the sub-command list ---------------------------
|
| 138 |
+
|
| 139 |
+
def has_pure_modules(self):
|
| 140 |
+
return self.distribution.has_pure_modules()
|
| 141 |
+
|
| 142 |
+
def has_c_libraries(self):
|
| 143 |
+
return self.distribution.has_c_libraries()
|
| 144 |
+
|
| 145 |
+
def has_ext_modules(self):
|
| 146 |
+
return self.distribution.has_ext_modules()
|
| 147 |
+
|
| 148 |
+
def has_scripts(self):
|
| 149 |
+
return self.distribution.has_scripts()
|
| 150 |
+
|
| 151 |
+
sub_commands = [
|
| 152 |
+
('build_py', has_pure_modules),
|
| 153 |
+
('build_clib', has_c_libraries),
|
| 154 |
+
('build_ext', has_ext_modules),
|
| 155 |
+
('build_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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.build_clib
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'build_clib' command, to build a C/C++ library
|
| 4 |
+
that is included in the module distribution and needed by an extension
|
| 5 |
+
module."""
|
| 6 |
+
|
| 7 |
+
# XXX this module has *lots* of code ripped-off quite transparently from
|
| 8 |
+
# build_ext.py -- not surprisingly really, as the work required to build
|
| 9 |
+
# a static library from a collection of C source files is not really all
|
| 10 |
+
# that different from what's required to build a shared object file from
|
| 11 |
+
# a collection of C source files. Nevertheless, I haven't done the
|
| 12 |
+
# necessary refactoring to account for the overlap in code between the
|
| 13 |
+
# two modules, mainly because a number of subtle details changed in the
|
| 14 |
+
# cut 'n paste. Sigh.
|
| 15 |
+
from __future__ import annotations
|
| 16 |
+
|
| 17 |
+
import os
|
| 18 |
+
from collections.abc import Callable
|
| 19 |
+
from distutils._log import log
|
| 20 |
+
from typing import ClassVar
|
| 21 |
+
|
| 22 |
+
from ..ccompiler import new_compiler, show_compilers
|
| 23 |
+
from ..core import Command
|
| 24 |
+
from ..errors import DistutilsSetupError
|
| 25 |
+
from ..sysconfig import customize_compiler
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class build_clib(Command):
|
| 29 |
+
description = "build C/C++ libraries used by Python extensions"
|
| 30 |
+
|
| 31 |
+
user_options: ClassVar[list[tuple[str, str, str]]] = [
|
| 32 |
+
('build-clib=', 'b', "directory to build C/C++ libraries to"),
|
| 33 |
+
('build-temp=', 't', "directory to put temporary build by-products"),
|
| 34 |
+
('debug', 'g', "compile with debugging information"),
|
| 35 |
+
('force', 'f', "forcibly build everything (ignore file timestamps)"),
|
| 36 |
+
('compiler=', 'c', "specify the compiler type"),
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
boolean_options: ClassVar[list[str]] = ['debug', 'force']
|
| 40 |
+
|
| 41 |
+
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], object]]]] = [
|
| 42 |
+
('help-compiler', None, "list available compilers", show_compilers),
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
def initialize_options(self):
|
| 46 |
+
self.build_clib = None
|
| 47 |
+
self.build_temp = None
|
| 48 |
+
|
| 49 |
+
# List of libraries to build
|
| 50 |
+
self.libraries = None
|
| 51 |
+
|
| 52 |
+
# Compilation options for all libraries
|
| 53 |
+
self.include_dirs = None
|
| 54 |
+
self.define = None
|
| 55 |
+
self.undef = None
|
| 56 |
+
self.debug = None
|
| 57 |
+
self.force = False
|
| 58 |
+
self.compiler = None
|
| 59 |
+
|
| 60 |
+
def finalize_options(self) -> None:
|
| 61 |
+
# This might be confusing: both build-clib and build-temp default
|
| 62 |
+
# to build-temp as defined by the "build" command. This is because
|
| 63 |
+
# I think that C libraries are really just temporary build
|
| 64 |
+
# by-products, at least from the point of view of building Python
|
| 65 |
+
# extensions -- but I want to keep my options open.
|
| 66 |
+
self.set_undefined_options(
|
| 67 |
+
'build',
|
| 68 |
+
('build_temp', 'build_clib'),
|
| 69 |
+
('build_temp', 'build_temp'),
|
| 70 |
+
('compiler', 'compiler'),
|
| 71 |
+
('debug', 'debug'),
|
| 72 |
+
('force', 'force'),
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
self.libraries = self.distribution.libraries
|
| 76 |
+
if self.libraries:
|
| 77 |
+
self.check_library_list(self.libraries)
|
| 78 |
+
|
| 79 |
+
if self.include_dirs is None:
|
| 80 |
+
self.include_dirs = self.distribution.include_dirs or []
|
| 81 |
+
if isinstance(self.include_dirs, str):
|
| 82 |
+
self.include_dirs = self.include_dirs.split(os.pathsep)
|
| 83 |
+
|
| 84 |
+
# XXX same as for build_ext -- what about 'self.define' and
|
| 85 |
+
# 'self.undef' ?
|
| 86 |
+
|
| 87 |
+
def run(self) -> None:
|
| 88 |
+
if not self.libraries:
|
| 89 |
+
return
|
| 90 |
+
|
| 91 |
+
self.compiler = new_compiler(
|
| 92 |
+
compiler=self.compiler, dry_run=self.dry_run, force=self.force
|
| 93 |
+
)
|
| 94 |
+
customize_compiler(self.compiler)
|
| 95 |
+
|
| 96 |
+
if self.include_dirs is not None:
|
| 97 |
+
self.compiler.set_include_dirs(self.include_dirs)
|
| 98 |
+
if self.define is not None:
|
| 99 |
+
# 'define' option is a list of (name,value) tuples
|
| 100 |
+
for name, value in self.define:
|
| 101 |
+
self.compiler.define_macro(name, value)
|
| 102 |
+
if self.undef is not None:
|
| 103 |
+
for macro in self.undef:
|
| 104 |
+
self.compiler.undefine_macro(macro)
|
| 105 |
+
|
| 106 |
+
self.build_libraries(self.libraries)
|
| 107 |
+
|
| 108 |
+
def check_library_list(self, libraries) -> None:
|
| 109 |
+
"""Ensure that the list of libraries is valid.
|
| 110 |
+
|
| 111 |
+
`library` is presumably provided as a command option 'libraries'.
|
| 112 |
+
This method checks that it is a list of 2-tuples, where the tuples
|
| 113 |
+
are (library_name, build_info_dict).
|
| 114 |
+
|
| 115 |
+
Raise DistutilsSetupError if the structure is invalid anywhere;
|
| 116 |
+
just returns otherwise.
|
| 117 |
+
"""
|
| 118 |
+
if not isinstance(libraries, list):
|
| 119 |
+
raise DistutilsSetupError("'libraries' option must be a list of tuples")
|
| 120 |
+
|
| 121 |
+
for lib in libraries:
|
| 122 |
+
if not isinstance(lib, tuple) and len(lib) != 2:
|
| 123 |
+
raise DistutilsSetupError("each element of 'libraries' must a 2-tuple")
|
| 124 |
+
|
| 125 |
+
name, build_info = lib
|
| 126 |
+
|
| 127 |
+
if not isinstance(name, str):
|
| 128 |
+
raise DistutilsSetupError(
|
| 129 |
+
"first element of each tuple in 'libraries' "
|
| 130 |
+
"must be a string (the library name)"
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
if '/' in name or (os.sep != '/' and os.sep in name):
|
| 134 |
+
raise DistutilsSetupError(
|
| 135 |
+
f"bad library name '{lib[0]}': may not contain directory separators"
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
if not isinstance(build_info, dict):
|
| 139 |
+
raise DistutilsSetupError(
|
| 140 |
+
"second element of each tuple in 'libraries' "
|
| 141 |
+
"must be a dictionary (build info)"
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
def get_library_names(self):
|
| 145 |
+
# Assume the library list is valid -- 'check_library_list()' is
|
| 146 |
+
# called from 'finalize_options()', so it should be!
|
| 147 |
+
if not self.libraries:
|
| 148 |
+
return None
|
| 149 |
+
|
| 150 |
+
lib_names = []
|
| 151 |
+
for lib_name, _build_info in self.libraries:
|
| 152 |
+
lib_names.append(lib_name)
|
| 153 |
+
return lib_names
|
| 154 |
+
|
| 155 |
+
def get_source_files(self):
|
| 156 |
+
self.check_library_list(self.libraries)
|
| 157 |
+
filenames = []
|
| 158 |
+
for lib_name, build_info in self.libraries:
|
| 159 |
+
sources = build_info.get('sources')
|
| 160 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
| 161 |
+
raise DistutilsSetupError(
|
| 162 |
+
f"in 'libraries' option (library '{lib_name}'), "
|
| 163 |
+
"'sources' must be present and must be "
|
| 164 |
+
"a list of source filenames"
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
filenames.extend(sources)
|
| 168 |
+
return filenames
|
| 169 |
+
|
| 170 |
+
def build_libraries(self, libraries) -> None:
|
| 171 |
+
for lib_name, build_info in libraries:
|
| 172 |
+
sources = build_info.get('sources')
|
| 173 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
| 174 |
+
raise DistutilsSetupError(
|
| 175 |
+
f"in 'libraries' option (library '{lib_name}'), "
|
| 176 |
+
"'sources' must be present and must be "
|
| 177 |
+
"a list of source filenames"
|
| 178 |
+
)
|
| 179 |
+
sources = list(sources)
|
| 180 |
+
|
| 181 |
+
log.info("building '%s' library", lib_name)
|
| 182 |
+
|
| 183 |
+
# First, compile the source code to object files in the library
|
| 184 |
+
# directory. (This should probably change to putting object
|
| 185 |
+
# files in a temporary build directory.)
|
| 186 |
+
macros = build_info.get('macros')
|
| 187 |
+
include_dirs = build_info.get('include_dirs')
|
| 188 |
+
objects = self.compiler.compile(
|
| 189 |
+
sources,
|
| 190 |
+
output_dir=self.build_temp,
|
| 191 |
+
macros=macros,
|
| 192 |
+
include_dirs=include_dirs,
|
| 193 |
+
debug=self.debug,
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
# Now "link" the object files together into a static library.
|
| 197 |
+
# (On Unix at least, this isn't really linking -- it just
|
| 198 |
+
# builds an archive. Whatever.)
|
| 199 |
+
self.compiler.create_static_lib(
|
| 200 |
+
objects, lib_name, output_dir=self.build_clib, debug=self.debug
|
| 201 |
+
)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py
ADDED
|
@@ -0,0 +1,812 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.build_ext
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'build_ext' command, for building extension
|
| 4 |
+
modules (currently limited to C extensions, should accommodate C++
|
| 5 |
+
extensions ASAP)."""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import contextlib
|
| 10 |
+
import os
|
| 11 |
+
import re
|
| 12 |
+
import sys
|
| 13 |
+
from collections.abc import Callable
|
| 14 |
+
from distutils._log import log
|
| 15 |
+
from site import USER_BASE
|
| 16 |
+
from typing import ClassVar
|
| 17 |
+
|
| 18 |
+
from .._modified import newer_group
|
| 19 |
+
from ..ccompiler import new_compiler, show_compilers
|
| 20 |
+
from ..core import Command
|
| 21 |
+
from ..errors import (
|
| 22 |
+
CCompilerError,
|
| 23 |
+
CompileError,
|
| 24 |
+
DistutilsError,
|
| 25 |
+
DistutilsOptionError,
|
| 26 |
+
DistutilsPlatformError,
|
| 27 |
+
DistutilsSetupError,
|
| 28 |
+
)
|
| 29 |
+
from ..extension import Extension
|
| 30 |
+
from ..sysconfig import customize_compiler, get_config_h_filename, get_python_version
|
| 31 |
+
from ..util import get_platform, is_freethreaded, is_mingw
|
| 32 |
+
|
| 33 |
+
# An extension name is just a dot-separated list of Python NAMEs (ie.
|
| 34 |
+
# the same as a fully-qualified module name).
|
| 35 |
+
extension_name_re = re.compile(r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$')
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class build_ext(Command):
|
| 39 |
+
description = "build C/C++ extensions (compile/link to build directory)"
|
| 40 |
+
|
| 41 |
+
# XXX thoughts on how to deal with complex command-line options like
|
| 42 |
+
# these, i.e. how to make it so fancy_getopt can suck them off the
|
| 43 |
+
# command line and make it look like setup.py defined the appropriate
|
| 44 |
+
# lists of tuples of what-have-you.
|
| 45 |
+
# - each command needs a callback to process its command-line options
|
| 46 |
+
# - Command.__init__() needs access to its share of the whole
|
| 47 |
+
# command line (must ultimately come from
|
| 48 |
+
# Distribution.parse_command_line())
|
| 49 |
+
# - it then calls the current command class' option-parsing
|
| 50 |
+
# callback to deal with weird options like -D, which have to
|
| 51 |
+
# parse the option text and churn out some custom data
|
| 52 |
+
# structure
|
| 53 |
+
# - that data structure (in this case, a list of 2-tuples)
|
| 54 |
+
# will then be present in the command object by the time
|
| 55 |
+
# we get to finalize_options() (i.e. the constructor
|
| 56 |
+
# takes care of both command-line and client options
|
| 57 |
+
# in between initialize_options() and finalize_options())
|
| 58 |
+
|
| 59 |
+
sep_by = f" (separated by '{os.pathsep}')"
|
| 60 |
+
user_options = [
|
| 61 |
+
('build-lib=', 'b', "directory for compiled extension modules"),
|
| 62 |
+
('build-temp=', 't', "directory for temporary files (build by-products)"),
|
| 63 |
+
(
|
| 64 |
+
'plat-name=',
|
| 65 |
+
'p',
|
| 66 |
+
"platform name to cross-compile for, if supported "
|
| 67 |
+
f"[default: {get_platform()}]",
|
| 68 |
+
),
|
| 69 |
+
(
|
| 70 |
+
'inplace',
|
| 71 |
+
'i',
|
| 72 |
+
"ignore build-lib and put compiled extensions into the source "
|
| 73 |
+
"directory alongside your pure Python modules",
|
| 74 |
+
),
|
| 75 |
+
(
|
| 76 |
+
'include-dirs=',
|
| 77 |
+
'I',
|
| 78 |
+
"list of directories to search for header files" + sep_by,
|
| 79 |
+
),
|
| 80 |
+
('define=', 'D', "C preprocessor macros to define"),
|
| 81 |
+
('undef=', 'U', "C preprocessor macros to undefine"),
|
| 82 |
+
('libraries=', 'l', "external C libraries to link with"),
|
| 83 |
+
(
|
| 84 |
+
'library-dirs=',
|
| 85 |
+
'L',
|
| 86 |
+
"directories to search for external C libraries" + sep_by,
|
| 87 |
+
),
|
| 88 |
+
('rpath=', 'R', "directories to search for shared C libraries at runtime"),
|
| 89 |
+
('link-objects=', 'O', "extra explicit link objects to include in the link"),
|
| 90 |
+
('debug', 'g', "compile/link with debugging information"),
|
| 91 |
+
('force', 'f', "forcibly build everything (ignore file timestamps)"),
|
| 92 |
+
('compiler=', 'c', "specify the compiler type"),
|
| 93 |
+
('parallel=', 'j', "number of parallel build jobs"),
|
| 94 |
+
('swig-cpp', None, "make SWIG create C++ files (default is C)"),
|
| 95 |
+
('swig-opts=', None, "list of SWIG command line options"),
|
| 96 |
+
('swig=', None, "path to the SWIG executable"),
|
| 97 |
+
('user', None, "add user include, library and rpath"),
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
boolean_options: ClassVar[list[str]] = [
|
| 101 |
+
'inplace',
|
| 102 |
+
'debug',
|
| 103 |
+
'force',
|
| 104 |
+
'swig-cpp',
|
| 105 |
+
'user',
|
| 106 |
+
]
|
| 107 |
+
|
| 108 |
+
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], object]]]] = [
|
| 109 |
+
('help-compiler', None, "list available compilers", show_compilers),
|
| 110 |
+
]
|
| 111 |
+
|
| 112 |
+
def initialize_options(self):
|
| 113 |
+
self.extensions = None
|
| 114 |
+
self.build_lib = None
|
| 115 |
+
self.plat_name = None
|
| 116 |
+
self.build_temp = None
|
| 117 |
+
self.inplace = False
|
| 118 |
+
self.package = None
|
| 119 |
+
|
| 120 |
+
self.include_dirs = None
|
| 121 |
+
self.define = None
|
| 122 |
+
self.undef = None
|
| 123 |
+
self.libraries = None
|
| 124 |
+
self.library_dirs = None
|
| 125 |
+
self.rpath = None
|
| 126 |
+
self.link_objects = None
|
| 127 |
+
self.debug = None
|
| 128 |
+
self.force = None
|
| 129 |
+
self.compiler = None
|
| 130 |
+
self.swig = None
|
| 131 |
+
self.swig_cpp = None
|
| 132 |
+
self.swig_opts = None
|
| 133 |
+
self.user = None
|
| 134 |
+
self.parallel = None
|
| 135 |
+
|
| 136 |
+
@staticmethod
|
| 137 |
+
def _python_lib_dir(sysconfig):
|
| 138 |
+
"""
|
| 139 |
+
Resolve Python's library directory for building extensions
|
| 140 |
+
that rely on a shared Python library.
|
| 141 |
+
|
| 142 |
+
See python/cpython#44264 and python/cpython#48686
|
| 143 |
+
"""
|
| 144 |
+
if not sysconfig.get_config_var('Py_ENABLE_SHARED'):
|
| 145 |
+
return
|
| 146 |
+
|
| 147 |
+
if sysconfig.python_build:
|
| 148 |
+
yield '.'
|
| 149 |
+
return
|
| 150 |
+
|
| 151 |
+
if sys.platform == 'zos':
|
| 152 |
+
# On z/OS, a user is not required to install Python to
|
| 153 |
+
# a predetermined path, but can use Python portably
|
| 154 |
+
installed_dir = sysconfig.get_config_var('base')
|
| 155 |
+
lib_dir = sysconfig.get_config_var('platlibdir')
|
| 156 |
+
yield os.path.join(installed_dir, lib_dir)
|
| 157 |
+
else:
|
| 158 |
+
# building third party extensions
|
| 159 |
+
yield sysconfig.get_config_var('LIBDIR')
|
| 160 |
+
|
| 161 |
+
def finalize_options(self) -> None: # noqa: C901
|
| 162 |
+
from distutils import sysconfig
|
| 163 |
+
|
| 164 |
+
self.set_undefined_options(
|
| 165 |
+
'build',
|
| 166 |
+
('build_lib', 'build_lib'),
|
| 167 |
+
('build_temp', 'build_temp'),
|
| 168 |
+
('compiler', 'compiler'),
|
| 169 |
+
('debug', 'debug'),
|
| 170 |
+
('force', 'force'),
|
| 171 |
+
('parallel', 'parallel'),
|
| 172 |
+
('plat_name', 'plat_name'),
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
if self.package is None:
|
| 176 |
+
self.package = self.distribution.ext_package
|
| 177 |
+
|
| 178 |
+
self.extensions = self.distribution.ext_modules
|
| 179 |
+
|
| 180 |
+
# Make sure Python's include directories (for Python.h, pyconfig.h,
|
| 181 |
+
# etc.) are in the include search path.
|
| 182 |
+
py_include = sysconfig.get_python_inc()
|
| 183 |
+
plat_py_include = sysconfig.get_python_inc(plat_specific=True)
|
| 184 |
+
if self.include_dirs is None:
|
| 185 |
+
self.include_dirs = self.distribution.include_dirs or []
|
| 186 |
+
if isinstance(self.include_dirs, str):
|
| 187 |
+
self.include_dirs = self.include_dirs.split(os.pathsep)
|
| 188 |
+
|
| 189 |
+
# If in a virtualenv, add its include directory
|
| 190 |
+
# Issue 16116
|
| 191 |
+
if sys.exec_prefix != sys.base_exec_prefix:
|
| 192 |
+
self.include_dirs.append(os.path.join(sys.exec_prefix, 'include'))
|
| 193 |
+
|
| 194 |
+
# Put the Python "system" include dir at the end, so that
|
| 195 |
+
# any local include dirs take precedence.
|
| 196 |
+
self.include_dirs.extend(py_include.split(os.path.pathsep))
|
| 197 |
+
if plat_py_include != py_include:
|
| 198 |
+
self.include_dirs.extend(plat_py_include.split(os.path.pathsep))
|
| 199 |
+
|
| 200 |
+
self.ensure_string_list('libraries')
|
| 201 |
+
self.ensure_string_list('link_objects')
|
| 202 |
+
|
| 203 |
+
# Life is easier if we're not forever checking for None, so
|
| 204 |
+
# simplify these options to empty lists if unset
|
| 205 |
+
if self.libraries is None:
|
| 206 |
+
self.libraries = []
|
| 207 |
+
if self.library_dirs is None:
|
| 208 |
+
self.library_dirs = []
|
| 209 |
+
elif isinstance(self.library_dirs, str):
|
| 210 |
+
self.library_dirs = self.library_dirs.split(os.pathsep)
|
| 211 |
+
|
| 212 |
+
if self.rpath is None:
|
| 213 |
+
self.rpath = []
|
| 214 |
+
elif isinstance(self.rpath, str):
|
| 215 |
+
self.rpath = self.rpath.split(os.pathsep)
|
| 216 |
+
|
| 217 |
+
# for extensions under windows use different directories
|
| 218 |
+
# for Release and Debug builds.
|
| 219 |
+
# also Python's library directory must be appended to library_dirs
|
| 220 |
+
if os.name == 'nt' and not is_mingw():
|
| 221 |
+
# the 'libs' directory is for binary installs - we assume that
|
| 222 |
+
# must be the *native* platform. But we don't really support
|
| 223 |
+
# cross-compiling via a binary install anyway, so we let it go.
|
| 224 |
+
self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
|
| 225 |
+
if sys.base_exec_prefix != sys.prefix: # Issue 16116
|
| 226 |
+
self.library_dirs.append(os.path.join(sys.base_exec_prefix, 'libs'))
|
| 227 |
+
if self.debug:
|
| 228 |
+
self.build_temp = os.path.join(self.build_temp, "Debug")
|
| 229 |
+
else:
|
| 230 |
+
self.build_temp = os.path.join(self.build_temp, "Release")
|
| 231 |
+
|
| 232 |
+
# Append the source distribution include and library directories,
|
| 233 |
+
# this allows distutils on windows to work in the source tree
|
| 234 |
+
self.include_dirs.append(os.path.dirname(get_config_h_filename()))
|
| 235 |
+
self.library_dirs.append(sys.base_exec_prefix)
|
| 236 |
+
|
| 237 |
+
# Use the .lib files for the correct architecture
|
| 238 |
+
if self.plat_name == 'win32':
|
| 239 |
+
suffix = 'win32'
|
| 240 |
+
else:
|
| 241 |
+
# win-amd64
|
| 242 |
+
suffix = self.plat_name[4:]
|
| 243 |
+
new_lib = os.path.join(sys.exec_prefix, 'PCbuild')
|
| 244 |
+
if suffix:
|
| 245 |
+
new_lib = os.path.join(new_lib, suffix)
|
| 246 |
+
self.library_dirs.append(new_lib)
|
| 247 |
+
|
| 248 |
+
# For extensions under Cygwin, Python's library directory must be
|
| 249 |
+
# appended to library_dirs
|
| 250 |
+
if sys.platform[:6] == 'cygwin':
|
| 251 |
+
if not sysconfig.python_build:
|
| 252 |
+
# building third party extensions
|
| 253 |
+
self.library_dirs.append(
|
| 254 |
+
os.path.join(
|
| 255 |
+
sys.prefix, "lib", "python" + get_python_version(), "config"
|
| 256 |
+
)
|
| 257 |
+
)
|
| 258 |
+
else:
|
| 259 |
+
# building python standard extensions
|
| 260 |
+
self.library_dirs.append('.')
|
| 261 |
+
|
| 262 |
+
self.library_dirs.extend(self._python_lib_dir(sysconfig))
|
| 263 |
+
|
| 264 |
+
# The argument parsing will result in self.define being a string, but
|
| 265 |
+
# it has to be a list of 2-tuples. All the preprocessor symbols
|
| 266 |
+
# specified by the 'define' option will be set to '1'. Multiple
|
| 267 |
+
# symbols can be separated with commas.
|
| 268 |
+
|
| 269 |
+
if self.define:
|
| 270 |
+
defines = self.define.split(',')
|
| 271 |
+
self.define = [(symbol, '1') for symbol in defines]
|
| 272 |
+
|
| 273 |
+
# The option for macros to undefine is also a string from the
|
| 274 |
+
# option parsing, but has to be a list. Multiple symbols can also
|
| 275 |
+
# be separated with commas here.
|
| 276 |
+
if self.undef:
|
| 277 |
+
self.undef = self.undef.split(',')
|
| 278 |
+
|
| 279 |
+
if self.swig_opts is None:
|
| 280 |
+
self.swig_opts = []
|
| 281 |
+
else:
|
| 282 |
+
self.swig_opts = self.swig_opts.split(' ')
|
| 283 |
+
|
| 284 |
+
# Finally add the user include and library directories if requested
|
| 285 |
+
if self.user:
|
| 286 |
+
user_include = os.path.join(USER_BASE, "include")
|
| 287 |
+
user_lib = os.path.join(USER_BASE, "lib")
|
| 288 |
+
if os.path.isdir(user_include):
|
| 289 |
+
self.include_dirs.append(user_include)
|
| 290 |
+
if os.path.isdir(user_lib):
|
| 291 |
+
self.library_dirs.append(user_lib)
|
| 292 |
+
self.rpath.append(user_lib)
|
| 293 |
+
|
| 294 |
+
if isinstance(self.parallel, str):
|
| 295 |
+
try:
|
| 296 |
+
self.parallel = int(self.parallel)
|
| 297 |
+
except ValueError:
|
| 298 |
+
raise DistutilsOptionError("parallel should be an integer")
|
| 299 |
+
|
| 300 |
+
def run(self) -> None: # noqa: C901
|
| 301 |
+
# 'self.extensions', as supplied by setup.py, is a list of
|
| 302 |
+
# Extension instances. See the documentation for Extension (in
|
| 303 |
+
# distutils.extension) for details.
|
| 304 |
+
#
|
| 305 |
+
# For backwards compatibility with Distutils 0.8.2 and earlier, we
|
| 306 |
+
# also allow the 'extensions' list to be a list of tuples:
|
| 307 |
+
# (ext_name, build_info)
|
| 308 |
+
# where build_info is a dictionary containing everything that
|
| 309 |
+
# Extension instances do except the name, with a few things being
|
| 310 |
+
# differently named. We convert these 2-tuples to Extension
|
| 311 |
+
# instances as needed.
|
| 312 |
+
|
| 313 |
+
if not self.extensions:
|
| 314 |
+
return
|
| 315 |
+
|
| 316 |
+
# If we were asked to build any C/C++ libraries, make sure that the
|
| 317 |
+
# directory where we put them is in the library search path for
|
| 318 |
+
# linking extensions.
|
| 319 |
+
if self.distribution.has_c_libraries():
|
| 320 |
+
build_clib = self.get_finalized_command('build_clib')
|
| 321 |
+
self.libraries.extend(build_clib.get_library_names() or [])
|
| 322 |
+
self.library_dirs.append(build_clib.build_clib)
|
| 323 |
+
|
| 324 |
+
# Setup the CCompiler object that we'll use to do all the
|
| 325 |
+
# compiling and linking
|
| 326 |
+
self.compiler = new_compiler(
|
| 327 |
+
compiler=self.compiler,
|
| 328 |
+
verbose=self.verbose,
|
| 329 |
+
dry_run=self.dry_run,
|
| 330 |
+
force=self.force,
|
| 331 |
+
)
|
| 332 |
+
customize_compiler(self.compiler)
|
| 333 |
+
# If we are cross-compiling, init the compiler now (if we are not
|
| 334 |
+
# cross-compiling, init would not hurt, but people may rely on
|
| 335 |
+
# late initialization of compiler even if they shouldn't...)
|
| 336 |
+
if os.name == 'nt' and self.plat_name != get_platform():
|
| 337 |
+
self.compiler.initialize(self.plat_name)
|
| 338 |
+
|
| 339 |
+
# The official Windows free threaded Python installer doesn't set
|
| 340 |
+
# Py_GIL_DISABLED because its pyconfig.h is shared with the
|
| 341 |
+
# default build, so define it here (pypa/setuptools#4662).
|
| 342 |
+
if os.name == 'nt' and is_freethreaded():
|
| 343 |
+
self.compiler.define_macro('Py_GIL_DISABLED', '1')
|
| 344 |
+
|
| 345 |
+
# And make sure that any compile/link-related options (which might
|
| 346 |
+
# come from the command-line or from the setup script) are set in
|
| 347 |
+
# that CCompiler object -- that way, they automatically apply to
|
| 348 |
+
# all compiling and linking done here.
|
| 349 |
+
if self.include_dirs is not None:
|
| 350 |
+
self.compiler.set_include_dirs(self.include_dirs)
|
| 351 |
+
if self.define is not None:
|
| 352 |
+
# 'define' option is a list of (name,value) tuples
|
| 353 |
+
for name, value in self.define:
|
| 354 |
+
self.compiler.define_macro(name, value)
|
| 355 |
+
if self.undef is not None:
|
| 356 |
+
for macro in self.undef:
|
| 357 |
+
self.compiler.undefine_macro(macro)
|
| 358 |
+
if self.libraries is not None:
|
| 359 |
+
self.compiler.set_libraries(self.libraries)
|
| 360 |
+
if self.library_dirs is not None:
|
| 361 |
+
self.compiler.set_library_dirs(self.library_dirs)
|
| 362 |
+
if self.rpath is not None:
|
| 363 |
+
self.compiler.set_runtime_library_dirs(self.rpath)
|
| 364 |
+
if self.link_objects is not None:
|
| 365 |
+
self.compiler.set_link_objects(self.link_objects)
|
| 366 |
+
|
| 367 |
+
# Now actually compile and link everything.
|
| 368 |
+
self.build_extensions()
|
| 369 |
+
|
| 370 |
+
def check_extensions_list(self, extensions) -> None: # noqa: C901
|
| 371 |
+
"""Ensure that the list of extensions (presumably provided as a
|
| 372 |
+
command option 'extensions') is valid, i.e. it is a list of
|
| 373 |
+
Extension objects. We also support the old-style list of 2-tuples,
|
| 374 |
+
where the tuples are (ext_name, build_info), which are converted to
|
| 375 |
+
Extension instances here.
|
| 376 |
+
|
| 377 |
+
Raise DistutilsSetupError if the structure is invalid anywhere;
|
| 378 |
+
just returns otherwise.
|
| 379 |
+
"""
|
| 380 |
+
if not isinstance(extensions, list):
|
| 381 |
+
raise DistutilsSetupError(
|
| 382 |
+
"'ext_modules' option must be a list of Extension instances"
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
for i, ext in enumerate(extensions):
|
| 386 |
+
if isinstance(ext, Extension):
|
| 387 |
+
continue # OK! (assume type-checking done
|
| 388 |
+
# by Extension constructor)
|
| 389 |
+
|
| 390 |
+
if not isinstance(ext, tuple) or len(ext) != 2:
|
| 391 |
+
raise DistutilsSetupError(
|
| 392 |
+
"each element of 'ext_modules' option must be an "
|
| 393 |
+
"Extension instance or 2-tuple"
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
ext_name, build_info = ext
|
| 397 |
+
|
| 398 |
+
log.warning(
|
| 399 |
+
"old-style (ext_name, build_info) tuple found in "
|
| 400 |
+
"ext_modules for extension '%s' "
|
| 401 |
+
"-- please convert to Extension instance",
|
| 402 |
+
ext_name,
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
if not (isinstance(ext_name, str) and extension_name_re.match(ext_name)):
|
| 406 |
+
raise DistutilsSetupError(
|
| 407 |
+
"first element of each tuple in 'ext_modules' "
|
| 408 |
+
"must be the extension name (a string)"
|
| 409 |
+
)
|
| 410 |
+
|
| 411 |
+
if not isinstance(build_info, dict):
|
| 412 |
+
raise DistutilsSetupError(
|
| 413 |
+
"second element of each tuple in 'ext_modules' "
|
| 414 |
+
"must be a dictionary (build info)"
|
| 415 |
+
)
|
| 416 |
+
|
| 417 |
+
# OK, the (ext_name, build_info) dict is type-safe: convert it
|
| 418 |
+
# to an Extension instance.
|
| 419 |
+
ext = Extension(ext_name, build_info['sources'])
|
| 420 |
+
|
| 421 |
+
# Easy stuff: one-to-one mapping from dict elements to
|
| 422 |
+
# instance attributes.
|
| 423 |
+
for key in (
|
| 424 |
+
'include_dirs',
|
| 425 |
+
'library_dirs',
|
| 426 |
+
'libraries',
|
| 427 |
+
'extra_objects',
|
| 428 |
+
'extra_compile_args',
|
| 429 |
+
'extra_link_args',
|
| 430 |
+
):
|
| 431 |
+
val = build_info.get(key)
|
| 432 |
+
if val is not None:
|
| 433 |
+
setattr(ext, key, val)
|
| 434 |
+
|
| 435 |
+
# Medium-easy stuff: same syntax/semantics, different names.
|
| 436 |
+
ext.runtime_library_dirs = build_info.get('rpath')
|
| 437 |
+
if 'def_file' in build_info:
|
| 438 |
+
log.warning("'def_file' element of build info dict no longer supported")
|
| 439 |
+
|
| 440 |
+
# Non-trivial stuff: 'macros' split into 'define_macros'
|
| 441 |
+
# and 'undef_macros'.
|
| 442 |
+
macros = build_info.get('macros')
|
| 443 |
+
if macros:
|
| 444 |
+
ext.define_macros = []
|
| 445 |
+
ext.undef_macros = []
|
| 446 |
+
for macro in macros:
|
| 447 |
+
if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
|
| 448 |
+
raise DistutilsSetupError(
|
| 449 |
+
"'macros' element of build info dict must be 1- or 2-tuple"
|
| 450 |
+
)
|
| 451 |
+
if len(macro) == 1:
|
| 452 |
+
ext.undef_macros.append(macro[0])
|
| 453 |
+
elif len(macro) == 2:
|
| 454 |
+
ext.define_macros.append(macro)
|
| 455 |
+
|
| 456 |
+
extensions[i] = ext
|
| 457 |
+
|
| 458 |
+
def get_source_files(self):
|
| 459 |
+
self.check_extensions_list(self.extensions)
|
| 460 |
+
filenames = []
|
| 461 |
+
|
| 462 |
+
# Wouldn't it be neat if we knew the names of header files too...
|
| 463 |
+
for ext in self.extensions:
|
| 464 |
+
filenames.extend(ext.sources)
|
| 465 |
+
return filenames
|
| 466 |
+
|
| 467 |
+
def get_outputs(self):
|
| 468 |
+
# Sanity check the 'extensions' list -- can't assume this is being
|
| 469 |
+
# done in the same run as a 'build_extensions()' call (in fact, we
|
| 470 |
+
# can probably assume that it *isn't*!).
|
| 471 |
+
self.check_extensions_list(self.extensions)
|
| 472 |
+
|
| 473 |
+
# And build the list of output (built) filenames. Note that this
|
| 474 |
+
# ignores the 'inplace' flag, and assumes everything goes in the
|
| 475 |
+
# "build" tree.
|
| 476 |
+
return [self.get_ext_fullpath(ext.name) for ext in self.extensions]
|
| 477 |
+
|
| 478 |
+
def build_extensions(self) -> None:
|
| 479 |
+
# First, sanity-check the 'extensions' list
|
| 480 |
+
self.check_extensions_list(self.extensions)
|
| 481 |
+
if self.parallel:
|
| 482 |
+
self._build_extensions_parallel()
|
| 483 |
+
else:
|
| 484 |
+
self._build_extensions_serial()
|
| 485 |
+
|
| 486 |
+
def _build_extensions_parallel(self):
|
| 487 |
+
workers = self.parallel
|
| 488 |
+
if self.parallel is True:
|
| 489 |
+
workers = os.cpu_count() # may return None
|
| 490 |
+
try:
|
| 491 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 492 |
+
except ImportError:
|
| 493 |
+
workers = None
|
| 494 |
+
|
| 495 |
+
if workers is None:
|
| 496 |
+
self._build_extensions_serial()
|
| 497 |
+
return
|
| 498 |
+
|
| 499 |
+
with ThreadPoolExecutor(max_workers=workers) as executor:
|
| 500 |
+
futures = [
|
| 501 |
+
executor.submit(self.build_extension, ext) for ext in self.extensions
|
| 502 |
+
]
|
| 503 |
+
for ext, fut in zip(self.extensions, futures):
|
| 504 |
+
with self._filter_build_errors(ext):
|
| 505 |
+
fut.result()
|
| 506 |
+
|
| 507 |
+
def _build_extensions_serial(self):
|
| 508 |
+
for ext in self.extensions:
|
| 509 |
+
with self._filter_build_errors(ext):
|
| 510 |
+
self.build_extension(ext)
|
| 511 |
+
|
| 512 |
+
@contextlib.contextmanager
|
| 513 |
+
def _filter_build_errors(self, ext):
|
| 514 |
+
try:
|
| 515 |
+
yield
|
| 516 |
+
except (CCompilerError, DistutilsError, CompileError) as e:
|
| 517 |
+
if not ext.optional:
|
| 518 |
+
raise
|
| 519 |
+
self.warn(f'building extension "{ext.name}" failed: {e}')
|
| 520 |
+
|
| 521 |
+
def build_extension(self, ext) -> None:
|
| 522 |
+
sources = ext.sources
|
| 523 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
| 524 |
+
raise DistutilsSetupError(
|
| 525 |
+
f"in 'ext_modules' option (extension '{ext.name}'), "
|
| 526 |
+
"'sources' must be present and must be "
|
| 527 |
+
"a list of source filenames"
|
| 528 |
+
)
|
| 529 |
+
# sort to make the resulting .so file build reproducible
|
| 530 |
+
sources = sorted(sources)
|
| 531 |
+
|
| 532 |
+
ext_path = self.get_ext_fullpath(ext.name)
|
| 533 |
+
depends = sources + ext.depends
|
| 534 |
+
if not (self.force or newer_group(depends, ext_path, 'newer')):
|
| 535 |
+
log.debug("skipping '%s' extension (up-to-date)", ext.name)
|
| 536 |
+
return
|
| 537 |
+
else:
|
| 538 |
+
log.info("building '%s' extension", ext.name)
|
| 539 |
+
|
| 540 |
+
# First, scan the sources for SWIG definition files (.i), run
|
| 541 |
+
# SWIG on 'em to create .c files, and modify the sources list
|
| 542 |
+
# accordingly.
|
| 543 |
+
sources = self.swig_sources(sources, ext)
|
| 544 |
+
|
| 545 |
+
# Next, compile the source code to object files.
|
| 546 |
+
|
| 547 |
+
# XXX not honouring 'define_macros' or 'undef_macros' -- the
|
| 548 |
+
# CCompiler API needs to change to accommodate this, and I
|
| 549 |
+
# want to do one thing at a time!
|
| 550 |
+
|
| 551 |
+
# Two possible sources for extra compiler arguments:
|
| 552 |
+
# - 'extra_compile_args' in Extension object
|
| 553 |
+
# - CFLAGS environment variable (not particularly
|
| 554 |
+
# elegant, but people seem to expect it and I
|
| 555 |
+
# guess it's useful)
|
| 556 |
+
# The environment variable should take precedence, and
|
| 557 |
+
# any sensible compiler will give precedence to later
|
| 558 |
+
# command line args. Hence we combine them in order:
|
| 559 |
+
extra_args = ext.extra_compile_args or []
|
| 560 |
+
|
| 561 |
+
macros = ext.define_macros[:]
|
| 562 |
+
for undef in ext.undef_macros:
|
| 563 |
+
macros.append((undef,))
|
| 564 |
+
|
| 565 |
+
objects = self.compiler.compile(
|
| 566 |
+
sources,
|
| 567 |
+
output_dir=self.build_temp,
|
| 568 |
+
macros=macros,
|
| 569 |
+
include_dirs=ext.include_dirs,
|
| 570 |
+
debug=self.debug,
|
| 571 |
+
extra_postargs=extra_args,
|
| 572 |
+
depends=ext.depends,
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
# XXX outdated variable, kept here in case third-part code
|
| 576 |
+
# needs it.
|
| 577 |
+
self._built_objects = objects[:]
|
| 578 |
+
|
| 579 |
+
# Now link the object files together into a "shared object" --
|
| 580 |
+
# of course, first we have to figure out all the other things
|
| 581 |
+
# that go into the mix.
|
| 582 |
+
if ext.extra_objects:
|
| 583 |
+
objects.extend(ext.extra_objects)
|
| 584 |
+
extra_args = ext.extra_link_args or []
|
| 585 |
+
|
| 586 |
+
# Detect target language, if not provided
|
| 587 |
+
language = ext.language or self.compiler.detect_language(sources)
|
| 588 |
+
|
| 589 |
+
self.compiler.link_shared_object(
|
| 590 |
+
objects,
|
| 591 |
+
ext_path,
|
| 592 |
+
libraries=self.get_libraries(ext),
|
| 593 |
+
library_dirs=ext.library_dirs,
|
| 594 |
+
runtime_library_dirs=ext.runtime_library_dirs,
|
| 595 |
+
extra_postargs=extra_args,
|
| 596 |
+
export_symbols=self.get_export_symbols(ext),
|
| 597 |
+
debug=self.debug,
|
| 598 |
+
build_temp=self.build_temp,
|
| 599 |
+
target_lang=language,
|
| 600 |
+
)
|
| 601 |
+
|
| 602 |
+
def swig_sources(self, sources, extension):
|
| 603 |
+
"""Walk the list of source files in 'sources', looking for SWIG
|
| 604 |
+
interface (.i) files. Run SWIG on all that are found, and
|
| 605 |
+
return a modified 'sources' list with SWIG source files replaced
|
| 606 |
+
by the generated C (or C++) files.
|
| 607 |
+
"""
|
| 608 |
+
new_sources = []
|
| 609 |
+
swig_sources = []
|
| 610 |
+
swig_targets = {}
|
| 611 |
+
|
| 612 |
+
# XXX this drops generated C/C++ files into the source tree, which
|
| 613 |
+
# is fine for developers who want to distribute the generated
|
| 614 |
+
# source -- but there should be an option to put SWIG output in
|
| 615 |
+
# the temp dir.
|
| 616 |
+
|
| 617 |
+
if self.swig_cpp:
|
| 618 |
+
log.warning("--swig-cpp is deprecated - use --swig-opts=-c++")
|
| 619 |
+
|
| 620 |
+
if (
|
| 621 |
+
self.swig_cpp
|
| 622 |
+
or ('-c++' in self.swig_opts)
|
| 623 |
+
or ('-c++' in extension.swig_opts)
|
| 624 |
+
):
|
| 625 |
+
target_ext = '.cpp'
|
| 626 |
+
else:
|
| 627 |
+
target_ext = '.c'
|
| 628 |
+
|
| 629 |
+
for source in sources:
|
| 630 |
+
(base, ext) = os.path.splitext(source)
|
| 631 |
+
if ext == ".i": # SWIG interface file
|
| 632 |
+
new_sources.append(base + '_wrap' + target_ext)
|
| 633 |
+
swig_sources.append(source)
|
| 634 |
+
swig_targets[source] = new_sources[-1]
|
| 635 |
+
else:
|
| 636 |
+
new_sources.append(source)
|
| 637 |
+
|
| 638 |
+
if not swig_sources:
|
| 639 |
+
return new_sources
|
| 640 |
+
|
| 641 |
+
swig = self.swig or self.find_swig()
|
| 642 |
+
swig_cmd = [swig, "-python"]
|
| 643 |
+
swig_cmd.extend(self.swig_opts)
|
| 644 |
+
if self.swig_cpp:
|
| 645 |
+
swig_cmd.append("-c++")
|
| 646 |
+
|
| 647 |
+
# Do not override commandline arguments
|
| 648 |
+
if not self.swig_opts:
|
| 649 |
+
swig_cmd.extend(extension.swig_opts)
|
| 650 |
+
|
| 651 |
+
for source in swig_sources:
|
| 652 |
+
target = swig_targets[source]
|
| 653 |
+
log.info("swigging %s to %s", source, target)
|
| 654 |
+
self.spawn(swig_cmd + ["-o", target, source])
|
| 655 |
+
|
| 656 |
+
return new_sources
|
| 657 |
+
|
| 658 |
+
def find_swig(self):
|
| 659 |
+
"""Return the name of the SWIG executable. On Unix, this is
|
| 660 |
+
just "swig" -- it should be in the PATH. Tries a bit harder on
|
| 661 |
+
Windows.
|
| 662 |
+
"""
|
| 663 |
+
if os.name == "posix":
|
| 664 |
+
return "swig"
|
| 665 |
+
elif os.name == "nt":
|
| 666 |
+
# Look for SWIG in its standard installation directory on
|
| 667 |
+
# Windows (or so I presume!). If we find it there, great;
|
| 668 |
+
# if not, act like Unix and assume it's in the PATH.
|
| 669 |
+
for vers in ("1.3", "1.2", "1.1"):
|
| 670 |
+
fn = os.path.join(f"c:\\swig{vers}", "swig.exe")
|
| 671 |
+
if os.path.isfile(fn):
|
| 672 |
+
return fn
|
| 673 |
+
else:
|
| 674 |
+
return "swig.exe"
|
| 675 |
+
else:
|
| 676 |
+
raise DistutilsPlatformError(
|
| 677 |
+
f"I don't know how to find (much less run) SWIG on platform '{os.name}'"
|
| 678 |
+
)
|
| 679 |
+
|
| 680 |
+
# -- Name generators -----------------------------------------------
|
| 681 |
+
# (extension names, filenames, whatever)
|
| 682 |
+
def get_ext_fullpath(self, ext_name: str) -> str:
|
| 683 |
+
"""Returns the path of the filename for a given extension.
|
| 684 |
+
|
| 685 |
+
The file is located in `build_lib` or directly in the package
|
| 686 |
+
(inplace option).
|
| 687 |
+
"""
|
| 688 |
+
fullname = self.get_ext_fullname(ext_name)
|
| 689 |
+
modpath = fullname.split('.')
|
| 690 |
+
filename = self.get_ext_filename(modpath[-1])
|
| 691 |
+
|
| 692 |
+
if not self.inplace:
|
| 693 |
+
# no further work needed
|
| 694 |
+
# returning :
|
| 695 |
+
# build_dir/package/path/filename
|
| 696 |
+
filename = os.path.join(*modpath[:-1] + [filename])
|
| 697 |
+
return os.path.join(self.build_lib, filename)
|
| 698 |
+
|
| 699 |
+
# the inplace option requires to find the package directory
|
| 700 |
+
# using the build_py command for that
|
| 701 |
+
package = '.'.join(modpath[0:-1])
|
| 702 |
+
build_py = self.get_finalized_command('build_py')
|
| 703 |
+
package_dir = os.path.abspath(build_py.get_package_dir(package))
|
| 704 |
+
|
| 705 |
+
# returning
|
| 706 |
+
# package_dir/filename
|
| 707 |
+
return os.path.join(package_dir, filename)
|
| 708 |
+
|
| 709 |
+
def get_ext_fullname(self, ext_name: str) -> str:
|
| 710 |
+
"""Returns the fullname of a given extension name.
|
| 711 |
+
|
| 712 |
+
Adds the `package.` prefix"""
|
| 713 |
+
if self.package is None:
|
| 714 |
+
return ext_name
|
| 715 |
+
else:
|
| 716 |
+
return self.package + '.' + ext_name
|
| 717 |
+
|
| 718 |
+
def get_ext_filename(self, ext_name: str) -> str:
|
| 719 |
+
r"""Convert the name of an extension (eg. "foo.bar") into the name
|
| 720 |
+
of the file from which it will be loaded (eg. "foo/bar.so", or
|
| 721 |
+
"foo\bar.pyd").
|
| 722 |
+
"""
|
| 723 |
+
from ..sysconfig import get_config_var
|
| 724 |
+
|
| 725 |
+
ext_path = ext_name.split('.')
|
| 726 |
+
ext_suffix = get_config_var('EXT_SUFFIX')
|
| 727 |
+
return os.path.join(*ext_path) + ext_suffix
|
| 728 |
+
|
| 729 |
+
def get_export_symbols(self, ext: Extension) -> list[str]:
|
| 730 |
+
"""Return the list of symbols that a shared extension has to
|
| 731 |
+
export. This either uses 'ext.export_symbols' or, if it's not
|
| 732 |
+
provided, "PyInit_" + module_name. Only relevant on Windows, where
|
| 733 |
+
the .pyd file (DLL) must export the module "PyInit_" function.
|
| 734 |
+
"""
|
| 735 |
+
name = self._get_module_name_for_symbol(ext)
|
| 736 |
+
try:
|
| 737 |
+
# Unicode module name support as defined in PEP-489
|
| 738 |
+
# https://peps.python.org/pep-0489/#export-hook-name
|
| 739 |
+
name.encode('ascii')
|
| 740 |
+
except UnicodeEncodeError:
|
| 741 |
+
suffix = 'U_' + name.encode('punycode').replace(b'-', b'_').decode('ascii')
|
| 742 |
+
else:
|
| 743 |
+
suffix = "_" + name
|
| 744 |
+
|
| 745 |
+
initfunc_name = "PyInit" + suffix
|
| 746 |
+
if initfunc_name not in ext.export_symbols:
|
| 747 |
+
ext.export_symbols.append(initfunc_name)
|
| 748 |
+
return ext.export_symbols
|
| 749 |
+
|
| 750 |
+
def _get_module_name_for_symbol(self, ext):
|
| 751 |
+
# Package name should be used for `__init__` modules
|
| 752 |
+
# https://github.com/python/cpython/issues/80074
|
| 753 |
+
# https://github.com/pypa/setuptools/issues/4826
|
| 754 |
+
parts = ext.name.split(".")
|
| 755 |
+
if parts[-1] == "__init__" and len(parts) >= 2:
|
| 756 |
+
return parts[-2]
|
| 757 |
+
return parts[-1]
|
| 758 |
+
|
| 759 |
+
def get_libraries(self, ext: Extension) -> list[str]: # noqa: C901
|
| 760 |
+
"""Return the list of libraries to link against when building a
|
| 761 |
+
shared extension. On most platforms, this is just 'ext.libraries';
|
| 762 |
+
on Windows, we add the Python library (eg. python20.dll).
|
| 763 |
+
"""
|
| 764 |
+
# The python library is always needed on Windows. For MSVC, this
|
| 765 |
+
# is redundant, since the library is mentioned in a pragma in
|
| 766 |
+
# pyconfig.h that MSVC groks. The other Windows compilers all seem
|
| 767 |
+
# to need it mentioned explicitly, though, so that's what we do.
|
| 768 |
+
# Append '_d' to the python import library on debug builds.
|
| 769 |
+
if sys.platform == "win32" and not is_mingw():
|
| 770 |
+
from .._msvccompiler import MSVCCompiler
|
| 771 |
+
|
| 772 |
+
if not isinstance(self.compiler, MSVCCompiler):
|
| 773 |
+
template = "python%d%d"
|
| 774 |
+
if self.debug:
|
| 775 |
+
template = template + '_d'
|
| 776 |
+
pythonlib = template % (
|
| 777 |
+
sys.hexversion >> 24,
|
| 778 |
+
(sys.hexversion >> 16) & 0xFF,
|
| 779 |
+
)
|
| 780 |
+
# don't extend ext.libraries, it may be shared with other
|
| 781 |
+
# extensions, it is a reference to the original list
|
| 782 |
+
return ext.libraries + [pythonlib]
|
| 783 |
+
else:
|
| 784 |
+
# On Android only the main executable and LD_PRELOADs are considered
|
| 785 |
+
# to be RTLD_GLOBAL, all the dependencies of the main executable
|
| 786 |
+
# remain RTLD_LOCAL and so the shared libraries must be linked with
|
| 787 |
+
# libpython when python is built with a shared python library (issue
|
| 788 |
+
# bpo-21536).
|
| 789 |
+
# On Cygwin (and if required, other POSIX-like platforms based on
|
| 790 |
+
# Windows like MinGW) it is simply necessary that all symbols in
|
| 791 |
+
# shared libraries are resolved at link time.
|
| 792 |
+
from ..sysconfig import get_config_var
|
| 793 |
+
|
| 794 |
+
link_libpython = False
|
| 795 |
+
if get_config_var('Py_ENABLE_SHARED'):
|
| 796 |
+
# A native build on an Android device or on Cygwin
|
| 797 |
+
if hasattr(sys, 'getandroidapilevel'):
|
| 798 |
+
link_libpython = True
|
| 799 |
+
elif sys.platform == 'cygwin' or is_mingw():
|
| 800 |
+
link_libpython = True
|
| 801 |
+
elif '_PYTHON_HOST_PLATFORM' in os.environ:
|
| 802 |
+
# We are cross-compiling for one of the relevant platforms
|
| 803 |
+
if get_config_var('ANDROID_API_LEVEL') != 0:
|
| 804 |
+
link_libpython = True
|
| 805 |
+
elif get_config_var('MACHDEP') == 'cygwin':
|
| 806 |
+
link_libpython = True
|
| 807 |
+
|
| 808 |
+
if link_libpython:
|
| 809 |
+
ldversion = get_config_var('LDVERSION')
|
| 810 |
+
return ext.libraries + ['python' + ldversion]
|
| 811 |
+
|
| 812 |
+
return ext.libraries
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_py.py
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.build_py
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'build_py' command."""
|
| 4 |
+
|
| 5 |
+
import glob
|
| 6 |
+
import importlib.util
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
from distutils._log import log
|
| 10 |
+
from typing import ClassVar
|
| 11 |
+
|
| 12 |
+
from ..core import Command
|
| 13 |
+
from ..errors import DistutilsFileError, DistutilsOptionError
|
| 14 |
+
from ..util import convert_path
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class build_py(Command):
|
| 18 |
+
description = "\"build\" pure Python modules (copy to build directory)"
|
| 19 |
+
|
| 20 |
+
user_options = [
|
| 21 |
+
('build-lib=', 'd', "directory to \"build\" (copy) to"),
|
| 22 |
+
('compile', 'c', "compile .py to .pyc"),
|
| 23 |
+
('no-compile', None, "don't compile .py files [default]"),
|
| 24 |
+
(
|
| 25 |
+
'optimize=',
|
| 26 |
+
'O',
|
| 27 |
+
"also compile with optimization: -O1 for \"python -O\", "
|
| 28 |
+
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]",
|
| 29 |
+
),
|
| 30 |
+
('force', 'f', "forcibly build everything (ignore file timestamps)"),
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
boolean_options: ClassVar[list[str]] = ['compile', 'force']
|
| 34 |
+
negative_opt: ClassVar[dict[str, str]] = {'no-compile': 'compile'}
|
| 35 |
+
|
| 36 |
+
def initialize_options(self):
|
| 37 |
+
self.build_lib = None
|
| 38 |
+
self.py_modules = None
|
| 39 |
+
self.package = None
|
| 40 |
+
self.package_data = None
|
| 41 |
+
self.package_dir = None
|
| 42 |
+
self.compile = False
|
| 43 |
+
self.optimize = 0
|
| 44 |
+
self.force = None
|
| 45 |
+
|
| 46 |
+
def finalize_options(self) -> None:
|
| 47 |
+
self.set_undefined_options(
|
| 48 |
+
'build', ('build_lib', 'build_lib'), ('force', 'force')
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
# Get the distribution options that are aliases for build_py
|
| 52 |
+
# options -- list of packages and list of modules.
|
| 53 |
+
self.packages = self.distribution.packages
|
| 54 |
+
self.py_modules = self.distribution.py_modules
|
| 55 |
+
self.package_data = self.distribution.package_data
|
| 56 |
+
self.package_dir = {}
|
| 57 |
+
if self.distribution.package_dir:
|
| 58 |
+
for name, path in self.distribution.package_dir.items():
|
| 59 |
+
self.package_dir[name] = convert_path(path)
|
| 60 |
+
self.data_files = self.get_data_files()
|
| 61 |
+
|
| 62 |
+
# Ick, copied straight from install_lib.py (fancy_getopt needs a
|
| 63 |
+
# type system! Hell, *everything* needs a type system!!!)
|
| 64 |
+
if not isinstance(self.optimize, int):
|
| 65 |
+
try:
|
| 66 |
+
self.optimize = int(self.optimize)
|
| 67 |
+
assert 0 <= self.optimize <= 2
|
| 68 |
+
except (ValueError, AssertionError):
|
| 69 |
+
raise DistutilsOptionError("optimize must be 0, 1, or 2")
|
| 70 |
+
|
| 71 |
+
def run(self) -> None:
|
| 72 |
+
# XXX copy_file by default preserves atime and mtime. IMHO this is
|
| 73 |
+
# the right thing to do, but perhaps it should be an option -- in
|
| 74 |
+
# particular, a site administrator might want installed files to
|
| 75 |
+
# reflect the time of installation rather than the last
|
| 76 |
+
# modification time before the installed release.
|
| 77 |
+
|
| 78 |
+
# XXX copy_file by default preserves mode, which appears to be the
|
| 79 |
+
# wrong thing to do: if a file is read-only in the working
|
| 80 |
+
# directory, we want it to be installed read/write so that the next
|
| 81 |
+
# installation of the same module distribution can overwrite it
|
| 82 |
+
# without problems. (This might be a Unix-specific issue.) Thus
|
| 83 |
+
# we turn off 'preserve_mode' when copying to the build directory,
|
| 84 |
+
# since the build directory is supposed to be exactly what the
|
| 85 |
+
# installation will look like (ie. we preserve mode when
|
| 86 |
+
# installing).
|
| 87 |
+
|
| 88 |
+
# Two options control which modules will be installed: 'packages'
|
| 89 |
+
# and 'py_modules'. The former lets us work with whole packages, not
|
| 90 |
+
# specifying individual modules at all; the latter is for
|
| 91 |
+
# specifying modules one-at-a-time.
|
| 92 |
+
|
| 93 |
+
if self.py_modules:
|
| 94 |
+
self.build_modules()
|
| 95 |
+
if self.packages:
|
| 96 |
+
self.build_packages()
|
| 97 |
+
self.build_package_data()
|
| 98 |
+
|
| 99 |
+
self.byte_compile(self.get_outputs(include_bytecode=False))
|
| 100 |
+
|
| 101 |
+
def get_data_files(self):
|
| 102 |
+
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
|
| 103 |
+
data = []
|
| 104 |
+
if not self.packages:
|
| 105 |
+
return data
|
| 106 |
+
for package in self.packages:
|
| 107 |
+
# Locate package source directory
|
| 108 |
+
src_dir = self.get_package_dir(package)
|
| 109 |
+
|
| 110 |
+
# Compute package build directory
|
| 111 |
+
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
|
| 112 |
+
|
| 113 |
+
# Length of path to strip from found files
|
| 114 |
+
plen = 0
|
| 115 |
+
if src_dir:
|
| 116 |
+
plen = len(src_dir) + 1
|
| 117 |
+
|
| 118 |
+
# Strip directory from globbed filenames
|
| 119 |
+
filenames = [file[plen:] for file in self.find_data_files(package, src_dir)]
|
| 120 |
+
data.append((package, src_dir, build_dir, filenames))
|
| 121 |
+
return data
|
| 122 |
+
|
| 123 |
+
def find_data_files(self, package, src_dir):
|
| 124 |
+
"""Return filenames for package's data files in 'src_dir'"""
|
| 125 |
+
globs = self.package_data.get('', []) + self.package_data.get(package, [])
|
| 126 |
+
files = []
|
| 127 |
+
for pattern in globs:
|
| 128 |
+
# Each pattern has to be converted to a platform-specific path
|
| 129 |
+
filelist = glob.glob(
|
| 130 |
+
os.path.join(glob.escape(src_dir), convert_path(pattern))
|
| 131 |
+
)
|
| 132 |
+
# Files that match more than one pattern are only added once
|
| 133 |
+
files.extend([
|
| 134 |
+
fn for fn in filelist if fn not in files and os.path.isfile(fn)
|
| 135 |
+
])
|
| 136 |
+
return files
|
| 137 |
+
|
| 138 |
+
def build_package_data(self) -> None:
|
| 139 |
+
"""Copy data files into build directory"""
|
| 140 |
+
for _package, src_dir, build_dir, filenames in self.data_files:
|
| 141 |
+
for filename in filenames:
|
| 142 |
+
target = os.path.join(build_dir, filename)
|
| 143 |
+
self.mkpath(os.path.dirname(target))
|
| 144 |
+
self.copy_file(
|
| 145 |
+
os.path.join(src_dir, filename), target, preserve_mode=False
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
def get_package_dir(self, package):
|
| 149 |
+
"""Return the directory, relative to the top of the source
|
| 150 |
+
distribution, where package 'package' should be found
|
| 151 |
+
(at least according to the 'package_dir' option, if any)."""
|
| 152 |
+
path = package.split('.')
|
| 153 |
+
|
| 154 |
+
if not self.package_dir:
|
| 155 |
+
if path:
|
| 156 |
+
return os.path.join(*path)
|
| 157 |
+
else:
|
| 158 |
+
return ''
|
| 159 |
+
else:
|
| 160 |
+
tail = []
|
| 161 |
+
while path:
|
| 162 |
+
try:
|
| 163 |
+
pdir = self.package_dir['.'.join(path)]
|
| 164 |
+
except KeyError:
|
| 165 |
+
tail.insert(0, path[-1])
|
| 166 |
+
del path[-1]
|
| 167 |
+
else:
|
| 168 |
+
tail.insert(0, pdir)
|
| 169 |
+
return os.path.join(*tail)
|
| 170 |
+
else:
|
| 171 |
+
# Oops, got all the way through 'path' without finding a
|
| 172 |
+
# match in package_dir. If package_dir defines a directory
|
| 173 |
+
# for the root (nameless) package, then fallback on it;
|
| 174 |
+
# otherwise, we might as well have not consulted
|
| 175 |
+
# package_dir at all, as we just use the directory implied
|
| 176 |
+
# by 'tail' (which should be the same as the original value
|
| 177 |
+
# of 'path' at this point).
|
| 178 |
+
pdir = self.package_dir.get('')
|
| 179 |
+
if pdir is not None:
|
| 180 |
+
tail.insert(0, pdir)
|
| 181 |
+
|
| 182 |
+
if tail:
|
| 183 |
+
return os.path.join(*tail)
|
| 184 |
+
else:
|
| 185 |
+
return ''
|
| 186 |
+
|
| 187 |
+
def check_package(self, package, package_dir):
|
| 188 |
+
# Empty dir name means current directory, which we can probably
|
| 189 |
+
# assume exists. Also, os.path.exists and isdir don't know about
|
| 190 |
+
# my "empty string means current dir" convention, so we have to
|
| 191 |
+
# circumvent them.
|
| 192 |
+
if package_dir != "":
|
| 193 |
+
if not os.path.exists(package_dir):
|
| 194 |
+
raise DistutilsFileError(
|
| 195 |
+
f"package directory '{package_dir}' does not exist"
|
| 196 |
+
)
|
| 197 |
+
if not os.path.isdir(package_dir):
|
| 198 |
+
raise DistutilsFileError(
|
| 199 |
+
f"supposed package directory '{package_dir}' exists, "
|
| 200 |
+
"but is not a directory"
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
# Directories without __init__.py are namespace packages (PEP 420).
|
| 204 |
+
if package:
|
| 205 |
+
init_py = os.path.join(package_dir, "__init__.py")
|
| 206 |
+
if os.path.isfile(init_py):
|
| 207 |
+
return init_py
|
| 208 |
+
|
| 209 |
+
# Either not in a package at all (__init__.py not expected), or
|
| 210 |
+
# __init__.py doesn't exist -- so don't return the filename.
|
| 211 |
+
return None
|
| 212 |
+
|
| 213 |
+
def check_module(self, module, module_file):
|
| 214 |
+
if not os.path.isfile(module_file):
|
| 215 |
+
log.warning("file %s (for module %s) not found", module_file, module)
|
| 216 |
+
return False
|
| 217 |
+
else:
|
| 218 |
+
return True
|
| 219 |
+
|
| 220 |
+
def find_package_modules(self, package, package_dir):
|
| 221 |
+
self.check_package(package, package_dir)
|
| 222 |
+
module_files = glob.glob(os.path.join(glob.escape(package_dir), "*.py"))
|
| 223 |
+
modules = []
|
| 224 |
+
setup_script = os.path.abspath(self.distribution.script_name)
|
| 225 |
+
|
| 226 |
+
for f in module_files:
|
| 227 |
+
abs_f = os.path.abspath(f)
|
| 228 |
+
if abs_f != setup_script:
|
| 229 |
+
module = os.path.splitext(os.path.basename(f))[0]
|
| 230 |
+
modules.append((package, module, f))
|
| 231 |
+
else:
|
| 232 |
+
self.debug_print(f"excluding {setup_script}")
|
| 233 |
+
return modules
|
| 234 |
+
|
| 235 |
+
def find_modules(self):
|
| 236 |
+
"""Finds individually-specified Python modules, ie. those listed by
|
| 237 |
+
module name in 'self.py_modules'. Returns a list of tuples (package,
|
| 238 |
+
module_base, filename): 'package' is a tuple of the path through
|
| 239 |
+
package-space to the module; 'module_base' is the bare (no
|
| 240 |
+
packages, no dots) module name, and 'filename' is the path to the
|
| 241 |
+
".py" file (relative to the distribution root) that implements the
|
| 242 |
+
module.
|
| 243 |
+
"""
|
| 244 |
+
# Map package names to tuples of useful info about the package:
|
| 245 |
+
# (package_dir, checked)
|
| 246 |
+
# package_dir - the directory where we'll find source files for
|
| 247 |
+
# this package
|
| 248 |
+
# checked - true if we have checked that the package directory
|
| 249 |
+
# is valid (exists, contains __init__.py, ... ?)
|
| 250 |
+
packages = {}
|
| 251 |
+
|
| 252 |
+
# List of (package, module, filename) tuples to return
|
| 253 |
+
modules = []
|
| 254 |
+
|
| 255 |
+
# We treat modules-in-packages almost the same as toplevel modules,
|
| 256 |
+
# just the "package" for a toplevel is empty (either an empty
|
| 257 |
+
# string or empty list, depending on context). Differences:
|
| 258 |
+
# - don't check for __init__.py in directory for empty package
|
| 259 |
+
for module in self.py_modules:
|
| 260 |
+
path = module.split('.')
|
| 261 |
+
package = '.'.join(path[0:-1])
|
| 262 |
+
module_base = path[-1]
|
| 263 |
+
|
| 264 |
+
try:
|
| 265 |
+
(package_dir, checked) = packages[package]
|
| 266 |
+
except KeyError:
|
| 267 |
+
package_dir = self.get_package_dir(package)
|
| 268 |
+
checked = False
|
| 269 |
+
|
| 270 |
+
if not checked:
|
| 271 |
+
init_py = self.check_package(package, package_dir)
|
| 272 |
+
packages[package] = (package_dir, 1)
|
| 273 |
+
if init_py:
|
| 274 |
+
modules.append((package, "__init__", init_py))
|
| 275 |
+
|
| 276 |
+
# XXX perhaps we should also check for just .pyc files
|
| 277 |
+
# (so greedy closed-source bastards can distribute Python
|
| 278 |
+
# modules too)
|
| 279 |
+
module_file = os.path.join(package_dir, module_base + ".py")
|
| 280 |
+
if not self.check_module(module, module_file):
|
| 281 |
+
continue
|
| 282 |
+
|
| 283 |
+
modules.append((package, module_base, module_file))
|
| 284 |
+
|
| 285 |
+
return modules
|
| 286 |
+
|
| 287 |
+
def find_all_modules(self):
|
| 288 |
+
"""Compute the list of all modules that will be built, whether
|
| 289 |
+
they are specified one-module-at-a-time ('self.py_modules') or
|
| 290 |
+
by whole packages ('self.packages'). Return a list of tuples
|
| 291 |
+
(package, module, module_file), just like 'find_modules()' and
|
| 292 |
+
'find_package_modules()' do."""
|
| 293 |
+
modules = []
|
| 294 |
+
if self.py_modules:
|
| 295 |
+
modules.extend(self.find_modules())
|
| 296 |
+
if self.packages:
|
| 297 |
+
for package in self.packages:
|
| 298 |
+
package_dir = self.get_package_dir(package)
|
| 299 |
+
m = self.find_package_modules(package, package_dir)
|
| 300 |
+
modules.extend(m)
|
| 301 |
+
return modules
|
| 302 |
+
|
| 303 |
+
def get_source_files(self):
|
| 304 |
+
return [module[-1] for module in self.find_all_modules()]
|
| 305 |
+
|
| 306 |
+
def get_module_outfile(self, build_dir, package, module):
|
| 307 |
+
outfile_path = [build_dir] + list(package) + [module + ".py"]
|
| 308 |
+
return os.path.join(*outfile_path)
|
| 309 |
+
|
| 310 |
+
def get_outputs(self, include_bytecode: bool = True) -> list[str]:
|
| 311 |
+
modules = self.find_all_modules()
|
| 312 |
+
outputs = []
|
| 313 |
+
for package, module, _module_file in modules:
|
| 314 |
+
package = package.split('.')
|
| 315 |
+
filename = self.get_module_outfile(self.build_lib, package, module)
|
| 316 |
+
outputs.append(filename)
|
| 317 |
+
if include_bytecode:
|
| 318 |
+
if self.compile:
|
| 319 |
+
outputs.append(
|
| 320 |
+
importlib.util.cache_from_source(filename, optimization='')
|
| 321 |
+
)
|
| 322 |
+
if self.optimize > 0:
|
| 323 |
+
outputs.append(
|
| 324 |
+
importlib.util.cache_from_source(
|
| 325 |
+
filename, optimization=self.optimize
|
| 326 |
+
)
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
outputs += [
|
| 330 |
+
os.path.join(build_dir, filename)
|
| 331 |
+
for package, src_dir, build_dir, filenames in self.data_files
|
| 332 |
+
for filename in filenames
|
| 333 |
+
]
|
| 334 |
+
|
| 335 |
+
return outputs
|
| 336 |
+
|
| 337 |
+
def build_module(self, module, module_file, package):
|
| 338 |
+
if isinstance(package, str):
|
| 339 |
+
package = package.split('.')
|
| 340 |
+
elif not isinstance(package, (list, tuple)):
|
| 341 |
+
raise TypeError(
|
| 342 |
+
"'package' must be a string (dot-separated), list, or tuple"
|
| 343 |
+
)
|
| 344 |
+
|
| 345 |
+
# Now put the module source file into the "build" area -- this is
|
| 346 |
+
# easy, we just copy it somewhere under self.build_lib (the build
|
| 347 |
+
# directory for Python source).
|
| 348 |
+
outfile = self.get_module_outfile(self.build_lib, package, module)
|
| 349 |
+
dir = os.path.dirname(outfile)
|
| 350 |
+
self.mkpath(dir)
|
| 351 |
+
return self.copy_file(module_file, outfile, preserve_mode=False)
|
| 352 |
+
|
| 353 |
+
def build_modules(self) -> None:
|
| 354 |
+
modules = self.find_modules()
|
| 355 |
+
for package, module, module_file in modules:
|
| 356 |
+
# Now "build" the module -- ie. copy the source file to
|
| 357 |
+
# self.build_lib (the build directory for Python source).
|
| 358 |
+
# (Actually, it gets copied to the directory for this package
|
| 359 |
+
# under self.build_lib.)
|
| 360 |
+
self.build_module(module, module_file, package)
|
| 361 |
+
|
| 362 |
+
def build_packages(self) -> None:
|
| 363 |
+
for package in self.packages:
|
| 364 |
+
# Get list of (package, module, module_file) tuples based on
|
| 365 |
+
# scanning the package directory. 'package' is only included
|
| 366 |
+
# in the tuple so that 'find_modules()' and
|
| 367 |
+
# 'find_package_tuples()' have a consistent interface; it's
|
| 368 |
+
# ignored here (apart from a sanity check). Also, 'module' is
|
| 369 |
+
# the *unqualified* module name (ie. no dots, no package -- we
|
| 370 |
+
# already know its package!), and 'module_file' is the path to
|
| 371 |
+
# the .py file, relative to the current directory
|
| 372 |
+
# (ie. including 'package_dir').
|
| 373 |
+
package_dir = self.get_package_dir(package)
|
| 374 |
+
modules = self.find_package_modules(package, package_dir)
|
| 375 |
+
|
| 376 |
+
# Now loop over the modules we found, "building" each one (just
|
| 377 |
+
# copy it to self.build_lib).
|
| 378 |
+
for package_, module, module_file in modules:
|
| 379 |
+
assert package == package_
|
| 380 |
+
self.build_module(module, module_file, package)
|
| 381 |
+
|
| 382 |
+
def byte_compile(self, files) -> None:
|
| 383 |
+
if sys.dont_write_bytecode:
|
| 384 |
+
self.warn('byte-compiling is disabled, skipping.')
|
| 385 |
+
return
|
| 386 |
+
|
| 387 |
+
from ..util import byte_compile
|
| 388 |
+
|
| 389 |
+
prefix = self.build_lib
|
| 390 |
+
if prefix[-1] != os.sep:
|
| 391 |
+
prefix = prefix + os.sep
|
| 392 |
+
|
| 393 |
+
# XXX this code is essentially the same as the 'byte_compile()
|
| 394 |
+
# method of the "install_lib" command, except for the determination
|
| 395 |
+
# of the 'prefix' string. Hmmm.
|
| 396 |
+
if self.compile:
|
| 397 |
+
byte_compile(
|
| 398 |
+
files, optimize=0, force=self.force, prefix=prefix, dry_run=self.dry_run
|
| 399 |
+
)
|
| 400 |
+
if self.optimize > 0:
|
| 401 |
+
byte_compile(
|
| 402 |
+
files,
|
| 403 |
+
optimize=self.optimize,
|
| 404 |
+
force=self.force,
|
| 405 |
+
prefix=prefix,
|
| 406 |
+
dry_run=self.dry_run,
|
| 407 |
+
)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/build_scripts.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.build_scripts
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'build_scripts' command."""
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
import tokenize
|
| 8 |
+
from distutils._log import log
|
| 9 |
+
from stat import ST_MODE
|
| 10 |
+
from typing import ClassVar
|
| 11 |
+
|
| 12 |
+
from .._modified import newer
|
| 13 |
+
from ..core import Command
|
| 14 |
+
from ..util import convert_path
|
| 15 |
+
|
| 16 |
+
shebang_pattern = re.compile('^#!.*python[0-9.]*([ \t].*)?$')
|
| 17 |
+
"""
|
| 18 |
+
Pattern matching a Python interpreter indicated in first line of a script.
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
# for Setuptools compatibility
|
| 22 |
+
first_line_re = shebang_pattern
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class build_scripts(Command):
|
| 26 |
+
description = "\"build\" scripts (copy and fixup #! line)"
|
| 27 |
+
|
| 28 |
+
user_options: ClassVar[list[tuple[str, str, str]]] = [
|
| 29 |
+
('build-dir=', 'd', "directory to \"build\" (copy) to"),
|
| 30 |
+
('force', 'f', "forcibly build everything (ignore file timestamps"),
|
| 31 |
+
('executable=', 'e', "specify final destination interpreter path"),
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
boolean_options: ClassVar[list[str]] = ['force']
|
| 35 |
+
|
| 36 |
+
def initialize_options(self):
|
| 37 |
+
self.build_dir = None
|
| 38 |
+
self.scripts = None
|
| 39 |
+
self.force = None
|
| 40 |
+
self.executable = None
|
| 41 |
+
|
| 42 |
+
def finalize_options(self):
|
| 43 |
+
self.set_undefined_options(
|
| 44 |
+
'build',
|
| 45 |
+
('build_scripts', 'build_dir'),
|
| 46 |
+
('force', 'force'),
|
| 47 |
+
('executable', 'executable'),
|
| 48 |
+
)
|
| 49 |
+
self.scripts = self.distribution.scripts
|
| 50 |
+
|
| 51 |
+
def get_source_files(self):
|
| 52 |
+
return self.scripts
|
| 53 |
+
|
| 54 |
+
def run(self):
|
| 55 |
+
if not self.scripts:
|
| 56 |
+
return
|
| 57 |
+
self.copy_scripts()
|
| 58 |
+
|
| 59 |
+
def copy_scripts(self):
|
| 60 |
+
"""
|
| 61 |
+
Copy each script listed in ``self.scripts``.
|
| 62 |
+
|
| 63 |
+
If a script is marked as a Python script (first line matches
|
| 64 |
+
'shebang_pattern', i.e. starts with ``#!`` and contains
|
| 65 |
+
"python"), then adjust in the copy the first line to refer to
|
| 66 |
+
the current Python interpreter.
|
| 67 |
+
"""
|
| 68 |
+
self.mkpath(self.build_dir)
|
| 69 |
+
outfiles = []
|
| 70 |
+
updated_files = []
|
| 71 |
+
for script in self.scripts:
|
| 72 |
+
self._copy_script(script, outfiles, updated_files)
|
| 73 |
+
|
| 74 |
+
self._change_modes(outfiles)
|
| 75 |
+
|
| 76 |
+
return outfiles, updated_files
|
| 77 |
+
|
| 78 |
+
def _copy_script(self, script, outfiles, updated_files):
|
| 79 |
+
shebang_match = None
|
| 80 |
+
script = convert_path(script)
|
| 81 |
+
outfile = os.path.join(self.build_dir, os.path.basename(script))
|
| 82 |
+
outfiles.append(outfile)
|
| 83 |
+
|
| 84 |
+
if not self.force and not newer(script, outfile):
|
| 85 |
+
log.debug("not copying %s (up-to-date)", script)
|
| 86 |
+
return
|
| 87 |
+
|
| 88 |
+
# Always open the file, but ignore failures in dry-run mode
|
| 89 |
+
# in order to attempt to copy directly.
|
| 90 |
+
try:
|
| 91 |
+
f = tokenize.open(script)
|
| 92 |
+
except OSError:
|
| 93 |
+
if not self.dry_run:
|
| 94 |
+
raise
|
| 95 |
+
f = None
|
| 96 |
+
else:
|
| 97 |
+
first_line = f.readline()
|
| 98 |
+
if not first_line:
|
| 99 |
+
self.warn(f"{script} is an empty file (skipping)")
|
| 100 |
+
return
|
| 101 |
+
|
| 102 |
+
shebang_match = shebang_pattern.match(first_line)
|
| 103 |
+
|
| 104 |
+
updated_files.append(outfile)
|
| 105 |
+
if shebang_match:
|
| 106 |
+
log.info("copying and adjusting %s -> %s", script, self.build_dir)
|
| 107 |
+
if not self.dry_run:
|
| 108 |
+
post_interp = shebang_match.group(1) or ''
|
| 109 |
+
shebang = "#!" + self.executable + post_interp + "\n"
|
| 110 |
+
self._validate_shebang(shebang, f.encoding)
|
| 111 |
+
with open(outfile, "w", encoding=f.encoding) as outf:
|
| 112 |
+
outf.write(shebang)
|
| 113 |
+
outf.writelines(f.readlines())
|
| 114 |
+
if f:
|
| 115 |
+
f.close()
|
| 116 |
+
else:
|
| 117 |
+
if f:
|
| 118 |
+
f.close()
|
| 119 |
+
self.copy_file(script, outfile)
|
| 120 |
+
|
| 121 |
+
def _change_modes(self, outfiles):
|
| 122 |
+
if os.name != 'posix':
|
| 123 |
+
return
|
| 124 |
+
|
| 125 |
+
for file in outfiles:
|
| 126 |
+
self._change_mode(file)
|
| 127 |
+
|
| 128 |
+
def _change_mode(self, file):
|
| 129 |
+
if self.dry_run:
|
| 130 |
+
log.info("changing mode of %s", file)
|
| 131 |
+
return
|
| 132 |
+
|
| 133 |
+
oldmode = os.stat(file)[ST_MODE] & 0o7777
|
| 134 |
+
newmode = (oldmode | 0o555) & 0o7777
|
| 135 |
+
if newmode != oldmode:
|
| 136 |
+
log.info("changing mode of %s from %o to %o", file, oldmode, newmode)
|
| 137 |
+
os.chmod(file, newmode)
|
| 138 |
+
|
| 139 |
+
@staticmethod
|
| 140 |
+
def _validate_shebang(shebang, encoding):
|
| 141 |
+
# Python parser starts to read a script using UTF-8 until
|
| 142 |
+
# it gets a #coding:xxx cookie. The shebang has to be the
|
| 143 |
+
# first line of a file, the #coding:xxx cookie cannot be
|
| 144 |
+
# written before. So the shebang has to be encodable to
|
| 145 |
+
# UTF-8.
|
| 146 |
+
try:
|
| 147 |
+
shebang.encode('utf-8')
|
| 148 |
+
except UnicodeEncodeError:
|
| 149 |
+
raise ValueError(f"The shebang ({shebang!r}) is not encodable to utf-8")
|
| 150 |
+
|
| 151 |
+
# If the script is encoded to a custom encoding (use a
|
| 152 |
+
# #coding:xxx cookie), the shebang has to be encodable to
|
| 153 |
+
# the script encoding too.
|
| 154 |
+
try:
|
| 155 |
+
shebang.encode(encoding)
|
| 156 |
+
except UnicodeEncodeError:
|
| 157 |
+
raise ValueError(
|
| 158 |
+
f"The shebang ({shebang!r}) is not encodable "
|
| 159 |
+
f"to the script encoding ({encoding})"
|
| 160 |
+
)
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/check.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.check
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'check' command.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import contextlib
|
| 7 |
+
from typing import ClassVar
|
| 8 |
+
|
| 9 |
+
from ..core import Command
|
| 10 |
+
from ..errors import DistutilsSetupError
|
| 11 |
+
|
| 12 |
+
with contextlib.suppress(ImportError):
|
| 13 |
+
import docutils.frontend
|
| 14 |
+
import docutils.nodes
|
| 15 |
+
import docutils.parsers.rst
|
| 16 |
+
import docutils.utils
|
| 17 |
+
|
| 18 |
+
class SilentReporter(docutils.utils.Reporter):
|
| 19 |
+
def __init__(
|
| 20 |
+
self,
|
| 21 |
+
source,
|
| 22 |
+
report_level,
|
| 23 |
+
halt_level,
|
| 24 |
+
stream=None,
|
| 25 |
+
debug=False,
|
| 26 |
+
encoding='ascii',
|
| 27 |
+
error_handler='replace',
|
| 28 |
+
):
|
| 29 |
+
self.messages = []
|
| 30 |
+
super().__init__(
|
| 31 |
+
source, report_level, halt_level, stream, debug, encoding, error_handler
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def system_message(self, level, message, *children, **kwargs):
|
| 35 |
+
self.messages.append((level, message, children, kwargs))
|
| 36 |
+
return docutils.nodes.system_message(
|
| 37 |
+
message, *children, level=level, type=self.levels[level], **kwargs
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class check(Command):
|
| 42 |
+
"""This command checks the meta-data of the package."""
|
| 43 |
+
|
| 44 |
+
description = "perform some checks on the package"
|
| 45 |
+
user_options: ClassVar[list[tuple[str, str, str]]] = [
|
| 46 |
+
('metadata', 'm', 'Verify meta-data'),
|
| 47 |
+
(
|
| 48 |
+
'restructuredtext',
|
| 49 |
+
'r',
|
| 50 |
+
'Checks if long string meta-data syntax are reStructuredText-compliant',
|
| 51 |
+
),
|
| 52 |
+
('strict', 's', 'Will exit with an error if a check fails'),
|
| 53 |
+
]
|
| 54 |
+
|
| 55 |
+
boolean_options: ClassVar[list[str]] = ['metadata', 'restructuredtext', 'strict']
|
| 56 |
+
|
| 57 |
+
def initialize_options(self):
|
| 58 |
+
"""Sets default values for options."""
|
| 59 |
+
self.restructuredtext = False
|
| 60 |
+
self.metadata = 1
|
| 61 |
+
self.strict = False
|
| 62 |
+
self._warnings = 0
|
| 63 |
+
|
| 64 |
+
def finalize_options(self):
|
| 65 |
+
pass
|
| 66 |
+
|
| 67 |
+
def warn(self, msg):
|
| 68 |
+
"""Counts the number of warnings that occurs."""
|
| 69 |
+
self._warnings += 1
|
| 70 |
+
return Command.warn(self, msg)
|
| 71 |
+
|
| 72 |
+
def run(self):
|
| 73 |
+
"""Runs the command."""
|
| 74 |
+
# perform the various tests
|
| 75 |
+
if self.metadata:
|
| 76 |
+
self.check_metadata()
|
| 77 |
+
if self.restructuredtext:
|
| 78 |
+
if 'docutils' in globals():
|
| 79 |
+
try:
|
| 80 |
+
self.check_restructuredtext()
|
| 81 |
+
except TypeError as exc:
|
| 82 |
+
raise DistutilsSetupError(str(exc))
|
| 83 |
+
elif self.strict:
|
| 84 |
+
raise DistutilsSetupError('The docutils package is needed.')
|
| 85 |
+
|
| 86 |
+
# let's raise an error in strict mode, if we have at least
|
| 87 |
+
# one warning
|
| 88 |
+
if self.strict and self._warnings > 0:
|
| 89 |
+
raise DistutilsSetupError('Please correct your package.')
|
| 90 |
+
|
| 91 |
+
def check_metadata(self):
|
| 92 |
+
"""Ensures that all required elements of meta-data are supplied.
|
| 93 |
+
|
| 94 |
+
Required fields:
|
| 95 |
+
name, version
|
| 96 |
+
|
| 97 |
+
Warns if any are missing.
|
| 98 |
+
"""
|
| 99 |
+
metadata = self.distribution.metadata
|
| 100 |
+
|
| 101 |
+
missing = [
|
| 102 |
+
attr for attr in ('name', 'version') if not getattr(metadata, attr, None)
|
| 103 |
+
]
|
| 104 |
+
|
| 105 |
+
if missing:
|
| 106 |
+
self.warn("missing required meta-data: {}".format(', '.join(missing)))
|
| 107 |
+
|
| 108 |
+
def check_restructuredtext(self):
|
| 109 |
+
"""Checks if the long string fields are reST-compliant."""
|
| 110 |
+
data = self.distribution.get_long_description()
|
| 111 |
+
for warning in self._check_rst_data(data):
|
| 112 |
+
line = warning[-1].get('line')
|
| 113 |
+
if line is None:
|
| 114 |
+
warning = warning[1]
|
| 115 |
+
else:
|
| 116 |
+
warning = f'{warning[1]} (line {line})'
|
| 117 |
+
self.warn(warning)
|
| 118 |
+
|
| 119 |
+
def _check_rst_data(self, data):
|
| 120 |
+
"""Returns warnings when the provided data doesn't compile."""
|
| 121 |
+
# the include and csv_table directives need this to be a path
|
| 122 |
+
source_path = self.distribution.script_name or 'setup.py'
|
| 123 |
+
parser = docutils.parsers.rst.Parser()
|
| 124 |
+
settings = docutils.frontend.OptionParser(
|
| 125 |
+
components=(docutils.parsers.rst.Parser,)
|
| 126 |
+
).get_default_values()
|
| 127 |
+
settings.tab_width = 4
|
| 128 |
+
settings.pep_references = None
|
| 129 |
+
settings.rfc_references = None
|
| 130 |
+
reporter = SilentReporter(
|
| 131 |
+
source_path,
|
| 132 |
+
settings.report_level,
|
| 133 |
+
settings.halt_level,
|
| 134 |
+
stream=settings.warning_stream,
|
| 135 |
+
debug=settings.debug,
|
| 136 |
+
encoding=settings.error_encoding,
|
| 137 |
+
error_handler=settings.error_encoding_error_handler,
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
document = docutils.nodes.document(settings, reporter, source=source_path)
|
| 141 |
+
document.note_source(source_path, -1)
|
| 142 |
+
try:
|
| 143 |
+
parser.parse(data, document)
|
| 144 |
+
except (AttributeError, TypeError) as e:
|
| 145 |
+
reporter.messages.append((
|
| 146 |
+
-1,
|
| 147 |
+
f'Could not finish the parsing: {e}.',
|
| 148 |
+
'',
|
| 149 |
+
{},
|
| 150 |
+
))
|
| 151 |
+
|
| 152 |
+
return reporter.messages
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/clean.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.clean
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'clean' command."""
|
| 4 |
+
|
| 5 |
+
# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
from distutils._log import log
|
| 9 |
+
from typing import ClassVar
|
| 10 |
+
|
| 11 |
+
from ..core import Command
|
| 12 |
+
from ..dir_util import remove_tree
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class clean(Command):
|
| 16 |
+
description = "clean up temporary files from 'build' command"
|
| 17 |
+
user_options = [
|
| 18 |
+
('build-base=', 'b', "base build directory [default: 'build.build-base']"),
|
| 19 |
+
(
|
| 20 |
+
'build-lib=',
|
| 21 |
+
None,
|
| 22 |
+
"build directory for all modules [default: 'build.build-lib']",
|
| 23 |
+
),
|
| 24 |
+
('build-temp=', 't', "temporary build directory [default: 'build.build-temp']"),
|
| 25 |
+
(
|
| 26 |
+
'build-scripts=',
|
| 27 |
+
None,
|
| 28 |
+
"build directory for scripts [default: 'build.build-scripts']",
|
| 29 |
+
),
|
| 30 |
+
('bdist-base=', None, "temporary directory for built distributions"),
|
| 31 |
+
('all', 'a', "remove all build output, not just temporary by-products"),
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
boolean_options: ClassVar[list[str]] = ['all']
|
| 35 |
+
|
| 36 |
+
def initialize_options(self):
|
| 37 |
+
self.build_base = None
|
| 38 |
+
self.build_lib = None
|
| 39 |
+
self.build_temp = None
|
| 40 |
+
self.build_scripts = None
|
| 41 |
+
self.bdist_base = None
|
| 42 |
+
self.all = None
|
| 43 |
+
|
| 44 |
+
def finalize_options(self):
|
| 45 |
+
self.set_undefined_options(
|
| 46 |
+
'build',
|
| 47 |
+
('build_base', 'build_base'),
|
| 48 |
+
('build_lib', 'build_lib'),
|
| 49 |
+
('build_scripts', 'build_scripts'),
|
| 50 |
+
('build_temp', 'build_temp'),
|
| 51 |
+
)
|
| 52 |
+
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
|
| 53 |
+
|
| 54 |
+
def run(self):
|
| 55 |
+
# remove the build/temp.<plat> directory (unless it's already
|
| 56 |
+
# gone)
|
| 57 |
+
if os.path.exists(self.build_temp):
|
| 58 |
+
remove_tree(self.build_temp, dry_run=self.dry_run)
|
| 59 |
+
else:
|
| 60 |
+
log.debug("'%s' does not exist -- can't clean it", self.build_temp)
|
| 61 |
+
|
| 62 |
+
if self.all:
|
| 63 |
+
# remove build directories
|
| 64 |
+
for directory in (self.build_lib, self.bdist_base, self.build_scripts):
|
| 65 |
+
if os.path.exists(directory):
|
| 66 |
+
remove_tree(directory, dry_run=self.dry_run)
|
| 67 |
+
else:
|
| 68 |
+
log.warning("'%s' does not exist -- can't clean it", directory)
|
| 69 |
+
|
| 70 |
+
# just for the heck of it, try to remove the base build directory:
|
| 71 |
+
# we might have emptied it right now, but if not we don't care
|
| 72 |
+
if not self.dry_run:
|
| 73 |
+
try:
|
| 74 |
+
os.rmdir(self.build_base)
|
| 75 |
+
log.info("removing '%s'", self.build_base)
|
| 76 |
+
except OSError:
|
| 77 |
+
pass
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/config.py
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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) empty command class
|
| 4 |
+
that exists mainly to be sub-classed by specific module distributions and
|
| 5 |
+
applications. The idea is that while every "config" command is different,
|
| 6 |
+
at least they're all named the same, and users always see "config" in the
|
| 7 |
+
list of standard commands. Also, this is a good place to put common
|
| 8 |
+
configure-like tasks: "try to compile this C code", or "figure out where
|
| 9 |
+
this header file lives".
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
from __future__ import annotations
|
| 13 |
+
|
| 14 |
+
import os
|
| 15 |
+
import pathlib
|
| 16 |
+
import re
|
| 17 |
+
from collections.abc import Sequence
|
| 18 |
+
from distutils._log import log
|
| 19 |
+
|
| 20 |
+
from ..ccompiler import CCompiler, CompileError, LinkError, new_compiler
|
| 21 |
+
from ..core import Command
|
| 22 |
+
from ..errors import DistutilsExecError
|
| 23 |
+
from ..sysconfig import customize_compiler
|
| 24 |
+
|
| 25 |
+
LANG_EXT = {"c": ".c", "c++": ".cxx"}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class config(Command):
|
| 29 |
+
description = "prepare to build"
|
| 30 |
+
|
| 31 |
+
user_options = [
|
| 32 |
+
('compiler=', None, "specify the compiler type"),
|
| 33 |
+
('cc=', None, "specify the compiler executable"),
|
| 34 |
+
('include-dirs=', 'I', "list of directories to search for header files"),
|
| 35 |
+
('define=', 'D', "C preprocessor macros to define"),
|
| 36 |
+
('undef=', 'U', "C preprocessor macros to undefine"),
|
| 37 |
+
('libraries=', 'l', "external C libraries to link with"),
|
| 38 |
+
('library-dirs=', 'L', "directories to search for external C libraries"),
|
| 39 |
+
('noisy', None, "show every action (compile, link, run, ...) taken"),
|
| 40 |
+
(
|
| 41 |
+
'dump-source',
|
| 42 |
+
None,
|
| 43 |
+
"dump generated source files before attempting to compile them",
|
| 44 |
+
),
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
# The three standard command methods: since the "config" command
|
| 48 |
+
# does nothing by default, these are empty.
|
| 49 |
+
|
| 50 |
+
def initialize_options(self):
|
| 51 |
+
self.compiler = None
|
| 52 |
+
self.cc = None
|
| 53 |
+
self.include_dirs = None
|
| 54 |
+
self.libraries = None
|
| 55 |
+
self.library_dirs = None
|
| 56 |
+
|
| 57 |
+
# maximal output for now
|
| 58 |
+
self.noisy = 1
|
| 59 |
+
self.dump_source = 1
|
| 60 |
+
|
| 61 |
+
# list of temporary files generated along-the-way that we have
|
| 62 |
+
# to clean at some point
|
| 63 |
+
self.temp_files = []
|
| 64 |
+
|
| 65 |
+
def finalize_options(self):
|
| 66 |
+
if self.include_dirs is None:
|
| 67 |
+
self.include_dirs = self.distribution.include_dirs or []
|
| 68 |
+
elif isinstance(self.include_dirs, str):
|
| 69 |
+
self.include_dirs = self.include_dirs.split(os.pathsep)
|
| 70 |
+
|
| 71 |
+
if self.libraries is None:
|
| 72 |
+
self.libraries = []
|
| 73 |
+
elif isinstance(self.libraries, str):
|
| 74 |
+
self.libraries = [self.libraries]
|
| 75 |
+
|
| 76 |
+
if self.library_dirs is None:
|
| 77 |
+
self.library_dirs = []
|
| 78 |
+
elif isinstance(self.library_dirs, str):
|
| 79 |
+
self.library_dirs = self.library_dirs.split(os.pathsep)
|
| 80 |
+
|
| 81 |
+
def run(self):
|
| 82 |
+
pass
|
| 83 |
+
|
| 84 |
+
# Utility methods for actual "config" commands. The interfaces are
|
| 85 |
+
# loosely based on Autoconf macros of similar names. Sub-classes
|
| 86 |
+
# may use these freely.
|
| 87 |
+
|
| 88 |
+
def _check_compiler(self):
|
| 89 |
+
"""Check that 'self.compiler' really is a CCompiler object;
|
| 90 |
+
if not, make it one.
|
| 91 |
+
"""
|
| 92 |
+
if not isinstance(self.compiler, CCompiler):
|
| 93 |
+
self.compiler = new_compiler(
|
| 94 |
+
compiler=self.compiler, dry_run=self.dry_run, force=True
|
| 95 |
+
)
|
| 96 |
+
customize_compiler(self.compiler)
|
| 97 |
+
if self.include_dirs:
|
| 98 |
+
self.compiler.set_include_dirs(self.include_dirs)
|
| 99 |
+
if self.libraries:
|
| 100 |
+
self.compiler.set_libraries(self.libraries)
|
| 101 |
+
if self.library_dirs:
|
| 102 |
+
self.compiler.set_library_dirs(self.library_dirs)
|
| 103 |
+
|
| 104 |
+
def _gen_temp_sourcefile(self, body, headers, lang):
|
| 105 |
+
filename = "_configtest" + LANG_EXT[lang]
|
| 106 |
+
with open(filename, "w", encoding='utf-8') as file:
|
| 107 |
+
if headers:
|
| 108 |
+
for header in headers:
|
| 109 |
+
file.write(f"#include <{header}>\n")
|
| 110 |
+
file.write("\n")
|
| 111 |
+
file.write(body)
|
| 112 |
+
if body[-1] != "\n":
|
| 113 |
+
file.write("\n")
|
| 114 |
+
return filename
|
| 115 |
+
|
| 116 |
+
def _preprocess(self, body, headers, include_dirs, lang):
|
| 117 |
+
src = self._gen_temp_sourcefile(body, headers, lang)
|
| 118 |
+
out = "_configtest.i"
|
| 119 |
+
self.temp_files.extend([src, out])
|
| 120 |
+
self.compiler.preprocess(src, out, include_dirs=include_dirs)
|
| 121 |
+
return (src, out)
|
| 122 |
+
|
| 123 |
+
def _compile(self, body, headers, include_dirs, lang):
|
| 124 |
+
src = self._gen_temp_sourcefile(body, headers, lang)
|
| 125 |
+
if self.dump_source:
|
| 126 |
+
dump_file(src, f"compiling '{src}':")
|
| 127 |
+
(obj,) = self.compiler.object_filenames([src])
|
| 128 |
+
self.temp_files.extend([src, obj])
|
| 129 |
+
self.compiler.compile([src], include_dirs=include_dirs)
|
| 130 |
+
return (src, obj)
|
| 131 |
+
|
| 132 |
+
def _link(self, body, headers, include_dirs, libraries, library_dirs, lang):
|
| 133 |
+
(src, obj) = self._compile(body, headers, include_dirs, lang)
|
| 134 |
+
prog = os.path.splitext(os.path.basename(src))[0]
|
| 135 |
+
self.compiler.link_executable(
|
| 136 |
+
[obj],
|
| 137 |
+
prog,
|
| 138 |
+
libraries=libraries,
|
| 139 |
+
library_dirs=library_dirs,
|
| 140 |
+
target_lang=lang,
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
if self.compiler.exe_extension is not None:
|
| 144 |
+
prog = prog + self.compiler.exe_extension
|
| 145 |
+
self.temp_files.append(prog)
|
| 146 |
+
|
| 147 |
+
return (src, obj, prog)
|
| 148 |
+
|
| 149 |
+
def _clean(self, *filenames):
|
| 150 |
+
if not filenames:
|
| 151 |
+
filenames = self.temp_files
|
| 152 |
+
self.temp_files = []
|
| 153 |
+
log.info("removing: %s", ' '.join(filenames))
|
| 154 |
+
for filename in filenames:
|
| 155 |
+
try:
|
| 156 |
+
os.remove(filename)
|
| 157 |
+
except OSError:
|
| 158 |
+
pass
|
| 159 |
+
|
| 160 |
+
# XXX these ignore the dry-run flag: what to do, what to do? even if
|
| 161 |
+
# you want a dry-run build, you still need some sort of configuration
|
| 162 |
+
# info. My inclination is to make it up to the real config command to
|
| 163 |
+
# consult 'dry_run', and assume a default (minimal) configuration if
|
| 164 |
+
# true. The problem with trying to do it here is that you'd have to
|
| 165 |
+
# return either true or false from all the 'try' methods, neither of
|
| 166 |
+
# which is correct.
|
| 167 |
+
|
| 168 |
+
# XXX need access to the header search path and maybe default macros.
|
| 169 |
+
|
| 170 |
+
def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"):
|
| 171 |
+
"""Construct a source file from 'body' (a string containing lines
|
| 172 |
+
of C/C++ code) and 'headers' (a list of header files to include)
|
| 173 |
+
and run it through the preprocessor. Return true if the
|
| 174 |
+
preprocessor succeeded, false if there were any errors.
|
| 175 |
+
('body' probably isn't of much use, but what the heck.)
|
| 176 |
+
"""
|
| 177 |
+
self._check_compiler()
|
| 178 |
+
ok = True
|
| 179 |
+
try:
|
| 180 |
+
self._preprocess(body, headers, include_dirs, lang)
|
| 181 |
+
except CompileError:
|
| 182 |
+
ok = False
|
| 183 |
+
|
| 184 |
+
self._clean()
|
| 185 |
+
return ok
|
| 186 |
+
|
| 187 |
+
def search_cpp(self, pattern, body=None, headers=None, include_dirs=None, lang="c"):
|
| 188 |
+
"""Construct a source file (just like 'try_cpp()'), run it through
|
| 189 |
+
the preprocessor, and return true if any line of the output matches
|
| 190 |
+
'pattern'. 'pattern' should either be a compiled regex object or a
|
| 191 |
+
string containing a regex. If both 'body' and 'headers' are None,
|
| 192 |
+
preprocesses an empty file -- which can be useful to determine the
|
| 193 |
+
symbols the preprocessor and compiler set by default.
|
| 194 |
+
"""
|
| 195 |
+
self._check_compiler()
|
| 196 |
+
src, out = self._preprocess(body, headers, include_dirs, lang)
|
| 197 |
+
|
| 198 |
+
if isinstance(pattern, str):
|
| 199 |
+
pattern = re.compile(pattern)
|
| 200 |
+
|
| 201 |
+
with open(out, encoding='utf-8') as file:
|
| 202 |
+
match = any(pattern.search(line) for line in file)
|
| 203 |
+
|
| 204 |
+
self._clean()
|
| 205 |
+
return match
|
| 206 |
+
|
| 207 |
+
def try_compile(self, body, headers=None, include_dirs=None, lang="c"):
|
| 208 |
+
"""Try to compile a source file built from 'body' and 'headers'.
|
| 209 |
+
Return true on success, false otherwise.
|
| 210 |
+
"""
|
| 211 |
+
self._check_compiler()
|
| 212 |
+
try:
|
| 213 |
+
self._compile(body, headers, include_dirs, lang)
|
| 214 |
+
ok = True
|
| 215 |
+
except CompileError:
|
| 216 |
+
ok = False
|
| 217 |
+
|
| 218 |
+
log.info(ok and "success!" or "failure.")
|
| 219 |
+
self._clean()
|
| 220 |
+
return ok
|
| 221 |
+
|
| 222 |
+
def try_link(
|
| 223 |
+
self,
|
| 224 |
+
body,
|
| 225 |
+
headers=None,
|
| 226 |
+
include_dirs=None,
|
| 227 |
+
libraries=None,
|
| 228 |
+
library_dirs=None,
|
| 229 |
+
lang="c",
|
| 230 |
+
):
|
| 231 |
+
"""Try to compile and link a source file, built from 'body' and
|
| 232 |
+
'headers', to executable form. Return true on success, false
|
| 233 |
+
otherwise.
|
| 234 |
+
"""
|
| 235 |
+
self._check_compiler()
|
| 236 |
+
try:
|
| 237 |
+
self._link(body, headers, include_dirs, libraries, library_dirs, lang)
|
| 238 |
+
ok = True
|
| 239 |
+
except (CompileError, LinkError):
|
| 240 |
+
ok = False
|
| 241 |
+
|
| 242 |
+
log.info(ok and "success!" or "failure.")
|
| 243 |
+
self._clean()
|
| 244 |
+
return ok
|
| 245 |
+
|
| 246 |
+
def try_run(
|
| 247 |
+
self,
|
| 248 |
+
body,
|
| 249 |
+
headers=None,
|
| 250 |
+
include_dirs=None,
|
| 251 |
+
libraries=None,
|
| 252 |
+
library_dirs=None,
|
| 253 |
+
lang="c",
|
| 254 |
+
):
|
| 255 |
+
"""Try to compile, link to an executable, and run a program
|
| 256 |
+
built from 'body' and 'headers'. Return true on success, false
|
| 257 |
+
otherwise.
|
| 258 |
+
"""
|
| 259 |
+
self._check_compiler()
|
| 260 |
+
try:
|
| 261 |
+
src, obj, exe = self._link(
|
| 262 |
+
body, headers, include_dirs, libraries, library_dirs, lang
|
| 263 |
+
)
|
| 264 |
+
self.spawn([exe])
|
| 265 |
+
ok = True
|
| 266 |
+
except (CompileError, LinkError, DistutilsExecError):
|
| 267 |
+
ok = False
|
| 268 |
+
|
| 269 |
+
log.info(ok and "success!" or "failure.")
|
| 270 |
+
self._clean()
|
| 271 |
+
return ok
|
| 272 |
+
|
| 273 |
+
# -- High-level methods --------------------------------------------
|
| 274 |
+
# (these are the ones that are actually likely to be useful
|
| 275 |
+
# when implementing a real-world config command!)
|
| 276 |
+
|
| 277 |
+
def check_func(
|
| 278 |
+
self,
|
| 279 |
+
func,
|
| 280 |
+
headers=None,
|
| 281 |
+
include_dirs=None,
|
| 282 |
+
libraries=None,
|
| 283 |
+
library_dirs=None,
|
| 284 |
+
decl=False,
|
| 285 |
+
call=False,
|
| 286 |
+
):
|
| 287 |
+
"""Determine if function 'func' is available by constructing a
|
| 288 |
+
source file that refers to 'func', and compiles and links it.
|
| 289 |
+
If everything succeeds, returns true; otherwise returns false.
|
| 290 |
+
|
| 291 |
+
The constructed source file starts out by including the header
|
| 292 |
+
files listed in 'headers'. If 'decl' is true, it then declares
|
| 293 |
+
'func' (as "int func()"); you probably shouldn't supply 'headers'
|
| 294 |
+
and set 'decl' true in the same call, or you might get errors about
|
| 295 |
+
a conflicting declarations for 'func'. Finally, the constructed
|
| 296 |
+
'main()' function either references 'func' or (if 'call' is true)
|
| 297 |
+
calls it. 'libraries' and 'library_dirs' are used when
|
| 298 |
+
linking.
|
| 299 |
+
"""
|
| 300 |
+
self._check_compiler()
|
| 301 |
+
body = []
|
| 302 |
+
if decl:
|
| 303 |
+
body.append(f"int {func} ();")
|
| 304 |
+
body.append("int main () {")
|
| 305 |
+
if call:
|
| 306 |
+
body.append(f" {func}();")
|
| 307 |
+
else:
|
| 308 |
+
body.append(f" {func};")
|
| 309 |
+
body.append("}")
|
| 310 |
+
body = "\n".join(body) + "\n"
|
| 311 |
+
|
| 312 |
+
return self.try_link(body, headers, include_dirs, libraries, library_dirs)
|
| 313 |
+
|
| 314 |
+
def check_lib(
|
| 315 |
+
self,
|
| 316 |
+
library,
|
| 317 |
+
library_dirs=None,
|
| 318 |
+
headers=None,
|
| 319 |
+
include_dirs=None,
|
| 320 |
+
other_libraries: Sequence[str] = [],
|
| 321 |
+
):
|
| 322 |
+
"""Determine if 'library' is available to be linked against,
|
| 323 |
+
without actually checking that any particular symbols are provided
|
| 324 |
+
by it. 'headers' will be used in constructing the source file to
|
| 325 |
+
be compiled, but the only effect of this is to check if all the
|
| 326 |
+
header files listed are available. Any libraries listed in
|
| 327 |
+
'other_libraries' will be included in the link, in case 'library'
|
| 328 |
+
has symbols that depend on other libraries.
|
| 329 |
+
"""
|
| 330 |
+
self._check_compiler()
|
| 331 |
+
return self.try_link(
|
| 332 |
+
"int main (void) { }",
|
| 333 |
+
headers,
|
| 334 |
+
include_dirs,
|
| 335 |
+
[library] + list(other_libraries),
|
| 336 |
+
library_dirs,
|
| 337 |
+
)
|
| 338 |
+
|
| 339 |
+
def check_header(self, header, include_dirs=None, library_dirs=None, lang="c"):
|
| 340 |
+
"""Determine if the system header file named by 'header_file'
|
| 341 |
+
exists and can be found by the preprocessor; return true if so,
|
| 342 |
+
false otherwise.
|
| 343 |
+
"""
|
| 344 |
+
return self.try_cpp(
|
| 345 |
+
body="/* No body */", headers=[header], include_dirs=include_dirs
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
def dump_file(filename, head=None):
|
| 350 |
+
"""Dumps a file content into log.info.
|
| 351 |
+
|
| 352 |
+
If head is not None, will be dumped before the file content.
|
| 353 |
+
"""
|
| 354 |
+
if head is None:
|
| 355 |
+
log.info('%s', filename)
|
| 356 |
+
else:
|
| 357 |
+
log.info(head)
|
| 358 |
+
log.info(pathlib.Path(filename).read_text(encoding='utf-8'))
|
miniconda3/pkgs/setuptools-80.10.2-py310h06a4308_0/lib/python3.10/site-packages/setuptools/_distutils/command/install.py
ADDED
|
@@ -0,0 +1,805 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""distutils.command.install
|
| 2 |
+
|
| 3 |
+
Implements the Distutils 'install' command."""
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
import collections
|
| 8 |
+
import contextlib
|
| 9 |
+
import itertools
|
| 10 |
+
import os
|
| 11 |
+
import sys
|
| 12 |
+
import sysconfig
|
| 13 |
+
from distutils._log import log
|
| 14 |
+
from site import USER_BASE, USER_SITE
|
| 15 |
+
from typing import ClassVar
|
| 16 |
+
|
| 17 |
+
from ..core import Command
|
| 18 |
+
from ..debug import DEBUG
|
| 19 |
+
from ..errors import DistutilsOptionError, DistutilsPlatformError
|
| 20 |
+
from ..file_util import write_file
|
| 21 |
+
from ..sysconfig import get_config_vars
|
| 22 |
+
from ..util import change_root, convert_path, get_platform, subst_vars
|
| 23 |
+
from . import _framework_compat as fw
|
| 24 |
+
|
| 25 |
+
HAS_USER_SITE = True
|
| 26 |
+
|
| 27 |
+
WINDOWS_SCHEME = {
|
| 28 |
+
'purelib': '{base}/Lib/site-packages',
|
| 29 |
+
'platlib': '{base}/Lib/site-packages',
|
| 30 |
+
'headers': '{base}/Include/{dist_name}',
|
| 31 |
+
'scripts': '{base}/Scripts',
|
| 32 |
+
'data': '{base}',
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
INSTALL_SCHEMES = {
|
| 36 |
+
'posix_prefix': {
|
| 37 |
+
'purelib': '{base}/lib/{implementation_lower}{py_version_short}/site-packages',
|
| 38 |
+
'platlib': '{platbase}/{platlibdir}/{implementation_lower}'
|
| 39 |
+
'{py_version_short}/site-packages',
|
| 40 |
+
'headers': '{base}/include/{implementation_lower}'
|
| 41 |
+
'{py_version_short}{abiflags}/{dist_name}',
|
| 42 |
+
'scripts': '{base}/bin',
|
| 43 |
+
'data': '{base}',
|
| 44 |
+
},
|
| 45 |
+
'posix_home': {
|
| 46 |
+
'purelib': '{base}/lib/{implementation_lower}',
|
| 47 |
+
'platlib': '{base}/{platlibdir}/{implementation_lower}',
|
| 48 |
+
'headers': '{base}/include/{implementation_lower}/{dist_name}',
|
| 49 |
+
'scripts': '{base}/bin',
|
| 50 |
+
'data': '{base}',
|
| 51 |
+
},
|
| 52 |
+
'nt': WINDOWS_SCHEME,
|
| 53 |
+
'pypy': {
|
| 54 |
+
'purelib': '{base}/site-packages',
|
| 55 |
+
'platlib': '{base}/site-packages',
|
| 56 |
+
'headers': '{base}/include/{dist_name}',
|
| 57 |
+
'scripts': '{base}/bin',
|
| 58 |
+
'data': '{base}',
|
| 59 |
+
},
|
| 60 |
+
'pypy_nt': {
|
| 61 |
+
'purelib': '{base}/site-packages',
|
| 62 |
+
'platlib': '{base}/site-packages',
|
| 63 |
+
'headers': '{base}/include/{dist_name}',
|
| 64 |
+
'scripts': '{base}/Scripts',
|
| 65 |
+
'data': '{base}',
|
| 66 |
+
},
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
# user site schemes
|
| 70 |
+
if HAS_USER_SITE:
|
| 71 |
+
INSTALL_SCHEMES['nt_user'] = {
|
| 72 |
+
'purelib': '{usersite}',
|
| 73 |
+
'platlib': '{usersite}',
|
| 74 |
+
'headers': '{userbase}/{implementation}{py_version_nodot_plat}'
|
| 75 |
+
'/Include/{dist_name}',
|
| 76 |
+
'scripts': '{userbase}/{implementation}{py_version_nodot_plat}/Scripts',
|
| 77 |
+
'data': '{userbase}',
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
INSTALL_SCHEMES['posix_user'] = {
|
| 81 |
+
'purelib': '{usersite}',
|
| 82 |
+
'platlib': '{usersite}',
|
| 83 |
+
'headers': '{userbase}/include/{implementation_lower}'
|
| 84 |
+
'{py_version_short}{abiflags}/{dist_name}',
|
| 85 |
+
'scripts': '{userbase}/bin',
|
| 86 |
+
'data': '{userbase}',
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
INSTALL_SCHEMES.update(fw.schemes)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# The keys to an installation scheme; if any new types of files are to be
|
| 94 |
+
# installed, be sure to add an entry to every installation scheme above,
|
| 95 |
+
# and to SCHEME_KEYS here.
|
| 96 |
+
SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def _load_sysconfig_schemes():
|
| 100 |
+
with contextlib.suppress(AttributeError):
|
| 101 |
+
return {
|
| 102 |
+
scheme: sysconfig.get_paths(scheme, expand=False)
|
| 103 |
+
for scheme in sysconfig.get_scheme_names()
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def _load_schemes():
|
| 108 |
+
"""
|
| 109 |
+
Extend default schemes with schemes from sysconfig.
|
| 110 |
+
"""
|
| 111 |
+
|
| 112 |
+
sysconfig_schemes = _load_sysconfig_schemes() or {}
|
| 113 |
+
|
| 114 |
+
return {
|
| 115 |
+
scheme: {
|
| 116 |
+
**INSTALL_SCHEMES.get(scheme, {}),
|
| 117 |
+
**sysconfig_schemes.get(scheme, {}),
|
| 118 |
+
}
|
| 119 |
+
for scheme in set(itertools.chain(INSTALL_SCHEMES, sysconfig_schemes))
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def _get_implementation():
|
| 124 |
+
if hasattr(sys, 'pypy_version_info'):
|
| 125 |
+
return 'PyPy'
|
| 126 |
+
else:
|
| 127 |
+
return 'Python'
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _select_scheme(ob, name):
|
| 131 |
+
scheme = _inject_headers(name, _load_scheme(_resolve_scheme(name)))
|
| 132 |
+
vars(ob).update(_remove_set(ob, _scheme_attrs(scheme)))
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def _remove_set(ob, attrs):
|
| 136 |
+
"""
|
| 137 |
+
Include only attrs that are None in ob.
|
| 138 |
+
"""
|
| 139 |
+
return {key: value for key, value in attrs.items() if getattr(ob, key) is None}
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def _resolve_scheme(name):
|
| 143 |
+
os_name, sep, key = name.partition('_')
|
| 144 |
+
try:
|
| 145 |
+
resolved = sysconfig.get_preferred_scheme(key)
|
| 146 |
+
except Exception:
|
| 147 |
+
resolved = fw.scheme(name)
|
| 148 |
+
return resolved
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _load_scheme(name):
|
| 152 |
+
return _load_schemes()[name]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def _inject_headers(name, scheme):
|
| 156 |
+
"""
|
| 157 |
+
Given a scheme name and the resolved scheme,
|
| 158 |
+
if the scheme does not include headers, resolve
|
| 159 |
+
the fallback scheme for the name and use headers
|
| 160 |
+
from it. pypa/distutils#88
|
| 161 |
+
"""
|
| 162 |
+
# Bypass the preferred scheme, which may not
|
| 163 |
+
# have defined headers.
|
| 164 |
+
fallback = _load_scheme(name)
|
| 165 |
+
scheme.setdefault('headers', fallback['headers'])
|
| 166 |
+
return scheme
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def _scheme_attrs(scheme):
|
| 170 |
+
"""Resolve install directories by applying the install schemes."""
|
| 171 |
+
return {f'install_{key}': scheme[key] for key in SCHEME_KEYS}
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
class install(Command):
|
| 175 |
+
description = "install everything from build directory"
|
| 176 |
+
|
| 177 |
+
user_options = [
|
| 178 |
+
# Select installation scheme and set base director(y|ies)
|
| 179 |
+
('prefix=', None, "installation prefix"),
|
| 180 |
+
('exec-prefix=', None, "(Unix only) prefix for platform-specific files"),
|
| 181 |
+
('home=', None, "(Unix only) home directory to install under"),
|
| 182 |
+
# Or, just set the base director(y|ies)
|
| 183 |
+
(
|
| 184 |
+
'install-base=',
|
| 185 |
+
None,
|
| 186 |
+
"base installation directory (instead of --prefix or --home)",
|
| 187 |
+
),
|
| 188 |
+
(
|
| 189 |
+
'install-platbase=',
|
| 190 |
+
None,
|
| 191 |
+
"base installation directory for platform-specific files (instead of --exec-prefix or --home)",
|
| 192 |
+
),
|
| 193 |
+
('root=', None, "install everything relative to this alternate root directory"),
|
| 194 |
+
# Or, explicitly set the installation scheme
|
| 195 |
+
(
|
| 196 |
+
'install-purelib=',
|
| 197 |
+
None,
|
| 198 |
+
"installation directory for pure Python module distributions",
|
| 199 |
+
),
|
| 200 |
+
(
|
| 201 |
+
'install-platlib=',
|
| 202 |
+
None,
|
| 203 |
+
"installation directory for non-pure module distributions",
|
| 204 |
+
),
|
| 205 |
+
(
|
| 206 |
+
'install-lib=',
|
| 207 |
+
None,
|
| 208 |
+
"installation directory for all module distributions (overrides --install-purelib and --install-platlib)",
|
| 209 |
+
),
|
| 210 |
+
('install-headers=', None, "installation directory for C/C++ headers"),
|
| 211 |
+
('install-scripts=', None, "installation directory for Python scripts"),
|
| 212 |
+
('install-data=', None, "installation directory for data files"),
|
| 213 |
+
# Byte-compilation options -- see install_lib.py for details, as
|
| 214 |
+
# these are duplicated from there (but only install_lib does
|
| 215 |
+
# anything with them).
|
| 216 |
+
('compile', 'c', "compile .py to .pyc [default]"),
|
| 217 |
+
('no-compile', None, "don't compile .py files"),
|
| 218 |
+
(
|
| 219 |
+
'optimize=',
|
| 220 |
+
'O',
|
| 221 |
+
"also compile with optimization: -O1 for \"python -O\", "
|
| 222 |
+
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]",
|
| 223 |
+
),
|
| 224 |
+
# Miscellaneous control options
|
| 225 |
+
('force', 'f', "force installation (overwrite any existing files)"),
|
| 226 |
+
('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
|
| 227 |
+
# Where to install documentation (eventually!)
|
| 228 |
+
# ('doc-format=', None, "format of documentation to generate"),
|
| 229 |
+
# ('install-man=', None, "directory for Unix man pages"),
|
| 230 |
+
# ('install-html=', None, "directory for HTML documentation"),
|
| 231 |
+
# ('install-info=', None, "directory for GNU info files"),
|
| 232 |
+
('record=', None, "filename in which to record list of installed files"),
|
| 233 |
+
]
|
| 234 |
+
|
| 235 |
+
boolean_options: ClassVar[list[str]] = ['compile', 'force', 'skip-build']
|
| 236 |
+
|
| 237 |
+
if HAS_USER_SITE:
|
| 238 |
+
user_options.append((
|
| 239 |
+
'user',
|
| 240 |
+
None,
|
| 241 |
+
f"install in user site-package '{USER_SITE}'",
|
| 242 |
+
))
|
| 243 |
+
boolean_options.append('user')
|
| 244 |
+
|
| 245 |
+
negative_opt: ClassVar[dict[str, str]] = {'no-compile': 'compile'}
|
| 246 |
+
|
| 247 |
+
def initialize_options(self) -> None:
|
| 248 |
+
"""Initializes options."""
|
| 249 |
+
# High-level options: these select both an installation base
|
| 250 |
+
# and scheme.
|
| 251 |
+
self.prefix: str | None = None
|
| 252 |
+
self.exec_prefix: str | None = None
|
| 253 |
+
self.home: str | None = None
|
| 254 |
+
self.user = False
|
| 255 |
+
|
| 256 |
+
# These select only the installation base; it's up to the user to
|
| 257 |
+
# specify the installation scheme (currently, that means supplying
|
| 258 |
+
# the --install-{platlib,purelib,scripts,data} options).
|
| 259 |
+
self.install_base = None
|
| 260 |
+
self.install_platbase = None
|
| 261 |
+
self.root: str | None = None
|
| 262 |
+
|
| 263 |
+
# These options are the actual installation directories; if not
|
| 264 |
+
# supplied by the user, they are filled in using the installation
|
| 265 |
+
# scheme implied by prefix/exec-prefix/home and the contents of
|
| 266 |
+
# that installation scheme.
|
| 267 |
+
self.install_purelib = None # for pure module distributions
|
| 268 |
+
self.install_platlib = None # non-pure (dists w/ extensions)
|
| 269 |
+
self.install_headers = None # for C/C++ headers
|
| 270 |
+
self.install_lib: str | None = None # set to either purelib or platlib
|
| 271 |
+
self.install_scripts = None
|
| 272 |
+
self.install_data = None
|
| 273 |
+
self.install_userbase = USER_BASE
|
| 274 |
+
self.install_usersite = USER_SITE
|
| 275 |
+
|
| 276 |
+
self.compile = None
|
| 277 |
+
self.optimize = None
|
| 278 |
+
|
| 279 |
+
# Deprecated
|
| 280 |
+
# These two are for putting non-packagized distributions into their
|
| 281 |
+
# own directory and creating a .pth file if it makes sense.
|
| 282 |
+
# 'extra_path' comes from the setup file; 'install_path_file' can
|
| 283 |
+
# be turned off if it makes no sense to install a .pth file. (But
|
| 284 |
+
# better to install it uselessly than to guess wrong and not
|
| 285 |
+
# install it when it's necessary and would be used!) Currently,
|
| 286 |
+
# 'install_path_file' is always true unless some outsider meddles
|
| 287 |
+
# with it.
|
| 288 |
+
self.extra_path = None
|
| 289 |
+
self.install_path_file = True
|
| 290 |
+
|
| 291 |
+
# 'force' forces installation, even if target files are not
|
| 292 |
+
# out-of-date. 'skip_build' skips running the "build" command,
|
| 293 |
+
# handy if you know it's not necessary. 'warn_dir' (which is *not*
|
| 294 |
+
# a user option, it's just there so the bdist_* commands can turn
|
| 295 |
+
# it off) determines whether we warn about installing to a
|
| 296 |
+
# directory not in sys.path.
|
| 297 |
+
self.force = False
|
| 298 |
+
self.skip_build = False
|
| 299 |
+
self.warn_dir = True
|
| 300 |
+
|
| 301 |
+
# These are only here as a conduit from the 'build' command to the
|
| 302 |
+
# 'install_*' commands that do the real work. ('build_base' isn't
|
| 303 |
+
# actually used anywhere, but it might be useful in future.) They
|
| 304 |
+
# are not user options, because if the user told the install
|
| 305 |
+
# command where the build directory is, that wouldn't affect the
|
| 306 |
+
# build command.
|
| 307 |
+
self.build_base = None
|
| 308 |
+
self.build_lib = None
|
| 309 |
+
|
| 310 |
+
# Not defined yet because we don't know anything about
|
| 311 |
+
# documentation yet.
|
| 312 |
+
# self.install_man = None
|
| 313 |
+
# self.install_html = None
|
| 314 |
+
# self.install_info = None
|
| 315 |
+
|
| 316 |
+
self.record = None
|
| 317 |
+
|
| 318 |
+
# -- Option finalizing methods -------------------------------------
|
| 319 |
+
# (This is rather more involved than for most commands,
|
| 320 |
+
# because this is where the policy for installing third-
|
| 321 |
+
# party Python modules on various platforms given a wide
|
| 322 |
+
# array of user input is decided. Yes, it's quite complex!)
|
| 323 |
+
|
| 324 |
+
def finalize_options(self) -> None: # noqa: C901
|
| 325 |
+
"""Finalizes options."""
|
| 326 |
+
# This method (and its helpers, like 'finalize_unix()',
|
| 327 |
+
# 'finalize_other()', and 'select_scheme()') is where the default
|
| 328 |
+
# installation directories for modules, extension modules, and
|
| 329 |
+
# anything else we care to install from a Python module
|
| 330 |
+
# distribution. Thus, this code makes a pretty important policy
|
| 331 |
+
# statement about how third-party stuff is added to a Python
|
| 332 |
+
# installation! Note that the actual work of installation is done
|
| 333 |
+
# by the relatively simple 'install_*' commands; they just take
|
| 334 |
+
# their orders from the installation directory options determined
|
| 335 |
+
# here.
|
| 336 |
+
|
| 337 |
+
# Check for errors/inconsistencies in the options; first, stuff
|
| 338 |
+
# that's wrong on any platform.
|
| 339 |
+
|
| 340 |
+
if (self.prefix or self.exec_prefix or self.home) and (
|
| 341 |
+
self.install_base or self.install_platbase
|
| 342 |
+
):
|
| 343 |
+
raise DistutilsOptionError(
|
| 344 |
+
"must supply either prefix/exec-prefix/home or install-base/install-platbase -- not both"
|
| 345 |
+
)
|
| 346 |
+
|
| 347 |
+
if self.home and (self.prefix or self.exec_prefix):
|
| 348 |
+
raise DistutilsOptionError(
|
| 349 |
+
"must supply either home or prefix/exec-prefix -- not both"
|
| 350 |
+
)
|
| 351 |
+
|
| 352 |
+
if self.user and (
|
| 353 |
+
self.prefix
|
| 354 |
+
or self.exec_prefix
|
| 355 |
+
or self.home
|
| 356 |
+
or self.install_base
|
| 357 |
+
or self.install_platbase
|
| 358 |
+
):
|
| 359 |
+
raise DistutilsOptionError(
|
| 360 |
+
"can't combine user with prefix, "
|
| 361 |
+
"exec_prefix/home, or install_(plat)base"
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
# Next, stuff that's wrong (or dubious) only on certain platforms.
|
| 365 |
+
if os.name != "posix":
|
| 366 |
+
if self.exec_prefix:
|
| 367 |
+
self.warn("exec-prefix option ignored on this platform")
|
| 368 |
+
self.exec_prefix = None
|
| 369 |
+
|
| 370 |
+
# Now the interesting logic -- so interesting that we farm it out
|
| 371 |
+
# to other methods. The goal of these methods is to set the final
|
| 372 |
+
# values for the install_{lib,scripts,data,...} options, using as
|
| 373 |
+
# input a heady brew of prefix, exec_prefix, home, install_base,
|
| 374 |
+
# install_platbase, user-supplied versions of
|
| 375 |
+
# install_{purelib,platlib,lib,scripts,data,...}, and the
|
| 376 |
+
# install schemes. Phew!
|
| 377 |
+
|
| 378 |
+
self.dump_dirs("pre-finalize_{unix,other}")
|
| 379 |
+
|
| 380 |
+
if os.name == 'posix':
|
| 381 |
+
self.finalize_unix()
|
| 382 |
+
else:
|
| 383 |
+
self.finalize_other()
|
| 384 |
+
|
| 385 |
+
self.dump_dirs("post-finalize_{unix,other}()")
|
| 386 |
+
|
| 387 |
+
# Expand configuration variables, tilde, etc. in self.install_base
|
| 388 |
+
# and self.install_platbase -- that way, we can use $base or
|
| 389 |
+
# $platbase in the other installation directories and not worry
|
| 390 |
+
# about needing recursive variable expansion (shudder).
|
| 391 |
+
|
| 392 |
+
py_version = sys.version.split()[0]
|
| 393 |
+
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
|
| 394 |
+
try:
|
| 395 |
+
abiflags = sys.abiflags
|
| 396 |
+
except AttributeError:
|
| 397 |
+
# sys.abiflags may not be defined on all platforms.
|
| 398 |
+
abiflags = ''
|
| 399 |
+
local_vars = {
|
| 400 |
+
'dist_name': self.distribution.get_name(),
|
| 401 |
+
'dist_version': self.distribution.get_version(),
|
| 402 |
+
'dist_fullname': self.distribution.get_fullname(),
|
| 403 |
+
'py_version': py_version,
|
| 404 |
+
'py_version_short': f'{sys.version_info.major}.{sys.version_info.minor}',
|
| 405 |
+
'py_version_nodot': f'{sys.version_info.major}{sys.version_info.minor}',
|
| 406 |
+
'sys_prefix': prefix,
|
| 407 |
+
'prefix': prefix,
|
| 408 |
+
'sys_exec_prefix': exec_prefix,
|
| 409 |
+
'exec_prefix': exec_prefix,
|
| 410 |
+
'abiflags': abiflags,
|
| 411 |
+
'platlibdir': getattr(sys, 'platlibdir', 'lib'),
|
| 412 |
+
'implementation_lower': _get_implementation().lower(),
|
| 413 |
+
'implementation': _get_implementation(),
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
# vars for compatibility on older Pythons
|
| 417 |
+
compat_vars = dict(
|
| 418 |
+
# Python 3.9 and earlier
|
| 419 |
+
py_version_nodot_plat=getattr(sys, 'winver', '').replace('.', ''),
|
| 420 |
+
)
|
| 421 |
+
|
| 422 |
+
if HAS_USER_SITE:
|
| 423 |
+
local_vars['userbase'] = self.install_userbase
|
| 424 |
+
local_vars['usersite'] = self.install_usersite
|
| 425 |
+
|
| 426 |
+
self.config_vars = collections.ChainMap(
|
| 427 |
+
local_vars,
|
| 428 |
+
sysconfig.get_config_vars(),
|
| 429 |
+
compat_vars,
|
| 430 |
+
fw.vars(),
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
self.expand_basedirs()
|
| 434 |
+
|
| 435 |
+
self.dump_dirs("post-expand_basedirs()")
|
| 436 |
+
|
| 437 |
+
# Now define config vars for the base directories so we can expand
|
| 438 |
+
# everything else.
|
| 439 |
+
local_vars['base'] = self.install_base
|
| 440 |
+
local_vars['platbase'] = self.install_platbase
|
| 441 |
+
|
| 442 |
+
if DEBUG:
|
| 443 |
+
from pprint import pprint
|
| 444 |
+
|
| 445 |
+
print("config vars:")
|
| 446 |
+
pprint(dict(self.config_vars))
|
| 447 |
+
|
| 448 |
+
# Expand "~" and configuration variables in the installation
|
| 449 |
+
# directories.
|
| 450 |
+
self.expand_dirs()
|
| 451 |
+
|
| 452 |
+
self.dump_dirs("post-expand_dirs()")
|
| 453 |
+
|
| 454 |
+
# Create directories in the home dir:
|
| 455 |
+
if self.user:
|
| 456 |
+
self.create_home_path()
|
| 457 |
+
|
| 458 |
+
# Pick the actual directory to install all modules to: either
|
| 459 |
+
# install_purelib or install_platlib, depending on whether this
|
| 460 |
+
# module distribution is pure or not. Of course, if the user
|
| 461 |
+
# already specified install_lib, use their selection.
|
| 462 |
+
if self.install_lib is None:
|
| 463 |
+
if self.distribution.has_ext_modules(): # has extensions: non-pure
|
| 464 |
+
self.install_lib = self.install_platlib
|
| 465 |
+
else:
|
| 466 |
+
self.install_lib = self.install_purelib
|
| 467 |
+
|
| 468 |
+
# Convert directories from Unix /-separated syntax to the local
|
| 469 |
+
# convention.
|
| 470 |
+
self.convert_paths(
|
| 471 |
+
'lib',
|
| 472 |
+
'purelib',
|
| 473 |
+
'platlib',
|
| 474 |
+
'scripts',
|
| 475 |
+
'data',
|
| 476 |
+
'headers',
|
| 477 |
+
'userbase',
|
| 478 |
+
'usersite',
|
| 479 |
+
)
|
| 480 |
+
|
| 481 |
+
# Deprecated
|
| 482 |
+
# Well, we're not actually fully completely finalized yet: we still
|
| 483 |
+
# have to deal with 'extra_path', which is the hack for allowing
|
| 484 |
+
# non-packagized module distributions (hello, Numerical Python!) to
|
| 485 |
+
# get their own directories.
|
| 486 |
+
self.handle_extra_path()
|
| 487 |
+
self.install_libbase = self.install_lib # needed for .pth file
|
| 488 |
+
self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
|
| 489 |
+
|
| 490 |
+
# If a new root directory was supplied, make all the installation
|
| 491 |
+
# dirs relative to it.
|
| 492 |
+
if self.root is not None:
|
| 493 |
+
self.change_roots(
|
| 494 |
+
'libbase', 'lib', 'purelib', 'platlib', 'scripts', 'data', 'headers'
|
| 495 |
+
)
|
| 496 |
+
|
| 497 |
+
self.dump_dirs("after prepending root")
|
| 498 |
+
|
| 499 |
+
# Find out the build directories, ie. where to install from.
|
| 500 |
+
self.set_undefined_options(
|
| 501 |
+
'build', ('build_base', 'build_base'), ('build_lib', 'build_lib')
|
| 502 |
+
)
|
| 503 |
+
|
| 504 |
+
# Punt on doc directories for now -- after all, we're punting on
|
| 505 |
+
# documentation completely!
|
| 506 |
+
|
| 507 |
+
def dump_dirs(self, msg) -> None:
|
| 508 |
+
"""Dumps the list of user options."""
|
| 509 |
+
if not DEBUG:
|
| 510 |
+
return
|
| 511 |
+
from ..fancy_getopt import longopt_xlate
|
| 512 |
+
|
| 513 |
+
log.debug(msg + ":")
|
| 514 |
+
for opt in self.user_options:
|
| 515 |
+
opt_name = opt[0]
|
| 516 |
+
if opt_name[-1] == "=":
|
| 517 |
+
opt_name = opt_name[0:-1]
|
| 518 |
+
if opt_name in self.negative_opt:
|
| 519 |
+
opt_name = self.negative_opt[opt_name]
|
| 520 |
+
opt_name = opt_name.translate(longopt_xlate)
|
| 521 |
+
val = not getattr(self, opt_name)
|
| 522 |
+
else:
|
| 523 |
+
opt_name = opt_name.translate(longopt_xlate)
|
| 524 |
+
val = getattr(self, opt_name)
|
| 525 |
+
log.debug(" %s: %s", opt_name, val)
|
| 526 |
+
|
| 527 |
+
def finalize_unix(self) -> None:
|
| 528 |
+
"""Finalizes options for posix platforms."""
|
| 529 |
+
if self.install_base is not None or self.install_platbase is not None:
|
| 530 |
+
incomplete_scheme = (
|
| 531 |
+
(
|
| 532 |
+
self.install_lib is None
|
| 533 |
+
and self.install_purelib is None
|
| 534 |
+
and self.install_platlib is None
|
| 535 |
+
)
|
| 536 |
+
or self.install_headers is None
|
| 537 |
+
or self.install_scripts is None
|
| 538 |
+
or self.install_data is None
|
| 539 |
+
)
|
| 540 |
+
if incomplete_scheme:
|
| 541 |
+
raise DistutilsOptionError(
|
| 542 |
+
"install-base or install-platbase supplied, but "
|
| 543 |
+
"installation scheme is incomplete"
|
| 544 |
+
)
|
| 545 |
+
return
|
| 546 |
+
|
| 547 |
+
if self.user:
|
| 548 |
+
if self.install_userbase is None:
|
| 549 |
+
raise DistutilsPlatformError("User base directory is not specified")
|
| 550 |
+
self.install_base = self.install_platbase = self.install_userbase
|
| 551 |
+
self.select_scheme("posix_user")
|
| 552 |
+
elif self.home is not None:
|
| 553 |
+
self.install_base = self.install_platbase = self.home
|
| 554 |
+
self.select_scheme("posix_home")
|
| 555 |
+
else:
|
| 556 |
+
if self.prefix is None:
|
| 557 |
+
if self.exec_prefix is not None:
|
| 558 |
+
raise DistutilsOptionError(
|
| 559 |
+
"must not supply exec-prefix without prefix"
|
| 560 |
+
)
|
| 561 |
+
|
| 562 |
+
# Allow Fedora to add components to the prefix
|
| 563 |
+
_prefix_addition = getattr(sysconfig, '_prefix_addition', "")
|
| 564 |
+
|
| 565 |
+
self.prefix = os.path.normpath(sys.prefix) + _prefix_addition
|
| 566 |
+
self.exec_prefix = os.path.normpath(sys.exec_prefix) + _prefix_addition
|
| 567 |
+
|
| 568 |
+
else:
|
| 569 |
+
if self.exec_prefix is None:
|
| 570 |
+
self.exec_prefix = self.prefix
|
| 571 |
+
|
| 572 |
+
self.install_base = self.prefix
|
| 573 |
+
self.install_platbase = self.exec_prefix
|
| 574 |
+
self.select_scheme("posix_prefix")
|
| 575 |
+
|
| 576 |
+
def finalize_other(self) -> None:
|
| 577 |
+
"""Finalizes options for non-posix platforms"""
|
| 578 |
+
if self.user:
|
| 579 |
+
if self.install_userbase is None:
|
| 580 |
+
raise DistutilsPlatformError("User base directory is not specified")
|
| 581 |
+
self.install_base = self.install_platbase = self.install_userbase
|
| 582 |
+
self.select_scheme(os.name + "_user")
|
| 583 |
+
elif self.home is not None:
|
| 584 |
+
self.install_base = self.install_platbase = self.home
|
| 585 |
+
self.select_scheme("posix_home")
|
| 586 |
+
else:
|
| 587 |
+
if self.prefix is None:
|
| 588 |
+
self.prefix = os.path.normpath(sys.prefix)
|
| 589 |
+
|
| 590 |
+
self.install_base = self.install_platbase = self.prefix
|
| 591 |
+
try:
|
| 592 |
+
self.select_scheme(os.name)
|
| 593 |
+
except KeyError:
|
| 594 |
+
raise DistutilsPlatformError(
|
| 595 |
+
f"I don't know how to install stuff on '{os.name}'"
|
| 596 |
+
)
|
| 597 |
+
|
| 598 |
+
def select_scheme(self, name) -> None:
|
| 599 |
+
_select_scheme(self, name)
|
| 600 |
+
|
| 601 |
+
def _expand_attrs(self, attrs):
|
| 602 |
+
for attr in attrs:
|
| 603 |
+
val = getattr(self, attr)
|
| 604 |
+
if val is not None:
|
| 605 |
+
if os.name in ('posix', 'nt'):
|
| 606 |
+
val = os.path.expanduser(val)
|
| 607 |
+
val = subst_vars(val, self.config_vars)
|
| 608 |
+
setattr(self, attr, val)
|
| 609 |
+
|
| 610 |
+
def expand_basedirs(self) -> None:
|
| 611 |
+
"""Calls `os.path.expanduser` on install_base, install_platbase and
|
| 612 |
+
root."""
|
| 613 |
+
self._expand_attrs(['install_base', 'install_platbase', 'root'])
|
| 614 |
+
|
| 615 |
+
def expand_dirs(self) -> None:
|
| 616 |
+
"""Calls `os.path.expanduser` on install dirs."""
|
| 617 |
+
self._expand_attrs([
|
| 618 |
+
'install_purelib',
|
| 619 |
+
'install_platlib',
|
| 620 |
+
'install_lib',
|
| 621 |
+
'install_headers',
|
| 622 |
+
'install_scripts',
|
| 623 |
+
'install_data',
|
| 624 |
+
])
|
| 625 |
+
|
| 626 |
+
def convert_paths(self, *names) -> None:
|
| 627 |
+
"""Call `convert_path` over `names`."""
|
| 628 |
+
for name in names:
|
| 629 |
+
attr = "install_" + name
|
| 630 |
+
setattr(self, attr, convert_path(getattr(self, attr)))
|
| 631 |
+
|
| 632 |
+
def handle_extra_path(self) -> None:
|
| 633 |
+
"""Set `path_file` and `extra_dirs` using `extra_path`."""
|
| 634 |
+
if self.extra_path is None:
|
| 635 |
+
self.extra_path = self.distribution.extra_path
|
| 636 |
+
|
| 637 |
+
if self.extra_path is not None:
|
| 638 |
+
log.warning(
|
| 639 |
+
"Distribution option extra_path is deprecated. "
|
| 640 |
+
"See issue27919 for details."
|
| 641 |
+
)
|
| 642 |
+
if isinstance(self.extra_path, str):
|
| 643 |
+
self.extra_path = self.extra_path.split(',')
|
| 644 |
+
|
| 645 |
+
if len(self.extra_path) == 1:
|
| 646 |
+
path_file = extra_dirs = self.extra_path[0]
|
| 647 |
+
elif len(self.extra_path) == 2:
|
| 648 |
+
path_file, extra_dirs = self.extra_path
|
| 649 |
+
else:
|
| 650 |
+
raise DistutilsOptionError(
|
| 651 |
+
"'extra_path' option must be a list, tuple, or "
|
| 652 |
+
"comma-separated string with 1 or 2 elements"
|
| 653 |
+
)
|
| 654 |
+
|
| 655 |
+
# convert to local form in case Unix notation used (as it
|
| 656 |
+
# should be in setup scripts)
|
| 657 |
+
extra_dirs = convert_path(extra_dirs)
|
| 658 |
+
else:
|
| 659 |
+
path_file = None
|
| 660 |
+
extra_dirs = ''
|
| 661 |
+
|
| 662 |
+
# XXX should we warn if path_file and not extra_dirs? (in which
|
| 663 |
+
# case the path file would be harmless but pointless)
|
| 664 |
+
self.path_file = path_file
|
| 665 |
+
self.extra_dirs = extra_dirs
|
| 666 |
+
|
| 667 |
+
def change_roots(self, *names) -> None:
|
| 668 |
+
"""Change the install directories pointed by name using root."""
|
| 669 |
+
for name in names:
|
| 670 |
+
attr = "install_" + name
|
| 671 |
+
setattr(self, attr, change_root(self.root, getattr(self, attr)))
|
| 672 |
+
|
| 673 |
+
def create_home_path(self) -> None:
|
| 674 |
+
"""Create directories under ~."""
|
| 675 |
+
if not self.user:
|
| 676 |
+
return
|
| 677 |
+
home = convert_path(os.path.expanduser("~"))
|
| 678 |
+
for path in self.config_vars.values():
|
| 679 |
+
if str(path).startswith(home) and not os.path.isdir(path):
|
| 680 |
+
self.debug_print(f"os.makedirs('{path}', 0o700)")
|
| 681 |
+
os.makedirs(path, 0o700)
|
| 682 |
+
|
| 683 |
+
# -- Command execution methods -------------------------------------
|
| 684 |
+
|
| 685 |
+
def run(self):
|
| 686 |
+
"""Runs the command."""
|
| 687 |
+
# Obviously have to build before we can install
|
| 688 |
+
if not self.skip_build:
|
| 689 |
+
self.run_command('build')
|
| 690 |
+
# If we built for any other platform, we can't install.
|
| 691 |
+
build_plat = self.distribution.get_command_obj('build').plat_name
|
| 692 |
+
# check warn_dir - it is a clue that the 'install' is happening
|
| 693 |
+
# internally, and not to sys.path, so we don't check the platform
|
| 694 |
+
# matches what we are running.
|
| 695 |
+
if self.warn_dir and build_plat != get_platform():
|
| 696 |
+
raise DistutilsPlatformError("Can't install when cross-compiling")
|
| 697 |
+
|
| 698 |
+
# Run all sub-commands (at least those that need to be run)
|
| 699 |
+
for cmd_name in self.get_sub_commands():
|
| 700 |
+
self.run_command(cmd_name)
|
| 701 |
+
|
| 702 |
+
if self.path_file:
|
| 703 |
+
self.create_path_file()
|
| 704 |
+
|
| 705 |
+
# write list of installed files, if requested.
|
| 706 |
+
if self.record:
|
| 707 |
+
outputs = self.get_outputs()
|
| 708 |
+
if self.root: # strip any package prefix
|
| 709 |
+
root_len = len(self.root)
|
| 710 |
+
for counter in range(len(outputs)):
|
| 711 |
+
outputs[counter] = outputs[counter][root_len:]
|
| 712 |
+
self.execute(
|
| 713 |
+
write_file,
|
| 714 |
+
(self.record, outputs),
|
| 715 |
+
f"writing list of installed files to '{self.record}'",
|
| 716 |
+
)
|
| 717 |
+
|
| 718 |
+
sys_path = map(os.path.normpath, sys.path)
|
| 719 |
+
sys_path = map(os.path.normcase, sys_path)
|
| 720 |
+
install_lib = os.path.normcase(os.path.normpath(self.install_lib))
|
| 721 |
+
if (
|
| 722 |
+
self.warn_dir
|
| 723 |
+
and not (self.path_file and self.install_path_file)
|
| 724 |
+
and install_lib not in sys_path
|
| 725 |
+
):
|
| 726 |
+
log.debug(
|
| 727 |
+
(
|
| 728 |
+
"modules installed to '%s', which is not in "
|
| 729 |
+
"Python's module search path (sys.path) -- "
|
| 730 |
+
"you'll have to change the search path yourself"
|
| 731 |
+
),
|
| 732 |
+
self.install_lib,
|
| 733 |
+
)
|
| 734 |
+
|
| 735 |
+
def create_path_file(self):
|
| 736 |
+
"""Creates the .pth file"""
|
| 737 |
+
filename = os.path.join(self.install_libbase, self.path_file + ".pth")
|
| 738 |
+
if self.install_path_file:
|
| 739 |
+
self.execute(
|
| 740 |
+
write_file, (filename, [self.extra_dirs]), f"creating {filename}"
|
| 741 |
+
)
|
| 742 |
+
else:
|
| 743 |
+
self.warn(f"path file '{filename}' not created")
|
| 744 |
+
|
| 745 |
+
# -- Reporting methods ---------------------------------------------
|
| 746 |
+
|
| 747 |
+
def get_outputs(self):
|
| 748 |
+
"""Assembles the outputs of all the sub-commands."""
|
| 749 |
+
outputs = []
|
| 750 |
+
for cmd_name in self.get_sub_commands():
|
| 751 |
+
cmd = self.get_finalized_command(cmd_name)
|
| 752 |
+
# Add the contents of cmd.get_outputs(), ensuring
|
| 753 |
+
# that outputs doesn't contain duplicate entries
|
| 754 |
+
for filename in cmd.get_outputs():
|
| 755 |
+
if filename not in outputs:
|
| 756 |
+
outputs.append(filename)
|
| 757 |
+
|
| 758 |
+
if self.path_file and self.install_path_file:
|
| 759 |
+
outputs.append(os.path.join(self.install_libbase, self.path_file + ".pth"))
|
| 760 |
+
|
| 761 |
+
return outputs
|
| 762 |
+
|
| 763 |
+
def get_inputs(self):
|
| 764 |
+
"""Returns the inputs of all the sub-commands"""
|
| 765 |
+
# XXX gee, this looks familiar ;-(
|
| 766 |
+
inputs = []
|
| 767 |
+
for cmd_name in self.get_sub_commands():
|
| 768 |
+
cmd = self.get_finalized_command(cmd_name)
|
| 769 |
+
inputs.extend(cmd.get_inputs())
|
| 770 |
+
|
| 771 |
+
return inputs
|
| 772 |
+
|
| 773 |
+
# -- Predicates for sub-command list -------------------------------
|
| 774 |
+
|
| 775 |
+
def has_lib(self):
|
| 776 |
+
"""Returns true if the current distribution has any Python
|
| 777 |
+
modules to install."""
|
| 778 |
+
return (
|
| 779 |
+
self.distribution.has_pure_modules() or self.distribution.has_ext_modules()
|
| 780 |
+
)
|
| 781 |
+
|
| 782 |
+
def has_headers(self):
|
| 783 |
+
"""Returns true if the current distribution has any headers to
|
| 784 |
+
install."""
|
| 785 |
+
return self.distribution.has_headers()
|
| 786 |
+
|
| 787 |
+
def has_scripts(self):
|
| 788 |
+
"""Returns true if the current distribution has any scripts to.
|
| 789 |
+
install."""
|
| 790 |
+
return self.distribution.has_scripts()
|
| 791 |
+
|
| 792 |
+
def has_data(self):
|
| 793 |
+
"""Returns true if the current distribution has any data to.
|
| 794 |
+
install."""
|
| 795 |
+
return self.distribution.has_data_files()
|
| 796 |
+
|
| 797 |
+
# 'sub_commands': a list of commands this command might have to run to
|
| 798 |
+
# get its work done. See cmd.py for more info.
|
| 799 |
+
sub_commands = [
|
| 800 |
+
('install_lib', has_lib),
|
| 801 |
+
('install_headers', has_headers),
|
| 802 |
+
('install_scripts', has_scripts),
|
| 803 |
+
('install_data', has_data),
|
| 804 |
+
('install_egg_info', lambda self: True),
|
| 805 |
+
]
|