Skip to content

Commit dd3af1c

Browse files
committed
runtime changes for typeshed merge
1 parent 08bd311 commit dd3af1c

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

newsfragments/xxx.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Changed the order of type checks in ``setuptools.command.easy_install.CommandSpec.from_param`` to support any `collections.abc.Iterable` of `str` param and to always fallback to the environment if the param type is unsupported -- by :user:`Avasam`

setuptools/command/build_ext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import Iterator
99
from pathlib import Path
1010

11-
from distutils.command.build_ext import build_ext as _du_build_ext
1211
from distutils.ccompiler import new_compiler
1312
from distutils.sysconfig import customize_compiler, get_config_var
1413
from distutils import log
@@ -24,7 +23,7 @@
2423
# also. Ref #1229.
2524
__import__('Cython.Compiler.Main')
2625
except ImportError:
27-
_build_ext = _du_build_ext
26+
from distutils.command.build_ext import build_ext as _build_ext
2827

2928
# make sure _config_vars is initialized
3029
get_config_var("LDSHARED")

setuptools/command/easy_install.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from __future__ import annotations
1414

15+
from collections.abc import Iterable
1516
from glob import glob
1617
from distutils.util import get_platform
1718
from distutils.util import convert_path, subst_vars
@@ -26,6 +27,7 @@
2627
from distutils.command import install
2728
import sys
2829
import os
30+
from typing import TYPE_CHECKING
2931
import zipimport
3032
import shutil
3133
import tempfile
@@ -78,6 +80,8 @@
7880
from .._path import ensure_directory
7981
from jaraco.text import yield_lines
8082

83+
if TYPE_CHECKING:
84+
from typing_extensions import Self
8185

8286
# Turn on PEP440Warnings
8387
warnings.filterwarnings("default", category=pkg_resources.PEP440Warning)
@@ -2055,19 +2059,18 @@ def _sys_executable(cls):
20552059
return os.environ.get('__PYVENV_LAUNCHER__', _default)
20562060

20572061
@classmethod
2058-
def from_param(cls, param):
2062+
def from_param(cls, param: Self | str | Iterable[str] | None) -> Self:
20592063
"""
20602064
Construct a CommandSpec from a parameter to build_scripts, which may
20612065
be None.
20622066
"""
20632067
if isinstance(param, cls):
20642068
return param
2065-
if isinstance(param, list):
2069+
if isinstance(param, str):
2070+
return cls.from_string(param)
2071+
if isinstance(param, Iterable):
20662072
return cls(param)
2067-
if param is None:
2068-
return cls.from_environment()
2069-
# otherwise, assume it's a string.
2070-
return cls.from_string(param)
2073+
return cls.from_environment()
20712074

20722075
@classmethod
20732076
def from_environment(cls):

setuptools/dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def assert_string_list(dist, attr, value):
5555
try:
5656
# verify that value is a list or tuple to exclude unordered
5757
# or single-use iterables
58-
assert isinstance(value, (list, tuple))
58+
assert isinstance(value, sequence)
5959
# verify that elements of value are strings
6060
assert ''.join(value) != value
6161
except (TypeError, ValueError, AttributeError, AssertionError) as e:

setuptools/extension.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
import re
23
import functools
34
import distutils.core
@@ -126,10 +127,12 @@ class Extension(_Extension):
126127
specified on Windows. (since v63)
127128
"""
128129

129-
def __init__(self, name, sources, *args, **kw):
130+
def __init__(
131+
self, name: str, sources: list[str], *args, py_limited_api: bool = False, **kw
132+
):
130133
# The *args is needed for compatibility as calls may use positional
131134
# arguments. py_limited_api may be set only via keyword.
132-
self.py_limited_api = kw.pop("py_limited_api", False)
135+
self.py_limited_api = py_limited_api
133136
super().__init__(name, sources, *args, **kw)
134137

135138
def _convert_pyx_sources_to_lang(self):

0 commit comments

Comments
 (0)