Skip to content

Commit 54b8a01

Browse files
authored
deprecation: cp313t (#2787)
Free-Threading Python 3.13 was experimental. Now that Python 3.14 has been released with explicit support, we can schedule removal of Python 3.13 free-threading.
1 parent 097806b commit 54b8a01

6 files changed

Lines changed: 90 additions & 10 deletions

File tree

‎cibuildwheel/__main__.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,7 @@ def print_preamble(platform: str, options: Options, identifiers: Sequence[str])
441441
def detect_errors(*, options: Options, identifiers: Iterable[str]) -> Generator[str, None, None]:
442442
# Check for deprecated CIBW_FREE_THREADED_SUPPORT environment variable
443443
if "CIBW_FREE_THREADED_SUPPORT" in os.environ:
444-
yield (
445-
"CIBW_FREE_THREADED_SUPPORT environment variable is no longer supported. "
446-
'Use tool.cibuildwheel.enable = ["cpython-freethreading"] in pyproject.toml '
447-
"or set CIBW_ENABLE=cpython-freethreading instead."
448-
)
444+
yield "CIBW_FREE_THREADED_SUPPORT environment variable is no longer supported."
449445

450446
# Deprecated {python} and {pip}
451447
for option_name in ["test_command", "before_build"]:
@@ -472,6 +468,13 @@ def detect_warnings(*, options: Options) -> Generator[str, None, None]:
472468
build_selector = options.globals.build_selector
473469
test_selector = options.globals.test_selector
474470

471+
if EnableGroup.CPythonFreeThreading in build_selector.enable:
472+
yield (
473+
"'cpython-freethreading' enable is deprecated and will be removed in a future version. "
474+
"It should be removed from tool.cibuildwheel.enable in pyproject.toml "
475+
"or CIBW_ENABLE environment variable."
476+
)
477+
475478
all_valid_identifiers = [
476479
config.identifier
477480
for module in ALL_PLATFORM_MODULES.values()

‎cibuildwheel/options.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@ def globals(self) -> GlobalOptions:
686686
skip_config = ""
687687
architectures = Architecture.all_archs(self.platform)
688688
enable |= EnableGroup.all_groups()
689+
if args.only.startswith("cp313t-"):
690+
enable.add(EnableGroup.CPythonFreeThreading)
689691

690692
build_selector = BuildSelector(
691693
build_config=build_config,

‎cibuildwheel/selector.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class EnableGroup(StrEnum):
3838

3939
@classmethod
4040
def all_groups(cls) -> frozenset[Self]:
41-
return frozenset(cls)
41+
# see https://github.com/python/mypy/issues/20434 for the reason to type: ignore[arg-type]
42+
return frozenset(set(cls) - {cls.CPythonFreeThreading}) # type: ignore[arg-type]
4243

4344
@classmethod
4445
def parse_option_value(cls, value: str) -> frozenset[Self]:

‎test/test_abi_variants.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_abi3(tmp_path: Path) -> None:
4444
add_env={
4545
# free_threaded, GraalPy, and PyPy do not have a Py_LIMITED_API equivalent, just build one of those
4646
# also limit the number of builds for test performance reasons
47-
"CIBW_BUILD": "cp39-* cp310-* pp310-* gp312_250-* cp312-* cp313t-*",
47+
"CIBW_BUILD": "cp39-* cp310-* pp310-* gp312_250-* cp312-* cp314t-*",
4848
"CIBW_ENABLE": "all",
4949
},
5050
)
@@ -65,7 +65,7 @@ def test_abi3(tmp_path: Path) -> None:
6565
python_abi_tags=[
6666
"cp39-cp39",
6767
"cp310-abi3", # <-- ABI3, works with 3.10 and 3.12
68-
"cp313-cp313t",
68+
"cp314-cp314t",
6969
"pp310-pypy310_pp73",
7070
"graalpy312-graalpy250_312_native",
7171
],
@@ -192,7 +192,7 @@ def test_abi_none(tmp_path: Path, capfd: pytest.CaptureFixture[str]) -> None:
192192
"CIBW_TEST_REQUIRES": "pytest",
193193
"CIBW_TEST_COMMAND": f"{utils.invoke_pytest()} {{project}}/test",
194194
# limit the number of builds for test performance reasons
195-
"CIBW_BUILD": "cp38-* cp{}{}-* cp313t-* pp310-*".format(*utils.SINGLE_PYTHON_VERSION),
195+
"CIBW_BUILD": "cp38-* cp{}{}-* cp314t-* pp310-*".format(*utils.SINGLE_PYTHON_VERSION),
196196
"CIBW_ENABLE": "all",
197197
},
198198
)

‎unit_test/get_platform_test.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_arm(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
7171

7272
def test_env_set(tmp_path: Path) -> None:
7373
environment = {"VSCMD_ARG_TGT_ARCH": "x64"}
74-
configuration = PythonConfiguration(version="irrelevant", identifier="cp313t-win32", url=None)
74+
configuration = PythonConfiguration(version="irrelevant", identifier="cp314t-win32", url=None)
7575

7676
with pytest.raises(FatalError, match="VSCMD_ARG_TGT_ARCH"):
7777
setup_setuptools_cross_compile(tmp_path, configuration, tmp_path, environment)

‎unit_test/main_tests/main_options_test.py‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23
import tomllib
34
from collections.abc import Mapping
@@ -167,6 +168,78 @@ def test_empty_selector(monkeypatch: pytest.MonkeyPatch) -> None:
167168
assert e.value.code == 3
168169

169170

171+
@pytest.mark.usefixtures("platform", "intercepted_build_args")
172+
def test_cp313t_warning1(
173+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
174+
) -> None:
175+
monkeypatch.setenv("CIBW_ENABLE", "cpython-freethreading")
176+
177+
main()
178+
179+
_, err = capsys.readouterr()
180+
print(err)
181+
assert "'cpython-freethreading' enable is deprecated" in err
182+
183+
184+
@pytest.mark.usefixtures("platform", "intercepted_build_args")
185+
def test_cp313t_warning2(
186+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], tmp_path: Path
187+
) -> None:
188+
local_path = tmp_path / "tmp_project"
189+
os.mkdir(local_path) # noqa:PTH102 Path.mkdir has been monkeypatched already
190+
local_path.joinpath("setup.py").touch()
191+
192+
monkeypatch.setattr(
193+
sys, "argv", ["cibuildwheel", "--only", "cp313t-manylinux_x86_64", str(local_path)]
194+
)
195+
monkeypatch.setenv("CIBW_ENABLE", "cpython-freethreading")
196+
197+
main()
198+
199+
_, err = capsys.readouterr()
200+
print(err)
201+
assert "'cpython-freethreading' enable is deprecated" in err
202+
203+
204+
@pytest.mark.usefixtures("platform", "intercepted_build_args")
205+
def test_cp313t_warning3(
206+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], tmp_path: Path
207+
) -> None:
208+
local_path = tmp_path / "tmp_project"
209+
os.mkdir(local_path) # noqa:PTH102 Path.mkdir has been monkeypatched already
210+
local_path.joinpath("setup.py").touch()
211+
212+
monkeypatch.setattr(
213+
sys, "argv", ["cibuildwheel", "--only", "cp313t-manylinux_x86_64", str(local_path)]
214+
)
215+
216+
main()
217+
218+
_, err = capsys.readouterr()
219+
print(err)
220+
assert "'cpython-freethreading' enable is deprecated" in err
221+
222+
223+
@pytest.mark.usefixtures("platform", "intercepted_build_args")
224+
def test_cp313t_warning4(
225+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], tmp_path: Path
226+
) -> None:
227+
local_path = tmp_path / "tmp_project"
228+
os.mkdir(local_path) # noqa:PTH102 Path.mkdir has been monkeypatched already
229+
local_path.joinpath("setup.py").touch()
230+
231+
monkeypatch.setattr(
232+
sys, "argv", ["cibuildwheel", "--only", "cp313t-manylinux_x86_64", str(local_path)]
233+
)
234+
monkeypatch.setenv("CIBW_ENABLE", "all")
235+
236+
main()
237+
238+
_, err = capsys.readouterr()
239+
print(err)
240+
assert "'cpython-freethreading' enable is deprecated" in err
241+
242+
170243
@pytest.mark.parametrize(
171244
("architecture", "image", "full_image"),
172245
[
@@ -579,6 +652,7 @@ def test_enable_all(
579652
intercepted_build_args: "ArgsInterceptor", monkeypatch: pytest.MonkeyPatch
580653
) -> None:
581654
monkeypatch.setattr(sys, "argv", [*sys.argv, "--enable", "all"])
655+
monkeypatch.delenv("CIBW_ENABLE", raising=False)
582656

583657
main()
584658

0 commit comments

Comments
 (0)