Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- openflamingo/lib/python3.10/site-packages/astroid/__pycache__/_ast.cpython-310.pyc +0 -0
- openflamingo/lib/python3.10/site-packages/astroid/__pycache__/arguments.cpython-310.pyc +0 -0
- openflamingo/lib/python3.10/site-packages/astroid/__pycache__/modutils.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/__init__.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_entry_points.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_importlib.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_normalization.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_path.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_reqs.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_shutil.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/_static.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/archive_util.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/build_meta.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/discovery.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/dist.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/errors.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/extension.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/launch.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/logging.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/monkey.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/msvc.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/sandbox.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/unicode_utils.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/version.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/__pycache__/warnings.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__init__.py +21 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/alias.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_rpm.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_wheel.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/build_clib.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/build_py.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/dist_info.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/easy_install.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/egg_info.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/install.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/install_lib.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/install_scripts.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/rotate.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/saveopts.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/sdist.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/setopt.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/test.cpython-310.pyc +0 -0
- phi4/lib/python3.10/site-packages/setuptools/command/_requirestxt.py +131 -0
- phi4/lib/python3.10/site-packages/setuptools/command/alias.py +77 -0
- phi4/lib/python3.10/site-packages/setuptools/command/bdist_egg.py +479 -0
- phi4/lib/python3.10/site-packages/setuptools/command/bdist_rpm.py +42 -0
- phi4/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py +610 -0
- phi4/lib/python3.10/site-packages/setuptools/command/build.py +135 -0
- phi4/lib/python3.10/site-packages/setuptools/command/build_clib.py +103 -0
openflamingo/lib/python3.10/site-packages/astroid/__pycache__/_ast.cpython-310.pyc
ADDED
|
Binary file (3.23 kB). View file
|
|
|
openflamingo/lib/python3.10/site-packages/astroid/__pycache__/arguments.cpython-310.pyc
ADDED
|
Binary file (7.86 kB). View file
|
|
|
openflamingo/lib/python3.10/site-packages/astroid/__pycache__/modutils.cpython-310.pyc
ADDED
|
Binary file (19 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (11.1 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_entry_points.cpython-310.pyc
ADDED
|
Binary file (3.23 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_importlib.cpython-310.pyc
ADDED
|
Binary file (321 Bytes). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_normalization.cpython-310.pyc
ADDED
|
Binary file (4.62 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_path.cpython-310.pyc
ADDED
|
Binary file (2.89 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_reqs.cpython-310.pyc
ADDED
|
Binary file (1.62 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_shutil.cpython-310.pyc
ADDED
|
Binary file (1.71 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/_static.cpython-310.pyc
ADDED
|
Binary file (5.15 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/archive_util.cpython-310.pyc
ADDED
|
Binary file (6.18 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/build_meta.cpython-310.pyc
ADDED
|
Binary file (18.4 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/discovery.cpython-310.pyc
ADDED
|
Binary file (21.2 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/dist.cpython-310.pyc
ADDED
|
Binary file (32.6 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/errors.cpython-310.pyc
ADDED
|
Binary file (2.84 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/extension.cpython-310.pyc
ADDED
|
Binary file (6.28 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/launch.cpython-310.pyc
ADDED
|
Binary file (891 Bytes). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/logging.cpython-310.pyc
ADDED
|
Binary file (1.27 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/monkey.cpython-310.pyc
ADDED
|
Binary file (3.62 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/msvc.cpython-310.pyc
ADDED
|
Binary file (36.1 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/sandbox.cpython-310.pyc
ADDED
|
Binary file (16.3 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/unicode_utils.cpython-310.pyc
ADDED
|
Binary file (3.15 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/version.cpython-310.pyc
ADDED
|
Binary file (299 Bytes). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/__pycache__/warnings.cpython-310.pyc
ADDED
|
Binary file (3.96 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mypy: disable_error_code=call-overload
|
| 2 |
+
# pyright: reportCallIssue=false, reportArgumentType=false
|
| 3 |
+
# Can't disable on the exact line because distutils doesn't exists on Python 3.12
|
| 4 |
+
# and type-checkers aren't aware of distutils_hack,
|
| 5 |
+
# causing distutils.command.bdist.bdist.format_commands to be Any.
|
| 6 |
+
|
| 7 |
+
import sys
|
| 8 |
+
|
| 9 |
+
from distutils.command.bdist import bdist
|
| 10 |
+
|
| 11 |
+
if 'egg' not in bdist.format_commands:
|
| 12 |
+
try:
|
| 13 |
+
# format_commands is a dict in vendored distutils
|
| 14 |
+
# It used to be a list in older (stdlib) distutils
|
| 15 |
+
# We support both for backwards compatibility
|
| 16 |
+
bdist.format_commands['egg'] = ('bdist_egg', "Python .egg file")
|
| 17 |
+
except TypeError:
|
| 18 |
+
bdist.format_command['egg'] = ('bdist_egg', "Python .egg file")
|
| 19 |
+
bdist.format_commands.append('egg')
|
| 20 |
+
|
| 21 |
+
del bdist, sys
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/alias.cpython-310.pyc
ADDED
|
Binary file (2.36 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-310.pyc
ADDED
|
Binary file (13.7 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_rpm.cpython-310.pyc
ADDED
|
Binary file (1.78 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/bdist_wheel.cpython-310.pyc
ADDED
|
Binary file (15.5 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/build_clib.cpython-310.pyc
ADDED
|
Binary file (2.5 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/build_py.cpython-310.pyc
ADDED
|
Binary file (15 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/dist_info.cpython-310.pyc
ADDED
|
Binary file (3.26 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/easy_install.cpython-310.pyc
ADDED
|
Binary file (65.2 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/egg_info.cpython-310.pyc
ADDED
|
Binary file (22.3 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/install.cpython-310.pyc
ADDED
|
Binary file (5.42 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/install_lib.cpython-310.pyc
ADDED
|
Binary file (4.52 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/install_scripts.cpython-310.pyc
ADDED
|
Binary file (2.58 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/rotate.cpython-310.pyc
ADDED
|
Binary file (2.63 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/saveopts.cpython-310.pyc
ADDED
|
Binary file (911 Bytes). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/sdist.cpython-310.pyc
ADDED
|
Binary file (7.98 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/setopt.cpython-310.pyc
ADDED
|
Binary file (4.75 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/__pycache__/test.cpython-310.pyc
ADDED
|
Binary file (1.71 kB). View file
|
|
|
phi4/lib/python3.10/site-packages/setuptools/command/_requirestxt.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Helper code used to generate ``requires.txt`` files in the egg-info directory.
|
| 2 |
+
|
| 3 |
+
The ``requires.txt`` file has an specific format:
|
| 4 |
+
- Environment markers need to be part of the section headers and
|
| 5 |
+
should not be part of the requirement spec itself.
|
| 6 |
+
|
| 7 |
+
See https://setuptools.pypa.io/en/latest/deprecated/python_eggs.html#requires-txt
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import io
|
| 13 |
+
from collections import defaultdict
|
| 14 |
+
from collections.abc import Mapping
|
| 15 |
+
from itertools import filterfalse
|
| 16 |
+
from typing import TypeVar
|
| 17 |
+
|
| 18 |
+
from jaraco.text import yield_lines
|
| 19 |
+
from packaging.requirements import Requirement
|
| 20 |
+
|
| 21 |
+
from .. import _reqs
|
| 22 |
+
from .._reqs import _StrOrIter
|
| 23 |
+
|
| 24 |
+
# dict can work as an ordered set
|
| 25 |
+
_T = TypeVar("_T")
|
| 26 |
+
_Ordered = dict[_T, None]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _prepare(
|
| 30 |
+
install_requires: _StrOrIter, extras_require: Mapping[str, _StrOrIter]
|
| 31 |
+
) -> tuple[list[str], dict[str, list[str]]]:
|
| 32 |
+
"""Given values for ``install_requires`` and ``extras_require``
|
| 33 |
+
create modified versions in a way that can be written in ``requires.txt``
|
| 34 |
+
"""
|
| 35 |
+
extras = _convert_extras_requirements(extras_require)
|
| 36 |
+
return _move_install_requirements_markers(install_requires, extras)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _convert_extras_requirements(
|
| 40 |
+
extras_require: Mapping[str, _StrOrIter],
|
| 41 |
+
) -> defaultdict[str, _Ordered[Requirement]]:
|
| 42 |
+
"""
|
| 43 |
+
Convert requirements in `extras_require` of the form
|
| 44 |
+
`"extra": ["barbazquux; {marker}"]` to
|
| 45 |
+
`"extra:{marker}": ["barbazquux"]`.
|
| 46 |
+
"""
|
| 47 |
+
output = defaultdict[str, _Ordered[Requirement]](dict)
|
| 48 |
+
for section, v in extras_require.items():
|
| 49 |
+
# Do not strip empty sections.
|
| 50 |
+
output[section]
|
| 51 |
+
for r in _reqs.parse(v):
|
| 52 |
+
output[section + _suffix_for(r)].setdefault(r)
|
| 53 |
+
|
| 54 |
+
return output
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def _move_install_requirements_markers(
|
| 58 |
+
install_requires: _StrOrIter, extras_require: Mapping[str, _Ordered[Requirement]]
|
| 59 |
+
) -> tuple[list[str], dict[str, list[str]]]:
|
| 60 |
+
"""
|
| 61 |
+
The ``requires.txt`` file has an specific format:
|
| 62 |
+
- Environment markers need to be part of the section headers and
|
| 63 |
+
should not be part of the requirement spec itself.
|
| 64 |
+
|
| 65 |
+
Move requirements in ``install_requires`` that are using environment
|
| 66 |
+
markers ``extras_require``.
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
# divide the install_requires into two sets, simple ones still
|
| 70 |
+
# handled by install_requires and more complex ones handled by extras_require.
|
| 71 |
+
|
| 72 |
+
inst_reqs = list(_reqs.parse(install_requires))
|
| 73 |
+
simple_reqs = filter(_no_marker, inst_reqs)
|
| 74 |
+
complex_reqs = filterfalse(_no_marker, inst_reqs)
|
| 75 |
+
simple_install_requires = list(map(str, simple_reqs))
|
| 76 |
+
|
| 77 |
+
for r in complex_reqs:
|
| 78 |
+
extras_require[':' + str(r.marker)].setdefault(r)
|
| 79 |
+
|
| 80 |
+
expanded_extras = dict(
|
| 81 |
+
# list(dict.fromkeys(...)) ensures a list of unique strings
|
| 82 |
+
(k, list(dict.fromkeys(str(r) for r in map(_clean_req, v))))
|
| 83 |
+
for k, v in extras_require.items()
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
return simple_install_requires, expanded_extras
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def _suffix_for(req):
|
| 90 |
+
"""Return the 'extras_require' suffix for a given requirement."""
|
| 91 |
+
return ':' + str(req.marker) if req.marker else ''
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def _clean_req(req):
|
| 95 |
+
"""Given a Requirement, remove environment markers and return it"""
|
| 96 |
+
r = Requirement(str(req)) # create a copy before modifying
|
| 97 |
+
r.marker = None
|
| 98 |
+
return r
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def _no_marker(req):
|
| 102 |
+
return not req.marker
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def _write_requirements(stream, reqs):
|
| 106 |
+
lines = yield_lines(reqs or ())
|
| 107 |
+
|
| 108 |
+
def append_cr(line):
|
| 109 |
+
return line + '\n'
|
| 110 |
+
|
| 111 |
+
lines = map(append_cr, lines)
|
| 112 |
+
stream.writelines(lines)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def write_requirements(cmd, basename, filename):
|
| 116 |
+
dist = cmd.distribution
|
| 117 |
+
data = io.StringIO()
|
| 118 |
+
install_requires, extras_require = _prepare(
|
| 119 |
+
dist.install_requires or (), dist.extras_require or {}
|
| 120 |
+
)
|
| 121 |
+
_write_requirements(data, install_requires)
|
| 122 |
+
for extra in sorted(extras_require):
|
| 123 |
+
data.write('\n[{extra}]\n'.format(**vars()))
|
| 124 |
+
_write_requirements(data, extras_require[extra])
|
| 125 |
+
cmd.write_or_delete_file("requirements", filename, data.getvalue())
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def write_setup_requirements(cmd, basename, filename):
|
| 129 |
+
data = io.StringIO()
|
| 130 |
+
_write_requirements(data, cmd.distribution.setup_requires)
|
| 131 |
+
cmd.write_or_delete_file("setup-requirements", filename, data.getvalue())
|
phi4/lib/python3.10/site-packages/setuptools/command/alias.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from setuptools.command.setopt import config_file, edit_config, option_base
|
| 2 |
+
|
| 3 |
+
from distutils.errors import DistutilsOptionError
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def shquote(arg):
|
| 7 |
+
"""Quote an argument for later parsing by shlex.split()"""
|
| 8 |
+
for c in '"', "'", "\\", "#":
|
| 9 |
+
if c in arg:
|
| 10 |
+
return repr(arg)
|
| 11 |
+
if arg.split() != [arg]:
|
| 12 |
+
return repr(arg)
|
| 13 |
+
return arg
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class alias(option_base):
|
| 17 |
+
"""Define a shortcut that invokes one or more commands"""
|
| 18 |
+
|
| 19 |
+
description = "define a shortcut to invoke one or more commands"
|
| 20 |
+
command_consumes_arguments = True
|
| 21 |
+
|
| 22 |
+
user_options = [
|
| 23 |
+
('remove', 'r', 'remove (unset) the alias'),
|
| 24 |
+
] + option_base.user_options
|
| 25 |
+
|
| 26 |
+
boolean_options = option_base.boolean_options + ['remove']
|
| 27 |
+
|
| 28 |
+
def initialize_options(self):
|
| 29 |
+
option_base.initialize_options(self)
|
| 30 |
+
self.args = None
|
| 31 |
+
self.remove = None
|
| 32 |
+
|
| 33 |
+
def finalize_options(self) -> None:
|
| 34 |
+
option_base.finalize_options(self)
|
| 35 |
+
if self.remove and len(self.args) != 1:
|
| 36 |
+
raise DistutilsOptionError(
|
| 37 |
+
"Must specify exactly one argument (the alias name) when using --remove"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
def run(self) -> None:
|
| 41 |
+
aliases = self.distribution.get_option_dict('aliases')
|
| 42 |
+
|
| 43 |
+
if not self.args:
|
| 44 |
+
print("Command Aliases")
|
| 45 |
+
print("---------------")
|
| 46 |
+
for alias in aliases:
|
| 47 |
+
print("setup.py alias", format_alias(alias, aliases))
|
| 48 |
+
return
|
| 49 |
+
|
| 50 |
+
elif len(self.args) == 1:
|
| 51 |
+
(alias,) = self.args
|
| 52 |
+
if self.remove:
|
| 53 |
+
command = None
|
| 54 |
+
elif alias in aliases:
|
| 55 |
+
print("setup.py alias", format_alias(alias, aliases))
|
| 56 |
+
return
|
| 57 |
+
else:
|
| 58 |
+
print(f"No alias definition found for {alias!r}")
|
| 59 |
+
return
|
| 60 |
+
else:
|
| 61 |
+
alias = self.args[0]
|
| 62 |
+
command = ' '.join(map(shquote, self.args[1:]))
|
| 63 |
+
|
| 64 |
+
edit_config(self.filename, {'aliases': {alias: command}}, self.dry_run)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def format_alias(name, aliases):
|
| 68 |
+
source, command = aliases[name]
|
| 69 |
+
if source == config_file('global'):
|
| 70 |
+
source = '--global-config '
|
| 71 |
+
elif source == config_file('user'):
|
| 72 |
+
source = '--user-config '
|
| 73 |
+
elif source == config_file('local'):
|
| 74 |
+
source = ''
|
| 75 |
+
else:
|
| 76 |
+
source = f'--filename={source!r}'
|
| 77 |
+
return source + name + ' ' + command
|
phi4/lib/python3.10/site-packages/setuptools/command/bdist_egg.py
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""setuptools.command.bdist_egg
|
| 2 |
+
|
| 3 |
+
Build .egg distributions"""
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
import marshal
|
| 8 |
+
import os
|
| 9 |
+
import re
|
| 10 |
+
import sys
|
| 11 |
+
import textwrap
|
| 12 |
+
from sysconfig import get_path, get_python_version
|
| 13 |
+
from types import CodeType
|
| 14 |
+
from typing import TYPE_CHECKING, Literal
|
| 15 |
+
|
| 16 |
+
from setuptools import Command
|
| 17 |
+
from setuptools.extension import Library
|
| 18 |
+
|
| 19 |
+
from .._path import StrPathT, ensure_directory
|
| 20 |
+
|
| 21 |
+
from distutils import log
|
| 22 |
+
from distutils.dir_util import mkpath, remove_tree
|
| 23 |
+
|
| 24 |
+
if TYPE_CHECKING:
|
| 25 |
+
from typing_extensions import TypeAlias
|
| 26 |
+
|
| 27 |
+
# Same as zipfile._ZipFileMode from typeshed
|
| 28 |
+
_ZipFileMode: TypeAlias = Literal["r", "w", "x", "a"]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _get_purelib():
|
| 32 |
+
return get_path("purelib")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def strip_module(filename):
|
| 36 |
+
if '.' in filename:
|
| 37 |
+
filename = os.path.splitext(filename)[0]
|
| 38 |
+
if filename.endswith('module'):
|
| 39 |
+
filename = filename[:-6]
|
| 40 |
+
return filename
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def sorted_walk(dir):
|
| 44 |
+
"""Do os.walk in a reproducible way,
|
| 45 |
+
independent of indeterministic filesystem readdir order
|
| 46 |
+
"""
|
| 47 |
+
for base, dirs, files in os.walk(dir):
|
| 48 |
+
dirs.sort()
|
| 49 |
+
files.sort()
|
| 50 |
+
yield base, dirs, files
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def write_stub(resource, pyfile) -> None:
|
| 54 |
+
_stub_template = textwrap.dedent(
|
| 55 |
+
"""
|
| 56 |
+
def __bootstrap__():
|
| 57 |
+
global __bootstrap__, __loader__, __file__
|
| 58 |
+
import sys, pkg_resources, importlib.util
|
| 59 |
+
__file__ = pkg_resources.resource_filename(__name__, %r)
|
| 60 |
+
__loader__ = None; del __bootstrap__, __loader__
|
| 61 |
+
spec = importlib.util.spec_from_file_location(__name__,__file__)
|
| 62 |
+
mod = importlib.util.module_from_spec(spec)
|
| 63 |
+
spec.loader.exec_module(mod)
|
| 64 |
+
__bootstrap__()
|
| 65 |
+
"""
|
| 66 |
+
).lstrip()
|
| 67 |
+
with open(pyfile, 'w', encoding="utf-8") as f:
|
| 68 |
+
f.write(_stub_template % resource)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class bdist_egg(Command):
|
| 72 |
+
description = 'create an "egg" distribution'
|
| 73 |
+
|
| 74 |
+
user_options = [
|
| 75 |
+
('bdist-dir=', 'b', "temporary directory for creating the distribution"),
|
| 76 |
+
(
|
| 77 |
+
'plat-name=',
|
| 78 |
+
'p',
|
| 79 |
+
"platform name to embed in generated filenames "
|
| 80 |
+
"(by default uses `pkg_resources.get_build_platform()`)",
|
| 81 |
+
),
|
| 82 |
+
('exclude-source-files', None, "remove all .py files from the generated egg"),
|
| 83 |
+
(
|
| 84 |
+
'keep-temp',
|
| 85 |
+
'k',
|
| 86 |
+
"keep the pseudo-installation tree around after "
|
| 87 |
+
"creating the distribution archive",
|
| 88 |
+
),
|
| 89 |
+
('dist-dir=', 'd', "directory to put final built distributions in"),
|
| 90 |
+
('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
|
| 91 |
+
]
|
| 92 |
+
|
| 93 |
+
boolean_options = ['keep-temp', 'skip-build', 'exclude-source-files']
|
| 94 |
+
|
| 95 |
+
def initialize_options(self):
|
| 96 |
+
self.bdist_dir = None
|
| 97 |
+
self.plat_name = None
|
| 98 |
+
self.keep_temp = False
|
| 99 |
+
self.dist_dir = None
|
| 100 |
+
self.skip_build = False
|
| 101 |
+
self.egg_output = None
|
| 102 |
+
self.exclude_source_files = None
|
| 103 |
+
|
| 104 |
+
def finalize_options(self) -> None:
|
| 105 |
+
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
|
| 106 |
+
self.egg_info = ei_cmd.egg_info
|
| 107 |
+
|
| 108 |
+
if self.bdist_dir is None:
|
| 109 |
+
bdist_base = self.get_finalized_command('bdist').bdist_base
|
| 110 |
+
self.bdist_dir = os.path.join(bdist_base, 'egg')
|
| 111 |
+
|
| 112 |
+
if self.plat_name is None:
|
| 113 |
+
from pkg_resources import get_build_platform
|
| 114 |
+
|
| 115 |
+
self.plat_name = get_build_platform()
|
| 116 |
+
|
| 117 |
+
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
| 118 |
+
|
| 119 |
+
if self.egg_output is None:
|
| 120 |
+
# Compute filename of the output egg
|
| 121 |
+
basename = ei_cmd._get_egg_basename(
|
| 122 |
+
py_version=get_python_version(),
|
| 123 |
+
platform=self.distribution.has_ext_modules() and self.plat_name,
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
|
| 127 |
+
|
| 128 |
+
def do_install_data(self) -> None:
|
| 129 |
+
# Hack for packages that install data to install's --install-lib
|
| 130 |
+
self.get_finalized_command('install').install_lib = self.bdist_dir
|
| 131 |
+
|
| 132 |
+
site_packages = os.path.normcase(os.path.realpath(_get_purelib()))
|
| 133 |
+
old, self.distribution.data_files = self.distribution.data_files, []
|
| 134 |
+
|
| 135 |
+
for item in old:
|
| 136 |
+
if isinstance(item, tuple) and len(item) == 2:
|
| 137 |
+
if os.path.isabs(item[0]):
|
| 138 |
+
realpath = os.path.realpath(item[0])
|
| 139 |
+
normalized = os.path.normcase(realpath)
|
| 140 |
+
if normalized == site_packages or normalized.startswith(
|
| 141 |
+
site_packages + os.sep
|
| 142 |
+
):
|
| 143 |
+
item = realpath[len(site_packages) + 1 :], item[1]
|
| 144 |
+
# XXX else: raise ???
|
| 145 |
+
self.distribution.data_files.append(item)
|
| 146 |
+
|
| 147 |
+
try:
|
| 148 |
+
log.info("installing package data to %s", self.bdist_dir)
|
| 149 |
+
self.call_command('install_data', force=False, root=None)
|
| 150 |
+
finally:
|
| 151 |
+
self.distribution.data_files = old
|
| 152 |
+
|
| 153 |
+
def get_outputs(self):
|
| 154 |
+
return [self.egg_output]
|
| 155 |
+
|
| 156 |
+
def call_command(self, cmdname, **kw):
|
| 157 |
+
"""Invoke reinitialized command `cmdname` with keyword args"""
|
| 158 |
+
for dirname in INSTALL_DIRECTORY_ATTRS:
|
| 159 |
+
kw.setdefault(dirname, self.bdist_dir)
|
| 160 |
+
kw.setdefault('skip_build', self.skip_build)
|
| 161 |
+
kw.setdefault('dry_run', self.dry_run)
|
| 162 |
+
cmd = self.reinitialize_command(cmdname, **kw)
|
| 163 |
+
self.run_command(cmdname)
|
| 164 |
+
return cmd
|
| 165 |
+
|
| 166 |
+
def run(self): # noqa: C901 # is too complex (14) # FIXME
|
| 167 |
+
# Generate metadata first
|
| 168 |
+
self.run_command("egg_info")
|
| 169 |
+
# We run install_lib before install_data, because some data hacks
|
| 170 |
+
# pull their data path from the install_lib command.
|
| 171 |
+
log.info("installing library code to %s", self.bdist_dir)
|
| 172 |
+
instcmd = self.get_finalized_command('install')
|
| 173 |
+
old_root = instcmd.root
|
| 174 |
+
instcmd.root = None
|
| 175 |
+
if self.distribution.has_c_libraries() and not self.skip_build:
|
| 176 |
+
self.run_command('build_clib')
|
| 177 |
+
cmd = self.call_command('install_lib', warn_dir=False)
|
| 178 |
+
instcmd.root = old_root
|
| 179 |
+
|
| 180 |
+
all_outputs, ext_outputs = self.get_ext_outputs()
|
| 181 |
+
self.stubs = []
|
| 182 |
+
to_compile = []
|
| 183 |
+
for p, ext_name in enumerate(ext_outputs):
|
| 184 |
+
filename, _ext = os.path.splitext(ext_name)
|
| 185 |
+
pyfile = os.path.join(self.bdist_dir, strip_module(filename) + '.py')
|
| 186 |
+
self.stubs.append(pyfile)
|
| 187 |
+
log.info("creating stub loader for %s", ext_name)
|
| 188 |
+
if not self.dry_run:
|
| 189 |
+
write_stub(os.path.basename(ext_name), pyfile)
|
| 190 |
+
to_compile.append(pyfile)
|
| 191 |
+
ext_outputs[p] = ext_name.replace(os.sep, '/')
|
| 192 |
+
|
| 193 |
+
if to_compile:
|
| 194 |
+
cmd.byte_compile(to_compile)
|
| 195 |
+
if self.distribution.data_files:
|
| 196 |
+
self.do_install_data()
|
| 197 |
+
|
| 198 |
+
# Make the EGG-INFO directory
|
| 199 |
+
archive_root = self.bdist_dir
|
| 200 |
+
egg_info = os.path.join(archive_root, 'EGG-INFO')
|
| 201 |
+
self.mkpath(egg_info)
|
| 202 |
+
if self.distribution.scripts:
|
| 203 |
+
script_dir = os.path.join(egg_info, 'scripts')
|
| 204 |
+
log.info("installing scripts to %s", script_dir)
|
| 205 |
+
self.call_command('install_scripts', install_dir=script_dir, no_ep=True)
|
| 206 |
+
|
| 207 |
+
self.copy_metadata_to(egg_info)
|
| 208 |
+
native_libs = os.path.join(egg_info, "native_libs.txt")
|
| 209 |
+
if all_outputs:
|
| 210 |
+
log.info("writing %s", native_libs)
|
| 211 |
+
if not self.dry_run:
|
| 212 |
+
ensure_directory(native_libs)
|
| 213 |
+
with open(native_libs, 'wt', encoding="utf-8") as libs_file:
|
| 214 |
+
libs_file.write('\n'.join(all_outputs))
|
| 215 |
+
libs_file.write('\n')
|
| 216 |
+
elif os.path.isfile(native_libs):
|
| 217 |
+
log.info("removing %s", native_libs)
|
| 218 |
+
if not self.dry_run:
|
| 219 |
+
os.unlink(native_libs)
|
| 220 |
+
|
| 221 |
+
write_safety_flag(os.path.join(archive_root, 'EGG-INFO'), self.zip_safe())
|
| 222 |
+
|
| 223 |
+
if os.path.exists(os.path.join(self.egg_info, 'depends.txt')):
|
| 224 |
+
log.warn(
|
| 225 |
+
"WARNING: 'depends.txt' will not be used by setuptools 0.6!\n"
|
| 226 |
+
"Use the install_requires/extras_require setup() args instead."
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
if self.exclude_source_files:
|
| 230 |
+
self.zap_pyfiles()
|
| 231 |
+
|
| 232 |
+
# Make the archive
|
| 233 |
+
make_zipfile(
|
| 234 |
+
self.egg_output,
|
| 235 |
+
archive_root,
|
| 236 |
+
verbose=self.verbose,
|
| 237 |
+
dry_run=self.dry_run,
|
| 238 |
+
mode=self.gen_header(),
|
| 239 |
+
)
|
| 240 |
+
if not self.keep_temp:
|
| 241 |
+
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
| 242 |
+
|
| 243 |
+
# Add to 'Distribution.dist_files' so that the "upload" command works
|
| 244 |
+
getattr(self.distribution, 'dist_files', []).append((
|
| 245 |
+
'bdist_egg',
|
| 246 |
+
get_python_version(),
|
| 247 |
+
self.egg_output,
|
| 248 |
+
))
|
| 249 |
+
|
| 250 |
+
def zap_pyfiles(self):
|
| 251 |
+
log.info("Removing .py files from temporary directory")
|
| 252 |
+
for base, dirs, files in walk_egg(self.bdist_dir):
|
| 253 |
+
for name in files:
|
| 254 |
+
path = os.path.join(base, name)
|
| 255 |
+
|
| 256 |
+
if name.endswith('.py'):
|
| 257 |
+
log.debug("Deleting %s", path)
|
| 258 |
+
os.unlink(path)
|
| 259 |
+
|
| 260 |
+
if base.endswith('__pycache__'):
|
| 261 |
+
path_old = path
|
| 262 |
+
|
| 263 |
+
pattern = r'(?P<name>.+)\.(?P<magic>[^.]+)\.pyc'
|
| 264 |
+
m = re.match(pattern, name)
|
| 265 |
+
path_new = os.path.join(base, os.pardir, m.group('name') + '.pyc')
|
| 266 |
+
log.info(f"Renaming file from [{path_old}] to [{path_new}]")
|
| 267 |
+
try:
|
| 268 |
+
os.remove(path_new)
|
| 269 |
+
except OSError:
|
| 270 |
+
pass
|
| 271 |
+
os.rename(path_old, path_new)
|
| 272 |
+
|
| 273 |
+
def zip_safe(self):
|
| 274 |
+
safe = getattr(self.distribution, 'zip_safe', None)
|
| 275 |
+
if safe is not None:
|
| 276 |
+
return safe
|
| 277 |
+
log.warn("zip_safe flag not set; analyzing archive contents...")
|
| 278 |
+
return analyze_egg(self.bdist_dir, self.stubs)
|
| 279 |
+
|
| 280 |
+
def gen_header(self) -> Literal["w"]:
|
| 281 |
+
return 'w'
|
| 282 |
+
|
| 283 |
+
def copy_metadata_to(self, target_dir) -> None:
|
| 284 |
+
"Copy metadata (egg info) to the target_dir"
|
| 285 |
+
# normalize the path (so that a forward-slash in egg_info will
|
| 286 |
+
# match using startswith below)
|
| 287 |
+
norm_egg_info = os.path.normpath(self.egg_info)
|
| 288 |
+
prefix = os.path.join(norm_egg_info, '')
|
| 289 |
+
for path in self.ei_cmd.filelist.files:
|
| 290 |
+
if path.startswith(prefix):
|
| 291 |
+
target = os.path.join(target_dir, path[len(prefix) :])
|
| 292 |
+
ensure_directory(target)
|
| 293 |
+
self.copy_file(path, target)
|
| 294 |
+
|
| 295 |
+
def get_ext_outputs(self):
|
| 296 |
+
"""Get a list of relative paths to C extensions in the output distro"""
|
| 297 |
+
|
| 298 |
+
all_outputs = []
|
| 299 |
+
ext_outputs = []
|
| 300 |
+
|
| 301 |
+
paths = {self.bdist_dir: ''}
|
| 302 |
+
for base, dirs, files in sorted_walk(self.bdist_dir):
|
| 303 |
+
all_outputs.extend(
|
| 304 |
+
paths[base] + filename
|
| 305 |
+
for filename in files
|
| 306 |
+
if os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS
|
| 307 |
+
)
|
| 308 |
+
for filename in dirs:
|
| 309 |
+
paths[os.path.join(base, filename)] = paths[base] + filename + '/'
|
| 310 |
+
|
| 311 |
+
if self.distribution.has_ext_modules():
|
| 312 |
+
build_cmd = self.get_finalized_command('build_ext')
|
| 313 |
+
for ext in build_cmd.extensions:
|
| 314 |
+
if isinstance(ext, Library):
|
| 315 |
+
continue
|
| 316 |
+
fullname = build_cmd.get_ext_fullname(ext.name)
|
| 317 |
+
filename = build_cmd.get_ext_filename(fullname)
|
| 318 |
+
if not os.path.basename(filename).startswith('dl-'):
|
| 319 |
+
if os.path.exists(os.path.join(self.bdist_dir, filename)):
|
| 320 |
+
ext_outputs.append(filename)
|
| 321 |
+
|
| 322 |
+
return all_outputs, ext_outputs
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
NATIVE_EXTENSIONS: dict[str, None] = dict.fromkeys('.dll .so .dylib .pyd'.split())
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def walk_egg(egg_dir):
|
| 329 |
+
"""Walk an unpacked egg's contents, skipping the metadata directory"""
|
| 330 |
+
walker = sorted_walk(egg_dir)
|
| 331 |
+
base, dirs, files = next(walker)
|
| 332 |
+
if 'EGG-INFO' in dirs:
|
| 333 |
+
dirs.remove('EGG-INFO')
|
| 334 |
+
yield base, dirs, files
|
| 335 |
+
yield from walker
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
def analyze_egg(egg_dir, stubs):
|
| 339 |
+
# check for existing flag in EGG-INFO
|
| 340 |
+
for flag, fn in safety_flags.items():
|
| 341 |
+
if os.path.exists(os.path.join(egg_dir, 'EGG-INFO', fn)):
|
| 342 |
+
return flag
|
| 343 |
+
if not can_scan():
|
| 344 |
+
return False
|
| 345 |
+
safe = True
|
| 346 |
+
for base, dirs, files in walk_egg(egg_dir):
|
| 347 |
+
for name in files:
|
| 348 |
+
if name.endswith('.py') or name.endswith('.pyw'):
|
| 349 |
+
continue
|
| 350 |
+
elif name.endswith('.pyc') or name.endswith('.pyo'):
|
| 351 |
+
# always scan, even if we already know we're not safe
|
| 352 |
+
safe = scan_module(egg_dir, base, name, stubs) and safe
|
| 353 |
+
return safe
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def write_safety_flag(egg_dir, safe) -> None:
|
| 357 |
+
# Write or remove zip safety flag file(s)
|
| 358 |
+
for flag, fn in safety_flags.items():
|
| 359 |
+
fn = os.path.join(egg_dir, fn)
|
| 360 |
+
if os.path.exists(fn):
|
| 361 |
+
if safe is None or bool(safe) != flag:
|
| 362 |
+
os.unlink(fn)
|
| 363 |
+
elif safe is not None and bool(safe) == flag:
|
| 364 |
+
with open(fn, 'wt', encoding="utf-8") as f:
|
| 365 |
+
f.write('\n')
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
safety_flags = {
|
| 369 |
+
True: 'zip-safe',
|
| 370 |
+
False: 'not-zip-safe',
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def scan_module(egg_dir, base, name, stubs):
|
| 375 |
+
"""Check whether module possibly uses unsafe-for-zipfile stuff"""
|
| 376 |
+
|
| 377 |
+
filename = os.path.join(base, name)
|
| 378 |
+
if filename[:-1] in stubs:
|
| 379 |
+
return True # Extension module
|
| 380 |
+
pkg = base[len(egg_dir) + 1 :].replace(os.sep, '.')
|
| 381 |
+
module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0]
|
| 382 |
+
skip = 16 # skip magic & reserved? & date & file size
|
| 383 |
+
f = open(filename, 'rb')
|
| 384 |
+
f.read(skip)
|
| 385 |
+
code = marshal.load(f)
|
| 386 |
+
f.close()
|
| 387 |
+
safe = True
|
| 388 |
+
symbols = dict.fromkeys(iter_symbols(code))
|
| 389 |
+
for bad in ['__file__', '__path__']:
|
| 390 |
+
if bad in symbols:
|
| 391 |
+
log.warn("%s: module references %s", module, bad)
|
| 392 |
+
safe = False
|
| 393 |
+
if 'inspect' in symbols:
|
| 394 |
+
for bad in [
|
| 395 |
+
'getsource',
|
| 396 |
+
'getabsfile',
|
| 397 |
+
'getfile',
|
| 398 |
+
'getsourcefile',
|
| 399 |
+
'getsourcelines',
|
| 400 |
+
'findsource',
|
| 401 |
+
'getcomments',
|
| 402 |
+
'getframeinfo',
|
| 403 |
+
'getinnerframes',
|
| 404 |
+
'getouterframes',
|
| 405 |
+
'stack',
|
| 406 |
+
'trace',
|
| 407 |
+
]:
|
| 408 |
+
if bad in symbols:
|
| 409 |
+
log.warn("%s: module MAY be using inspect.%s", module, bad)
|
| 410 |
+
safe = False
|
| 411 |
+
return safe
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
def iter_symbols(code):
|
| 415 |
+
"""Yield names and strings used by `code` and its nested code objects"""
|
| 416 |
+
yield from code.co_names
|
| 417 |
+
for const in code.co_consts:
|
| 418 |
+
if isinstance(const, str):
|
| 419 |
+
yield const
|
| 420 |
+
elif isinstance(const, CodeType):
|
| 421 |
+
yield from iter_symbols(const)
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
def can_scan() -> bool:
|
| 425 |
+
if not sys.platform.startswith('java') and sys.platform != 'cli':
|
| 426 |
+
# CPython, PyPy, etc.
|
| 427 |
+
return True
|
| 428 |
+
log.warn("Unable to analyze compiled code on this platform.")
|
| 429 |
+
log.warn(
|
| 430 |
+
"Please ask the author to include a 'zip_safe'"
|
| 431 |
+
" setting (either True or False) in the package's setup.py"
|
| 432 |
+
)
|
| 433 |
+
return False
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
# Attribute names of options for commands that might need to be convinced to
|
| 437 |
+
# install to the egg build directory
|
| 438 |
+
|
| 439 |
+
INSTALL_DIRECTORY_ATTRS = ['install_lib', 'install_dir', 'install_data', 'install_base']
|
| 440 |
+
|
| 441 |
+
|
| 442 |
+
def make_zipfile(
|
| 443 |
+
zip_filename: StrPathT,
|
| 444 |
+
base_dir,
|
| 445 |
+
verbose: bool = False,
|
| 446 |
+
dry_run: bool = False,
|
| 447 |
+
compress=True,
|
| 448 |
+
mode: _ZipFileMode = 'w',
|
| 449 |
+
) -> StrPathT:
|
| 450 |
+
"""Create a zip file from all the files under 'base_dir'. The output
|
| 451 |
+
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile"
|
| 452 |
+
Python module (if available) or the InfoZIP "zip" utility (if installed
|
| 453 |
+
and found on the default search path). If neither tool is available,
|
| 454 |
+
raises DistutilsExecError. Returns the name of the output zip file.
|
| 455 |
+
"""
|
| 456 |
+
import zipfile
|
| 457 |
+
|
| 458 |
+
mkpath(os.path.dirname(zip_filename), dry_run=dry_run) # type: ignore[arg-type] # python/mypy#18075
|
| 459 |
+
log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir)
|
| 460 |
+
|
| 461 |
+
def visit(z, dirname, names):
|
| 462 |
+
for name in names:
|
| 463 |
+
path = os.path.normpath(os.path.join(dirname, name))
|
| 464 |
+
if os.path.isfile(path):
|
| 465 |
+
p = path[len(base_dir) + 1 :]
|
| 466 |
+
if not dry_run:
|
| 467 |
+
z.write(path, p)
|
| 468 |
+
log.debug("adding '%s'", p)
|
| 469 |
+
|
| 470 |
+
compression = zipfile.ZIP_DEFLATED if compress else zipfile.ZIP_STORED
|
| 471 |
+
if not dry_run:
|
| 472 |
+
z = zipfile.ZipFile(zip_filename, mode, compression=compression)
|
| 473 |
+
for dirname, dirs, files in sorted_walk(base_dir):
|
| 474 |
+
visit(z, dirname, files)
|
| 475 |
+
z.close()
|
| 476 |
+
else:
|
| 477 |
+
for dirname, dirs, files in sorted_walk(base_dir):
|
| 478 |
+
visit(None, dirname, files)
|
| 479 |
+
return zip_filename
|
phi4/lib/python3.10/site-packages/setuptools/command/bdist_rpm.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..dist import Distribution
|
| 2 |
+
from ..warnings import SetuptoolsDeprecationWarning
|
| 3 |
+
|
| 4 |
+
import distutils.command.bdist_rpm as orig
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class bdist_rpm(orig.bdist_rpm):
|
| 8 |
+
"""
|
| 9 |
+
Override the default bdist_rpm behavior to do the following:
|
| 10 |
+
|
| 11 |
+
1. Run egg_info to ensure the name and version are properly calculated.
|
| 12 |
+
2. Always run 'install' using --single-version-externally-managed to
|
| 13 |
+
disable eggs in RPM distributions.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
| 17 |
+
|
| 18 |
+
def run(self) -> None:
|
| 19 |
+
SetuptoolsDeprecationWarning.emit(
|
| 20 |
+
"Deprecated command",
|
| 21 |
+
"""
|
| 22 |
+
bdist_rpm is deprecated and will be removed in a future version.
|
| 23 |
+
Use bdist_wheel (wheel packages) instead.
|
| 24 |
+
""",
|
| 25 |
+
see_url="https://github.com/pypa/setuptools/issues/1988",
|
| 26 |
+
due_date=(2023, 10, 30), # Deprecation introduced in 22 Oct 2021.
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# ensure distro name is up-to-date
|
| 30 |
+
self.run_command('egg_info')
|
| 31 |
+
|
| 32 |
+
orig.bdist_rpm.run(self)
|
| 33 |
+
|
| 34 |
+
def _make_spec_file(self):
|
| 35 |
+
spec = orig.bdist_rpm._make_spec_file(self)
|
| 36 |
+
return [
|
| 37 |
+
line.replace(
|
| 38 |
+
"setup.py install ",
|
| 39 |
+
"setup.py install --single-version-externally-managed ",
|
| 40 |
+
).replace("%setup", "%setup -n %{name}-%{unmangled_version}")
|
| 41 |
+
for line in spec
|
| 42 |
+
]
|
phi4/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py
ADDED
|
@@ -0,0 +1,610 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Create a wheel (.whl) distribution.
|
| 3 |
+
|
| 4 |
+
A wheel is a built archive format.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import os
|
| 10 |
+
import re
|
| 11 |
+
import shutil
|
| 12 |
+
import struct
|
| 13 |
+
import sys
|
| 14 |
+
import sysconfig
|
| 15 |
+
import warnings
|
| 16 |
+
from collections.abc import Iterable, Sequence
|
| 17 |
+
from email.generator import BytesGenerator
|
| 18 |
+
from glob import iglob
|
| 19 |
+
from typing import Literal, cast
|
| 20 |
+
from zipfile import ZIP_DEFLATED, ZIP_STORED
|
| 21 |
+
|
| 22 |
+
from packaging import tags, version as _packaging_version
|
| 23 |
+
from wheel.wheelfile import WheelFile
|
| 24 |
+
|
| 25 |
+
from .. import Command, __version__, _shutil
|
| 26 |
+
from ..warnings import SetuptoolsDeprecationWarning
|
| 27 |
+
from .egg_info import egg_info as egg_info_cls
|
| 28 |
+
|
| 29 |
+
from distutils import log
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def safe_name(name: str) -> str:
|
| 33 |
+
"""Convert an arbitrary string to a standard distribution name
|
| 34 |
+
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
|
| 35 |
+
"""
|
| 36 |
+
return re.sub("[^A-Za-z0-9.]+", "-", name)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def safe_version(version: str) -> str:
|
| 40 |
+
"""
|
| 41 |
+
Convert an arbitrary string to a standard version string
|
| 42 |
+
"""
|
| 43 |
+
try:
|
| 44 |
+
# normalize the version
|
| 45 |
+
return str(_packaging_version.Version(version))
|
| 46 |
+
except _packaging_version.InvalidVersion:
|
| 47 |
+
version = version.replace(" ", ".")
|
| 48 |
+
return re.sub("[^A-Za-z0-9.]+", "-", version)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
setuptools_major_version = int(__version__.split(".")[0])
|
| 52 |
+
|
| 53 |
+
PY_LIMITED_API_PATTERN = r"cp3\d"
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def _is_32bit_interpreter() -> bool:
|
| 57 |
+
return struct.calcsize("P") == 4
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def python_tag() -> str:
|
| 61 |
+
return f"py{sys.version_info.major}"
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def get_platform(archive_root: str | None) -> str:
|
| 65 |
+
"""Return our platform name 'win32', 'linux_x86_64'"""
|
| 66 |
+
result = sysconfig.get_platform()
|
| 67 |
+
if result.startswith("macosx") and archive_root is not None: # pragma: no cover
|
| 68 |
+
from wheel.macosx_libfile import calculate_macosx_platform_tag
|
| 69 |
+
|
| 70 |
+
result = calculate_macosx_platform_tag(archive_root, result)
|
| 71 |
+
elif _is_32bit_interpreter():
|
| 72 |
+
if result == "linux-x86_64":
|
| 73 |
+
# pip pull request #3497
|
| 74 |
+
result = "linux-i686"
|
| 75 |
+
elif result == "linux-aarch64":
|
| 76 |
+
# packaging pull request #234
|
| 77 |
+
# TODO armv8l, packaging pull request #690 => this did not land
|
| 78 |
+
# in pip/packaging yet
|
| 79 |
+
result = "linux-armv7l"
|
| 80 |
+
|
| 81 |
+
return result.replace("-", "_")
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def get_flag(
|
| 85 |
+
var: str, fallback: bool, expected: bool = True, warn: bool = True
|
| 86 |
+
) -> bool:
|
| 87 |
+
"""Use a fallback value for determining SOABI flags if the needed config
|
| 88 |
+
var is unset or unavailable."""
|
| 89 |
+
val = sysconfig.get_config_var(var)
|
| 90 |
+
if val is None:
|
| 91 |
+
if warn:
|
| 92 |
+
warnings.warn(
|
| 93 |
+
f"Config variable '{var}' is unset, Python ABI tag may be incorrect",
|
| 94 |
+
RuntimeWarning,
|
| 95 |
+
stacklevel=2,
|
| 96 |
+
)
|
| 97 |
+
return fallback
|
| 98 |
+
return val == expected
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def get_abi_tag() -> str | None:
|
| 102 |
+
"""Return the ABI tag based on SOABI (if available) or emulate SOABI (PyPy2)."""
|
| 103 |
+
soabi: str = sysconfig.get_config_var("SOABI")
|
| 104 |
+
impl = tags.interpreter_name()
|
| 105 |
+
if not soabi and impl in ("cp", "pp") and hasattr(sys, "maxunicode"):
|
| 106 |
+
d = ""
|
| 107 |
+
u = ""
|
| 108 |
+
if get_flag("Py_DEBUG", hasattr(sys, "gettotalrefcount"), warn=(impl == "cp")):
|
| 109 |
+
d = "d"
|
| 110 |
+
|
| 111 |
+
abi = f"{impl}{tags.interpreter_version()}{d}{u}"
|
| 112 |
+
elif soabi and impl == "cp" and soabi.startswith("cpython"):
|
| 113 |
+
# non-Windows
|
| 114 |
+
abi = "cp" + soabi.split("-")[1]
|
| 115 |
+
elif soabi and impl == "cp" and soabi.startswith("cp"):
|
| 116 |
+
# Windows
|
| 117 |
+
abi = soabi.split("-")[0]
|
| 118 |
+
if hasattr(sys, "gettotalrefcount"):
|
| 119 |
+
# using debug build; append "d" flag
|
| 120 |
+
abi += "d"
|
| 121 |
+
elif soabi and impl == "pp":
|
| 122 |
+
# we want something like pypy36-pp73
|
| 123 |
+
abi = "-".join(soabi.split("-")[:2])
|
| 124 |
+
abi = abi.replace(".", "_").replace("-", "_")
|
| 125 |
+
elif soabi and impl == "graalpy":
|
| 126 |
+
abi = "-".join(soabi.split("-")[:3])
|
| 127 |
+
abi = abi.replace(".", "_").replace("-", "_")
|
| 128 |
+
elif soabi:
|
| 129 |
+
abi = soabi.replace(".", "_").replace("-", "_")
|
| 130 |
+
else:
|
| 131 |
+
abi = None
|
| 132 |
+
|
| 133 |
+
return abi
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def safer_name(name: str) -> str:
|
| 137 |
+
return safe_name(name).replace("-", "_")
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def safer_version(version: str) -> str:
|
| 141 |
+
return safe_version(version).replace("-", "_")
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
class bdist_wheel(Command):
|
| 145 |
+
description = "create a wheel distribution"
|
| 146 |
+
|
| 147 |
+
supported_compressions = {
|
| 148 |
+
"stored": ZIP_STORED,
|
| 149 |
+
"deflated": ZIP_DEFLATED,
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
user_options = [
|
| 153 |
+
("bdist-dir=", "b", "temporary directory for creating the distribution"),
|
| 154 |
+
(
|
| 155 |
+
"plat-name=",
|
| 156 |
+
"p",
|
| 157 |
+
"platform name to embed in generated filenames "
|
| 158 |
+
f"[default: {get_platform(None)}]",
|
| 159 |
+
),
|
| 160 |
+
(
|
| 161 |
+
"keep-temp",
|
| 162 |
+
"k",
|
| 163 |
+
"keep the pseudo-installation tree around after "
|
| 164 |
+
"creating the distribution archive",
|
| 165 |
+
),
|
| 166 |
+
("dist-dir=", "d", "directory to put final built distributions in"),
|
| 167 |
+
("skip-build", None, "skip rebuilding everything (for testing/debugging)"),
|
| 168 |
+
(
|
| 169 |
+
"relative",
|
| 170 |
+
None,
|
| 171 |
+
"build the archive using relative paths [default: false]",
|
| 172 |
+
),
|
| 173 |
+
(
|
| 174 |
+
"owner=",
|
| 175 |
+
"u",
|
| 176 |
+
"Owner name used when creating a tar file [default: current user]",
|
| 177 |
+
),
|
| 178 |
+
(
|
| 179 |
+
"group=",
|
| 180 |
+
"g",
|
| 181 |
+
"Group name used when creating a tar file [default: current group]",
|
| 182 |
+
),
|
| 183 |
+
("universal", None, "*DEPRECATED* make a universal wheel [default: false]"),
|
| 184 |
+
(
|
| 185 |
+
"compression=",
|
| 186 |
+
None,
|
| 187 |
+
f"zipfile compression (one of: {', '.join(supported_compressions)}) [default: 'deflated']",
|
| 188 |
+
),
|
| 189 |
+
(
|
| 190 |
+
"python-tag=",
|
| 191 |
+
None,
|
| 192 |
+
f"Python implementation compatibility tag [default: '{python_tag()}']",
|
| 193 |
+
),
|
| 194 |
+
(
|
| 195 |
+
"build-number=",
|
| 196 |
+
None,
|
| 197 |
+
"Build number for this particular version. "
|
| 198 |
+
"As specified in PEP-0427, this must start with a digit. "
|
| 199 |
+
"[default: None]",
|
| 200 |
+
),
|
| 201 |
+
(
|
| 202 |
+
"py-limited-api=",
|
| 203 |
+
None,
|
| 204 |
+
"Python tag (cp32|cp33|cpNN) for abi3 wheel tag [default: false]",
|
| 205 |
+
),
|
| 206 |
+
(
|
| 207 |
+
"dist-info-dir=",
|
| 208 |
+
None,
|
| 209 |
+
"directory where a pre-generated dist-info can be found (e.g. as a "
|
| 210 |
+
"result of calling the PEP517 'prepare_metadata_for_build_wheel' "
|
| 211 |
+
"method)",
|
| 212 |
+
),
|
| 213 |
+
]
|
| 214 |
+
|
| 215 |
+
boolean_options = ["keep-temp", "skip-build", "relative", "universal"]
|
| 216 |
+
|
| 217 |
+
def initialize_options(self) -> None:
|
| 218 |
+
self.bdist_dir: str | None = None
|
| 219 |
+
self.data_dir = ""
|
| 220 |
+
self.plat_name: str | None = None
|
| 221 |
+
self.plat_tag: str | None = None
|
| 222 |
+
self.format = "zip"
|
| 223 |
+
self.keep_temp = False
|
| 224 |
+
self.dist_dir: str | None = None
|
| 225 |
+
self.dist_info_dir = None
|
| 226 |
+
self.egginfo_dir: str | None = None
|
| 227 |
+
self.root_is_pure: bool | None = None
|
| 228 |
+
self.skip_build = False
|
| 229 |
+
self.relative = False
|
| 230 |
+
self.owner = None
|
| 231 |
+
self.group = None
|
| 232 |
+
self.universal = False
|
| 233 |
+
self.compression: str | int = "deflated"
|
| 234 |
+
self.python_tag = python_tag()
|
| 235 |
+
self.build_number: str | None = None
|
| 236 |
+
self.py_limited_api: str | Literal[False] = False
|
| 237 |
+
self.plat_name_supplied = False
|
| 238 |
+
|
| 239 |
+
def finalize_options(self) -> None:
|
| 240 |
+
if not self.bdist_dir:
|
| 241 |
+
bdist_base = self.get_finalized_command("bdist").bdist_base
|
| 242 |
+
self.bdist_dir = os.path.join(bdist_base, "wheel")
|
| 243 |
+
|
| 244 |
+
if self.dist_info_dir is None:
|
| 245 |
+
egg_info = cast(egg_info_cls, self.distribution.get_command_obj("egg_info"))
|
| 246 |
+
egg_info.ensure_finalized() # needed for correct `wheel_dist_name`
|
| 247 |
+
|
| 248 |
+
self.data_dir = self.wheel_dist_name + ".data"
|
| 249 |
+
self.plat_name_supplied = bool(self.plat_name)
|
| 250 |
+
|
| 251 |
+
need_options = ("dist_dir", "plat_name", "skip_build")
|
| 252 |
+
|
| 253 |
+
self.set_undefined_options("bdist", *zip(need_options, need_options))
|
| 254 |
+
|
| 255 |
+
self.root_is_pure = not (
|
| 256 |
+
self.distribution.has_ext_modules() or self.distribution.has_c_libraries()
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
self._validate_py_limited_api()
|
| 260 |
+
|
| 261 |
+
# Support legacy [wheel] section for setting universal
|
| 262 |
+
wheel = self.distribution.get_option_dict("wheel")
|
| 263 |
+
if "universal" in wheel: # pragma: no cover
|
| 264 |
+
# please don't define this in your global configs
|
| 265 |
+
log.warn("The [wheel] section is deprecated. Use [bdist_wheel] instead.")
|
| 266 |
+
val = wheel["universal"][1].strip()
|
| 267 |
+
if val.lower() in ("1", "true", "yes"):
|
| 268 |
+
self.universal = True
|
| 269 |
+
|
| 270 |
+
if self.universal:
|
| 271 |
+
SetuptoolsDeprecationWarning.emit(
|
| 272 |
+
"bdist_wheel.universal is deprecated",
|
| 273 |
+
"""
|
| 274 |
+
With Python 2.7 end-of-life, support for building universal wheels
|
| 275 |
+
(i.e., wheels that support both Python 2 and Python 3)
|
| 276 |
+
is being obviated.
|
| 277 |
+
Please discontinue using this option, or if you still need it,
|
| 278 |
+
file an issue with pypa/setuptools describing your use case.
|
| 279 |
+
""",
|
| 280 |
+
due_date=(2025, 8, 30), # Introduced in 2024-08-30
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
if self.build_number is not None and not self.build_number[:1].isdigit():
|
| 284 |
+
raise ValueError("Build tag (build-number) must start with a digit.")
|
| 285 |
+
|
| 286 |
+
def _validate_py_limited_api(self) -> None:
|
| 287 |
+
if not self.py_limited_api:
|
| 288 |
+
return
|
| 289 |
+
|
| 290 |
+
if not re.match(PY_LIMITED_API_PATTERN, self.py_limited_api):
|
| 291 |
+
raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'")
|
| 292 |
+
|
| 293 |
+
if sysconfig.get_config_var("Py_GIL_DISABLED"):
|
| 294 |
+
raise ValueError(
|
| 295 |
+
f"`py_limited_api={self.py_limited_api!r}` not supported. "
|
| 296 |
+
"`Py_LIMITED_API` is currently incompatible with "
|
| 297 |
+
f"`Py_GIL_DISABLED` ({sys.abiflags=!r}). "
|
| 298 |
+
"See https://github.com/python/cpython/issues/111506."
|
| 299 |
+
)
|
| 300 |
+
|
| 301 |
+
@property
|
| 302 |
+
def wheel_dist_name(self) -> str:
|
| 303 |
+
"""Return distribution full name with - replaced with _"""
|
| 304 |
+
components = [
|
| 305 |
+
safer_name(self.distribution.get_name()),
|
| 306 |
+
safer_version(self.distribution.get_version()),
|
| 307 |
+
]
|
| 308 |
+
if self.build_number:
|
| 309 |
+
components.append(self.build_number)
|
| 310 |
+
return "-".join(components)
|
| 311 |
+
|
| 312 |
+
def get_tag(self) -> tuple[str, str, str]:
|
| 313 |
+
# bdist sets self.plat_name if unset, we should only use it for purepy
|
| 314 |
+
# wheels if the user supplied it.
|
| 315 |
+
if self.plat_name_supplied and self.plat_name:
|
| 316 |
+
plat_name = self.plat_name
|
| 317 |
+
elif self.root_is_pure:
|
| 318 |
+
plat_name = "any"
|
| 319 |
+
else:
|
| 320 |
+
# macosx contains system version in platform name so need special handle
|
| 321 |
+
if self.plat_name and not self.plat_name.startswith("macosx"):
|
| 322 |
+
plat_name = self.plat_name
|
| 323 |
+
else:
|
| 324 |
+
# on macosx always limit the platform name to comply with any
|
| 325 |
+
# c-extension modules in bdist_dir, since the user can specify
|
| 326 |
+
# a higher MACOSX_DEPLOYMENT_TARGET via tools like CMake
|
| 327 |
+
|
| 328 |
+
# on other platforms, and on macosx if there are no c-extension
|
| 329 |
+
# modules, use the default platform name.
|
| 330 |
+
plat_name = get_platform(self.bdist_dir)
|
| 331 |
+
|
| 332 |
+
if _is_32bit_interpreter():
|
| 333 |
+
if plat_name in ("linux-x86_64", "linux_x86_64"):
|
| 334 |
+
plat_name = "linux_i686"
|
| 335 |
+
if plat_name in ("linux-aarch64", "linux_aarch64"):
|
| 336 |
+
# TODO armv8l, packaging pull request #690 => this did not land
|
| 337 |
+
# in pip/packaging yet
|
| 338 |
+
plat_name = "linux_armv7l"
|
| 339 |
+
|
| 340 |
+
plat_name = (
|
| 341 |
+
plat_name.lower().replace("-", "_").replace(".", "_").replace(" ", "_")
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
if self.root_is_pure:
|
| 345 |
+
if self.universal:
|
| 346 |
+
impl = "py2.py3"
|
| 347 |
+
else:
|
| 348 |
+
impl = self.python_tag
|
| 349 |
+
tag = (impl, "none", plat_name)
|
| 350 |
+
else:
|
| 351 |
+
impl_name = tags.interpreter_name()
|
| 352 |
+
impl_ver = tags.interpreter_version()
|
| 353 |
+
impl = impl_name + impl_ver
|
| 354 |
+
# We don't work on CPython 3.1, 3.0.
|
| 355 |
+
if self.py_limited_api and (impl_name + impl_ver).startswith("cp3"):
|
| 356 |
+
impl = self.py_limited_api
|
| 357 |
+
abi_tag = "abi3"
|
| 358 |
+
else:
|
| 359 |
+
abi_tag = str(get_abi_tag()).lower()
|
| 360 |
+
tag = (impl, abi_tag, plat_name)
|
| 361 |
+
# issue gh-374: allow overriding plat_name
|
| 362 |
+
supported_tags = [
|
| 363 |
+
(t.interpreter, t.abi, plat_name) for t in tags.sys_tags()
|
| 364 |
+
]
|
| 365 |
+
assert tag in supported_tags, (
|
| 366 |
+
f"would build wheel with unsupported tag {tag}"
|
| 367 |
+
)
|
| 368 |
+
return tag
|
| 369 |
+
|
| 370 |
+
def run(self):
|
| 371 |
+
build_scripts = self.reinitialize_command("build_scripts")
|
| 372 |
+
build_scripts.executable = "python"
|
| 373 |
+
build_scripts.force = True
|
| 374 |
+
|
| 375 |
+
build_ext = self.reinitialize_command("build_ext")
|
| 376 |
+
build_ext.inplace = False
|
| 377 |
+
|
| 378 |
+
if not self.skip_build:
|
| 379 |
+
self.run_command("build")
|
| 380 |
+
|
| 381 |
+
install = self.reinitialize_command("install", reinit_subcommands=True)
|
| 382 |
+
install.root = self.bdist_dir
|
| 383 |
+
install.compile = False
|
| 384 |
+
install.skip_build = self.skip_build
|
| 385 |
+
install.warn_dir = False
|
| 386 |
+
|
| 387 |
+
# A wheel without setuptools scripts is more cross-platform.
|
| 388 |
+
# Use the (undocumented) `no_ep` option to setuptools'
|
| 389 |
+
# install_scripts command to avoid creating entry point scripts.
|
| 390 |
+
install_scripts = self.reinitialize_command("install_scripts")
|
| 391 |
+
install_scripts.no_ep = True
|
| 392 |
+
|
| 393 |
+
# Use a custom scheme for the archive, because we have to decide
|
| 394 |
+
# at installation time which scheme to use.
|
| 395 |
+
for key in ("headers", "scripts", "data", "purelib", "platlib"):
|
| 396 |
+
setattr(install, "install_" + key, os.path.join(self.data_dir, key))
|
| 397 |
+
|
| 398 |
+
basedir_observed = ""
|
| 399 |
+
|
| 400 |
+
if os.name == "nt":
|
| 401 |
+
# win32 barfs if any of these are ''; could be '.'?
|
| 402 |
+
# (distutils.command.install:change_roots bug)
|
| 403 |
+
basedir_observed = os.path.normpath(os.path.join(self.data_dir, ".."))
|
| 404 |
+
self.install_libbase = self.install_lib = basedir_observed
|
| 405 |
+
|
| 406 |
+
setattr(
|
| 407 |
+
install,
|
| 408 |
+
"install_purelib" if self.root_is_pure else "install_platlib",
|
| 409 |
+
basedir_observed,
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
log.info(f"installing to {self.bdist_dir}")
|
| 413 |
+
|
| 414 |
+
self.run_command("install")
|
| 415 |
+
|
| 416 |
+
impl_tag, abi_tag, plat_tag = self.get_tag()
|
| 417 |
+
archive_basename = f"{self.wheel_dist_name}-{impl_tag}-{abi_tag}-{plat_tag}"
|
| 418 |
+
if not self.relative:
|
| 419 |
+
archive_root = self.bdist_dir
|
| 420 |
+
else:
|
| 421 |
+
archive_root = os.path.join(
|
| 422 |
+
self.bdist_dir, self._ensure_relative(install.install_base)
|
| 423 |
+
)
|
| 424 |
+
|
| 425 |
+
self.set_undefined_options("install_egg_info", ("target", "egginfo_dir"))
|
| 426 |
+
distinfo_dirname = (
|
| 427 |
+
f"{safer_name(self.distribution.get_name())}-"
|
| 428 |
+
f"{safer_version(self.distribution.get_version())}.dist-info"
|
| 429 |
+
)
|
| 430 |
+
distinfo_dir = os.path.join(self.bdist_dir, distinfo_dirname)
|
| 431 |
+
if self.dist_info_dir:
|
| 432 |
+
# Use the given dist-info directly.
|
| 433 |
+
log.debug(f"reusing {self.dist_info_dir}")
|
| 434 |
+
shutil.copytree(self.dist_info_dir, distinfo_dir)
|
| 435 |
+
# Egg info is still generated, so remove it now to avoid it getting
|
| 436 |
+
# copied into the wheel.
|
| 437 |
+
_shutil.rmtree(self.egginfo_dir)
|
| 438 |
+
else:
|
| 439 |
+
# Convert the generated egg-info into dist-info.
|
| 440 |
+
self.egg2dist(self.egginfo_dir, distinfo_dir)
|
| 441 |
+
|
| 442 |
+
self.write_wheelfile(distinfo_dir)
|
| 443 |
+
|
| 444 |
+
# Make the archive
|
| 445 |
+
if not os.path.exists(self.dist_dir):
|
| 446 |
+
os.makedirs(self.dist_dir)
|
| 447 |
+
|
| 448 |
+
wheel_path = os.path.join(self.dist_dir, archive_basename + ".whl")
|
| 449 |
+
with WheelFile(wheel_path, "w", self._zip_compression()) as wf:
|
| 450 |
+
wf.write_files(archive_root)
|
| 451 |
+
|
| 452 |
+
# Add to 'Distribution.dist_files' so that the "upload" command works
|
| 453 |
+
getattr(self.distribution, "dist_files", []).append((
|
| 454 |
+
"bdist_wheel",
|
| 455 |
+
f"{sys.version_info.major}.{sys.version_info.minor}",
|
| 456 |
+
wheel_path,
|
| 457 |
+
))
|
| 458 |
+
|
| 459 |
+
if not self.keep_temp:
|
| 460 |
+
log.info(f"removing {self.bdist_dir}")
|
| 461 |
+
if not self.dry_run:
|
| 462 |
+
_shutil.rmtree(self.bdist_dir)
|
| 463 |
+
|
| 464 |
+
def write_wheelfile(
|
| 465 |
+
self, wheelfile_base: str, generator: str = f"setuptools ({__version__})"
|
| 466 |
+
) -> None:
|
| 467 |
+
from email.message import Message
|
| 468 |
+
|
| 469 |
+
msg = Message()
|
| 470 |
+
msg["Wheel-Version"] = "1.0" # of the spec
|
| 471 |
+
msg["Generator"] = generator
|
| 472 |
+
msg["Root-Is-Purelib"] = str(self.root_is_pure).lower()
|
| 473 |
+
if self.build_number is not None:
|
| 474 |
+
msg["Build"] = self.build_number
|
| 475 |
+
|
| 476 |
+
# Doesn't work for bdist_wininst
|
| 477 |
+
impl_tag, abi_tag, plat_tag = self.get_tag()
|
| 478 |
+
for impl in impl_tag.split("."):
|
| 479 |
+
for abi in abi_tag.split("."):
|
| 480 |
+
for plat in plat_tag.split("."):
|
| 481 |
+
msg["Tag"] = "-".join((impl, abi, plat))
|
| 482 |
+
|
| 483 |
+
wheelfile_path = os.path.join(wheelfile_base, "WHEEL")
|
| 484 |
+
log.info(f"creating {wheelfile_path}")
|
| 485 |
+
with open(wheelfile_path, "wb") as f:
|
| 486 |
+
BytesGenerator(f, maxheaderlen=0).flatten(msg)
|
| 487 |
+
|
| 488 |
+
def _ensure_relative(self, path: str) -> str:
|
| 489 |
+
# copied from dir_util, deleted
|
| 490 |
+
drive, path = os.path.splitdrive(path)
|
| 491 |
+
if path[0:1] == os.sep:
|
| 492 |
+
path = drive + path[1:]
|
| 493 |
+
return path
|
| 494 |
+
|
| 495 |
+
@property
|
| 496 |
+
def license_paths(self) -> Iterable[str]:
|
| 497 |
+
if setuptools_major_version >= 57:
|
| 498 |
+
# Setuptools has resolved any patterns to actual file names
|
| 499 |
+
return self.distribution.metadata.license_files or ()
|
| 500 |
+
|
| 501 |
+
files = set[str]()
|
| 502 |
+
metadata = self.distribution.get_option_dict("metadata")
|
| 503 |
+
if setuptools_major_version >= 42:
|
| 504 |
+
# Setuptools recognizes the license_files option but does not do globbing
|
| 505 |
+
patterns = cast(Sequence[str], self.distribution.metadata.license_files)
|
| 506 |
+
else:
|
| 507 |
+
# Prior to those, wheel is entirely responsible for handling license files
|
| 508 |
+
if "license_files" in metadata:
|
| 509 |
+
patterns = metadata["license_files"][1].split()
|
| 510 |
+
else:
|
| 511 |
+
patterns = ()
|
| 512 |
+
|
| 513 |
+
if "license_file" in metadata:
|
| 514 |
+
warnings.warn(
|
| 515 |
+
'The "license_file" option is deprecated. Use "license_files" instead.',
|
| 516 |
+
DeprecationWarning,
|
| 517 |
+
stacklevel=2,
|
| 518 |
+
)
|
| 519 |
+
files.add(metadata["license_file"][1])
|
| 520 |
+
|
| 521 |
+
if not files and not patterns and not isinstance(patterns, list):
|
| 522 |
+
patterns = ("LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*")
|
| 523 |
+
|
| 524 |
+
for pattern in patterns:
|
| 525 |
+
for path in iglob(pattern):
|
| 526 |
+
if path.endswith("~"):
|
| 527 |
+
log.debug(
|
| 528 |
+
f'ignoring license file "{path}" as it looks like a backup'
|
| 529 |
+
)
|
| 530 |
+
continue
|
| 531 |
+
|
| 532 |
+
if path not in files and os.path.isfile(path):
|
| 533 |
+
log.info(
|
| 534 |
+
f'adding license file "{path}" (matched pattern "{pattern}")'
|
| 535 |
+
)
|
| 536 |
+
files.add(path)
|
| 537 |
+
|
| 538 |
+
return files
|
| 539 |
+
|
| 540 |
+
def egg2dist(self, egginfo_path: str, distinfo_path: str) -> None:
|
| 541 |
+
"""Convert an .egg-info directory into a .dist-info directory"""
|
| 542 |
+
|
| 543 |
+
def adios(p: str) -> None:
|
| 544 |
+
"""Appropriately delete directory, file or link."""
|
| 545 |
+
if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p):
|
| 546 |
+
_shutil.rmtree(p)
|
| 547 |
+
elif os.path.exists(p):
|
| 548 |
+
os.unlink(p)
|
| 549 |
+
|
| 550 |
+
adios(distinfo_path)
|
| 551 |
+
|
| 552 |
+
if not os.path.exists(egginfo_path):
|
| 553 |
+
# There is no egg-info. This is probably because the egg-info
|
| 554 |
+
# file/directory is not named matching the distribution name used
|
| 555 |
+
# to name the archive file. Check for this case and report
|
| 556 |
+
# accordingly.
|
| 557 |
+
import glob
|
| 558 |
+
|
| 559 |
+
pat = os.path.join(os.path.dirname(egginfo_path), "*.egg-info")
|
| 560 |
+
possible = glob.glob(pat)
|
| 561 |
+
err = f"Egg metadata expected at {egginfo_path} but not found"
|
| 562 |
+
if possible:
|
| 563 |
+
alt = os.path.basename(possible[0])
|
| 564 |
+
err += f" ({alt} found - possible misnamed archive file?)"
|
| 565 |
+
|
| 566 |
+
raise ValueError(err)
|
| 567 |
+
|
| 568 |
+
# .egg-info is a directory
|
| 569 |
+
pkginfo_path = os.path.join(egginfo_path, "PKG-INFO")
|
| 570 |
+
|
| 571 |
+
# ignore common egg metadata that is useless to wheel
|
| 572 |
+
shutil.copytree(
|
| 573 |
+
egginfo_path,
|
| 574 |
+
distinfo_path,
|
| 575 |
+
ignore=lambda x, y: {
|
| 576 |
+
"PKG-INFO",
|
| 577 |
+
"requires.txt",
|
| 578 |
+
"SOURCES.txt",
|
| 579 |
+
"not-zip-safe",
|
| 580 |
+
},
|
| 581 |
+
)
|
| 582 |
+
|
| 583 |
+
# delete dependency_links if it is only whitespace
|
| 584 |
+
dependency_links_path = os.path.join(distinfo_path, "dependency_links.txt")
|
| 585 |
+
with open(dependency_links_path, encoding="utf-8") as dependency_links_file:
|
| 586 |
+
dependency_links = dependency_links_file.read().strip()
|
| 587 |
+
if not dependency_links:
|
| 588 |
+
adios(dependency_links_path)
|
| 589 |
+
|
| 590 |
+
metadata_path = os.path.join(distinfo_path, "METADATA")
|
| 591 |
+
shutil.copy(pkginfo_path, metadata_path)
|
| 592 |
+
|
| 593 |
+
for license_path in self.license_paths:
|
| 594 |
+
filename = os.path.basename(license_path)
|
| 595 |
+
shutil.copy(license_path, os.path.join(distinfo_path, filename))
|
| 596 |
+
|
| 597 |
+
adios(egginfo_path)
|
| 598 |
+
|
| 599 |
+
def _zip_compression(self) -> int:
|
| 600 |
+
if (
|
| 601 |
+
isinstance(self.compression, int)
|
| 602 |
+
and self.compression in self.supported_compressions.values()
|
| 603 |
+
):
|
| 604 |
+
return self.compression
|
| 605 |
+
|
| 606 |
+
compression = self.supported_compressions.get(str(self.compression))
|
| 607 |
+
if compression is not None:
|
| 608 |
+
return compression
|
| 609 |
+
|
| 610 |
+
raise ValueError(f"Unsupported compression: {self.compression!r}")
|
phi4/lib/python3.10/site-packages/setuptools/command/build.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import Protocol
|
| 4 |
+
|
| 5 |
+
from ..dist import Distribution
|
| 6 |
+
|
| 7 |
+
from distutils.command.build import build as _build
|
| 8 |
+
|
| 9 |
+
_ORIGINAL_SUBCOMMANDS = {"build_py", "build_clib", "build_ext", "build_scripts"}
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class build(_build):
|
| 13 |
+
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
| 14 |
+
|
| 15 |
+
# copy to avoid sharing the object with parent class
|
| 16 |
+
sub_commands = _build.sub_commands[:]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class SubCommand(Protocol):
|
| 20 |
+
"""In order to support editable installations (see :pep:`660`) all
|
| 21 |
+
build subcommands **SHOULD** implement this protocol. They also **MUST** inherit
|
| 22 |
+
from ``setuptools.Command``.
|
| 23 |
+
|
| 24 |
+
When creating an :pep:`editable wheel <660>`, ``setuptools`` will try to evaluate
|
| 25 |
+
custom ``build`` subcommands using the following procedure:
|
| 26 |
+
|
| 27 |
+
1. ``setuptools`` will set the ``editable_mode`` attribute to ``True``
|
| 28 |
+
2. ``setuptools`` will execute the ``run()`` command.
|
| 29 |
+
|
| 30 |
+
.. important::
|
| 31 |
+
Subcommands **SHOULD** take advantage of ``editable_mode=True`` to adequate
|
| 32 |
+
its behaviour or perform optimisations.
|
| 33 |
+
|
| 34 |
+
For example, if a subcommand doesn't need to generate an extra file and
|
| 35 |
+
all it does is to copy a source file into the build directory,
|
| 36 |
+
``run()`` **SHOULD** simply "early return".
|
| 37 |
+
|
| 38 |
+
Similarly, if the subcommand creates files that would be placed alongside
|
| 39 |
+
Python files in the final distribution, during an editable install
|
| 40 |
+
the command **SHOULD** generate these files "in place" (i.e. write them to
|
| 41 |
+
the original source directory, instead of using the build directory).
|
| 42 |
+
Note that ``get_output_mapping()`` should reflect that and include mappings
|
| 43 |
+
for "in place" builds accordingly.
|
| 44 |
+
|
| 45 |
+
3. ``setuptools`` use any knowledge it can derive from the return values of
|
| 46 |
+
``get_outputs()`` and ``get_output_mapping()`` to create an editable wheel.
|
| 47 |
+
When relevant ``setuptools`` **MAY** attempt to use file links based on the value
|
| 48 |
+
of ``get_output_mapping()``. Alternatively, ``setuptools`` **MAY** attempt to use
|
| 49 |
+
:doc:`import hooks <python:reference/import>` to redirect any attempt to import
|
| 50 |
+
to the directory with the original source code and other files built in place.
|
| 51 |
+
|
| 52 |
+
Please note that custom sub-commands **SHOULD NOT** rely on ``run()`` being
|
| 53 |
+
executed (or not) to provide correct return values for ``get_outputs()``,
|
| 54 |
+
``get_output_mapping()`` or ``get_source_files()``. The ``get_*`` methods should
|
| 55 |
+
work independently of ``run()``.
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
editable_mode: bool = False
|
| 59 |
+
"""Boolean flag that will be set to ``True`` when setuptools is used for an
|
| 60 |
+
editable installation (see :pep:`660`).
|
| 61 |
+
Implementations **SHOULD** explicitly set the default value of this attribute to
|
| 62 |
+
``False``.
|
| 63 |
+
When subcommands run, they can use this flag to perform optimizations or change
|
| 64 |
+
their behaviour accordingly.
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
build_lib: str
|
| 68 |
+
"""String representing the directory where the build artifacts should be stored,
|
| 69 |
+
e.g. ``build/lib``.
|
| 70 |
+
For example, if a distribution wants to provide a Python module named ``pkg.mod``,
|
| 71 |
+
then a corresponding file should be written to ``{build_lib}/package/module.py``.
|
| 72 |
+
A way of thinking about this is that the files saved under ``build_lib``
|
| 73 |
+
would be eventually copied to one of the directories in :obj:`site.PREFIXES`
|
| 74 |
+
upon installation.
|
| 75 |
+
|
| 76 |
+
A command that produces platform-independent files (e.g. compiling text templates
|
| 77 |
+
into Python functions), **CAN** initialize ``build_lib`` by copying its value from
|
| 78 |
+
the ``build_py`` command. On the other hand, a command that produces
|
| 79 |
+
platform-specific files **CAN** initialize ``build_lib`` by copying its value from
|
| 80 |
+
the ``build_ext`` command. In general this is done inside the ``finalize_options``
|
| 81 |
+
method with the help of the ``set_undefined_options`` command::
|
| 82 |
+
|
| 83 |
+
def finalize_options(self):
|
| 84 |
+
self.set_undefined_options("build_py", ("build_lib", "build_lib"))
|
| 85 |
+
...
|
| 86 |
+
"""
|
| 87 |
+
|
| 88 |
+
def initialize_options(self) -> None:
|
| 89 |
+
"""(Required by the original :class:`setuptools.Command` interface)"""
|
| 90 |
+
...
|
| 91 |
+
|
| 92 |
+
def finalize_options(self) -> None:
|
| 93 |
+
"""(Required by the original :class:`setuptools.Command` interface)"""
|
| 94 |
+
...
|
| 95 |
+
|
| 96 |
+
def run(self) -> None:
|
| 97 |
+
"""(Required by the original :class:`setuptools.Command` interface)"""
|
| 98 |
+
...
|
| 99 |
+
|
| 100 |
+
def get_source_files(self) -> list[str]:
|
| 101 |
+
"""
|
| 102 |
+
Return a list of all files that are used by the command to create the expected
|
| 103 |
+
outputs.
|
| 104 |
+
For example, if your build command transpiles Java files into Python, you should
|
| 105 |
+
list here all the Java files.
|
| 106 |
+
The primary purpose of this function is to help populating the ``sdist``
|
| 107 |
+
with all the files necessary to build the distribution.
|
| 108 |
+
All files should be strings relative to the project root directory.
|
| 109 |
+
"""
|
| 110 |
+
...
|
| 111 |
+
|
| 112 |
+
def get_outputs(self) -> list[str]:
|
| 113 |
+
"""
|
| 114 |
+
Return a list of files intended for distribution as they would have been
|
| 115 |
+
produced by the build.
|
| 116 |
+
These files should be strings in the form of
|
| 117 |
+
``"{build_lib}/destination/file/path"``.
|
| 118 |
+
|
| 119 |
+
.. note::
|
| 120 |
+
The return value of ``get_output()`` should include all files used as keys
|
| 121 |
+
in ``get_output_mapping()`` plus files that are generated during the build
|
| 122 |
+
and don't correspond to any source file already present in the project.
|
| 123 |
+
"""
|
| 124 |
+
...
|
| 125 |
+
|
| 126 |
+
def get_output_mapping(self) -> dict[str, str]:
|
| 127 |
+
"""
|
| 128 |
+
Return a mapping between destination files as they would be produced by the
|
| 129 |
+
build (dict keys) into the respective existing (source) files (dict values).
|
| 130 |
+
Existing (source) files should be represented as strings relative to the project
|
| 131 |
+
root directory.
|
| 132 |
+
Destination files should be strings in the form of
|
| 133 |
+
``"{build_lib}/destination/file/path"``.
|
| 134 |
+
"""
|
| 135 |
+
...
|
phi4/lib/python3.10/site-packages/setuptools/command/build_clib.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..dist import Distribution
|
| 2 |
+
from ..modified import newer_pairwise_group
|
| 3 |
+
|
| 4 |
+
import distutils.command.build_clib as orig
|
| 5 |
+
from distutils import log
|
| 6 |
+
from distutils.errors import DistutilsSetupError
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class build_clib(orig.build_clib):
|
| 10 |
+
"""
|
| 11 |
+
Override the default build_clib behaviour to do the following:
|
| 12 |
+
|
| 13 |
+
1. Implement a rudimentary timestamp-based dependency system
|
| 14 |
+
so 'compile()' doesn't run every time.
|
| 15 |
+
2. Add more keys to the 'build_info' dictionary:
|
| 16 |
+
* obj_deps - specify dependencies for each object compiled.
|
| 17 |
+
this should be a dictionary mapping a key
|
| 18 |
+
with the source filename to a list of
|
| 19 |
+
dependencies. Use an empty string for global
|
| 20 |
+
dependencies.
|
| 21 |
+
* cflags - specify a list of additional flags to pass to
|
| 22 |
+
the compiler.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
|
| 26 |
+
|
| 27 |
+
def build_libraries(self, libraries) -> None:
|
| 28 |
+
for lib_name, build_info in libraries:
|
| 29 |
+
sources = build_info.get('sources')
|
| 30 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
| 31 |
+
raise DistutilsSetupError(
|
| 32 |
+
f"in 'libraries' option (library '{lib_name}'), "
|
| 33 |
+
"'sources' must be present and must be "
|
| 34 |
+
"a list of source filenames"
|
| 35 |
+
)
|
| 36 |
+
sources = sorted(list(sources))
|
| 37 |
+
|
| 38 |
+
log.info("building '%s' library", lib_name)
|
| 39 |
+
|
| 40 |
+
# Make sure everything is the correct type.
|
| 41 |
+
# obj_deps should be a dictionary of keys as sources
|
| 42 |
+
# and a list/tuple of files that are its dependencies.
|
| 43 |
+
obj_deps = build_info.get('obj_deps', dict())
|
| 44 |
+
if not isinstance(obj_deps, dict):
|
| 45 |
+
raise DistutilsSetupError(
|
| 46 |
+
f"in 'libraries' option (library '{lib_name}'), "
|
| 47 |
+
"'obj_deps' must be a dictionary of "
|
| 48 |
+
"type 'source: list'"
|
| 49 |
+
)
|
| 50 |
+
dependencies = []
|
| 51 |
+
|
| 52 |
+
# Get the global dependencies that are specified by the '' key.
|
| 53 |
+
# These will go into every source's dependency list.
|
| 54 |
+
global_deps = obj_deps.get('', list())
|
| 55 |
+
if not isinstance(global_deps, (list, tuple)):
|
| 56 |
+
raise DistutilsSetupError(
|
| 57 |
+
f"in 'libraries' option (library '{lib_name}'), "
|
| 58 |
+
"'obj_deps' must be a dictionary of "
|
| 59 |
+
"type 'source: list'"
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# Build the list to be used by newer_pairwise_group
|
| 63 |
+
# each source will be auto-added to its dependencies.
|
| 64 |
+
for source in sources:
|
| 65 |
+
src_deps = [source]
|
| 66 |
+
src_deps.extend(global_deps)
|
| 67 |
+
extra_deps = obj_deps.get(source, list())
|
| 68 |
+
if not isinstance(extra_deps, (list, tuple)):
|
| 69 |
+
raise DistutilsSetupError(
|
| 70 |
+
f"in 'libraries' option (library '{lib_name}'), "
|
| 71 |
+
"'obj_deps' must be a dictionary of "
|
| 72 |
+
"type 'source: list'"
|
| 73 |
+
)
|
| 74 |
+
src_deps.extend(extra_deps)
|
| 75 |
+
dependencies.append(src_deps)
|
| 76 |
+
|
| 77 |
+
expected_objects = self.compiler.object_filenames(
|
| 78 |
+
sources,
|
| 79 |
+
output_dir=self.build_temp,
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
if newer_pairwise_group(dependencies, expected_objects) != ([], []):
|
| 83 |
+
# First, compile the source code to object files in the library
|
| 84 |
+
# directory. (This should probably change to putting object
|
| 85 |
+
# files in a temporary build directory.)
|
| 86 |
+
macros = build_info.get('macros')
|
| 87 |
+
include_dirs = build_info.get('include_dirs')
|
| 88 |
+
cflags = build_info.get('cflags')
|
| 89 |
+
self.compiler.compile(
|
| 90 |
+
sources,
|
| 91 |
+
output_dir=self.build_temp,
|
| 92 |
+
macros=macros,
|
| 93 |
+
include_dirs=include_dirs,
|
| 94 |
+
extra_postargs=cflags,
|
| 95 |
+
debug=self.debug,
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
# Now "link" the object files together into a static library.
|
| 99 |
+
# (On Unix at least, this isn't really linking -- it just
|
| 100 |
+
# builds an archive. Whatever.)
|
| 101 |
+
self.compiler.create_static_lib(
|
| 102 |
+
expected_objects, lib_name, output_dir=self.build_clib, debug=self.debug
|
| 103 |
+
)
|