This commit is contained in:
lz_db
2026-10-16 22:48:30 +08:00
parent 190de72571
commit 0b36fd3383
3161 changed files with 12787 additions and 77274 deletions
@@ -1,17 +1,11 @@
from __future__ import annotations
import functools
import re
from typing import TYPE_CHECKING
from setuptools._path import StrPath
from .monkey import get_unpatched
import functools
import distutils.core
import distutils.errors
import distutils.extension
from .monkey import get_unpatched
def _have_cython():
"""
@@ -21,18 +15,16 @@ def _have_cython():
try:
# from (cython_impl) import build_ext
__import__(cython_impl, fromlist=['build_ext']).build_ext
return True
except Exception:
return False
return True
pass
return False
# for compatibility
have_pyrex = _have_cython
if TYPE_CHECKING:
# Work around a mypy issue where type[T] can't be used as a base: https://github.com/python/mypy/issues/10962
from distutils.core import Extension as _Extension
else:
_Extension = get_unpatched(distutils.core.Extension)
_Extension = get_unpatched(distutils.core.Extension)
class Extension(_Extension):
@@ -52,7 +44,7 @@ class Extension(_Extension):
the full name of the extension, including any packages -- ie.
*not* a filename or pathname, but Python dotted name
:arg list[str|os.PathLike[str]] sources:
:arg list[str] sources:
list of source filenames, relative to the distribution root
(where the setup script lives), in Unix form (slash-separated)
for portability. Source files may be C, C++, SWIG (.i),
@@ -127,36 +119,15 @@ class Extension(_Extension):
:keyword bool py_limited_api:
opt-in flag for the usage of :doc:`Python's limited API <python:c-api/stable>`.
:raises setuptools.errors.PlatformError: if ``runtime_library_dirs`` is
:raises setuptools.errors.PlatformError: if 'runtime_library_dirs' is
specified on Windows. (since v63)
"""
# These 4 are set and used in setuptools/command/build_ext.py
# The lack of a default value and risk of `AttributeError` is purposeful
# to avoid people forgetting to call finalize_options if they modify the extension list.
# See example/rationale in https://github.com/pypa/setuptools/issues/4529.
_full_name: str #: Private API, internal use only.
_links_to_dynamic: bool #: Private API, internal use only.
_needs_stub: bool #: Private API, internal use only.
_file_name: str #: Private API, internal use only.
def __init__(
self,
name: str,
sources: list[StrPath],
*args,
py_limited_api: bool = False,
**kw,
) -> None:
def __init__(self, name, sources, *args, **kw):
# The *args is needed for compatibility as calls may use positional
# arguments. py_limited_api may be set only via keyword.
self.py_limited_api = py_limited_api
super().__init__(
name,
sources, # type: ignore[arg-type] # Vendored version of setuptools supports PathLike
*args,
**kw,
)
self.py_limited_api = kw.pop("py_limited_api", False)
super().__init__(name, sources, *args, **kw)
def _convert_pyx_sources_to_lang(self):
"""