Skip to content

Commit d134edc

Browse files
mayeutjoerick
andauthored
chore: drop deprecated options related to CIBW_ENABLE (#2095)
* chore: drop deprecated options * Add --enable option * Fix pyodide tests
 --------- Co-authored-by: Joe Rickerby <[email protected]>
1 parent 730b642 commit d134edc

File tree

15 files changed

+123
-130
lines changed

15 files changed

+123
-130
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ jobs:
8181
env:
8282
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
8383
CIBW_BUILD_FRONTEND: 'build[uv]'
84-
CIBW_FREE_THREADED_SUPPORT: 1
85-
CIBW_PRERELEASE_PYTHONS: 1
84+
CIBW_ENABLE: "cpython-prerelease cpython-freethreading pypy"
8685

8786
- name: Run a sample build (GitHub Action, only)
8887
uses: ./

bin/generate_schema.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@
119119
description: Set environment variables on the host to pass-through to the container
120120
during the build.
121121
type: string_array
122-
free-threaded-support:
123-
type: boolean
124-
default: false
125-
description: The project supports free-threaded builds of Python (PEP703)
126-
deprecated: Use the `enable` option instead.
127122
manylinux-aarch64-image:
128123
type: string
129124
description: Specify alternative manylinux / musllinux container images
@@ -277,7 +272,6 @@
277272
del non_global_options["build"]
278273
del non_global_options["skip"]
279274
del non_global_options["test-skip"]
280-
del non_global_options["free-threaded-support"]
281275
del non_global_options["enable"]
282276

283277
overrides["items"]["properties"]["select"]["oneOf"] = string_array

cibuildwheel/__main__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
CIBW_CACHE_PATH,
3131
BuildSelector,
3232
CIProvider,
33+
EnableGroup,
3334
Unbuffered,
3435
detect_ci_provider,
3536
fix_ansi_codes_for_github_actions,
@@ -100,6 +101,17 @@ def main_inner(global_options: GlobalOptions) -> None:
100101
""",
101102
)
102103

104+
enable_groups_str = ", ".join(g.value for g in EnableGroup)
105+
parser.add_argument(
106+
"--enable",
107+
action="append",
108+
default=[],
109+
metavar="GROUP",
110+
help=f"""
111+
Enable an additional category of builds. Use multiple times to select multiple groups. Choices: {enable_groups_str}.
112+
""",
113+
)
114+
103115
parser.add_argument(
104116
"--only",
105117
default=None,
@@ -156,12 +168,6 @@ def main_inner(global_options: GlobalOptions) -> None:
156168
help="Do not report an error code if the build does not match any wheels.",
157169
)
158170

159-
parser.add_argument(
160-
"--prerelease-pythons",
161-
action="store_true",
162-
help="Enable pre-release Python versions if available.",
163-
)
164-
165171
parser.add_argument(
166172
"--debug-traceback",
167173
action="store_true",

cibuildwheel/options.py

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929
BuildFrontendConfig,
3030
BuildSelector,
3131
DependencyConstraints,
32-
EnableGroups,
32+
EnableGroup,
3333
TestSelector,
3434
format_safe,
35-
read_python_configs,
3635
resources_dir,
3736
selector_matches,
3837
strtobool,
@@ -50,8 +49,8 @@ class CommandLineArguments:
5049
package_dir: Path
5150
print_build_identifiers: bool
5251
allow_empty: bool
53-
prerelease_pythons: bool
5452
debug_traceback: bool
53+
enable: list[str]
5554

5655
@staticmethod
5756
def defaults() -> CommandLineArguments:
@@ -63,9 +62,9 @@ def defaults() -> CommandLineArguments:
6362
config_file="",
6463
output_dir=Path("wheelhouse"),
6564
package_dir=Path("."),
66-
prerelease_pythons=False,
6765
print_build_identifiers=False,
6866
debug_traceback=False,
67+
enable=[],
6968
)
7069

7170

@@ -618,28 +617,13 @@ def globals(self) -> GlobalOptions:
618617
enable_groups = self.reader.get(
619618
"enable", env_plat=False, option_format=ListFormat(sep=" "), env_rule=InheritRule.APPEND
620619
)
621-
enable = {EnableGroups(group) for group in enable_groups.split()}
622-
623-
free_threaded_support = strtobool(
624-
self.reader.get("free-threaded-support", env_plat=False, ignore_empty=True)
625-
)
626-
627-
prerelease_pythons = args.prerelease_pythons or strtobool(
628-
self.env.get("CIBW_PRERELEASE_PYTHONS", "0")
629-
)
630-
631-
if free_threaded_support or prerelease_pythons:
632-
msg = (
633-
"free-threaded-support and prerelease-pythons should be specified by enable instead"
634-
)
635-
if enable:
636-
raise OptionsReaderError(msg)
637-
log.warning(msg)
638-
639-
if free_threaded_support:
640-
enable.add(EnableGroups.CPythonFreeThreading)
641-
if prerelease_pythons:
642-
enable.add(EnableGroups.CPythonPrerelease)
620+
try:
621+
enable = {EnableGroup(group) for group in enable_groups.split()}
622+
for command_line_group in args.enable:
623+
enable.add(EnableGroup(command_line_group))
624+
except ValueError as e:
625+
msg = f"Failed to parse enable group. {e}. Valid group names are: {', '.join(g.value for g in EnableGroup)}"
626+
raise errors.ConfigurationError(msg) from e
643627

644628
# This is not supported in tool.cibuildwheel, as it comes from a standard location.
645629
# Passing this in as an environment variable will override pyproject.toml, setup.cfg, or setup.py
@@ -656,30 +640,16 @@ def globals(self) -> GlobalOptions:
656640
build_config = args.only
657641
skip_config = ""
658642
architectures = Architecture.all_archs(self.platform)
659-
enable = set(EnableGroups)
643+
enable = set(EnableGroup)
660644

661645
build_selector = BuildSelector(
662646
build_config=build_config,
663647
skip_config=skip_config,
664648
requires_python=requires_python,
665-
enable=frozenset(
666-
enable | {EnableGroups.PyPy}
667-
), # For backwards compatibility, we are adding PyPy for now
649+
enable=frozenset(enable),
668650
)
669651
test_selector = TestSelector(skip_config=test_skip)
670652

671-
all_configs = read_python_configs(self.platform)
672-
all_pypy_ids = {
673-
config["identifier"] for config in all_configs if config["identifier"].startswith("pp")
674-
}
675-
if (
676-
not self._defaults
677-
and EnableGroups.PyPy not in enable
678-
and any(build_selector(build_id) for build_id in all_pypy_ids)
679-
):
680-
msg = "PyPy builds will be disabled by default in version 3. Enabling PyPy builds should be specified by enable"
681-
log.warning(msg)
682-
683653
return GlobalOptions(
684654
package_dir=package_dir,
685655
output_dir=output_dir,

cibuildwheel/resources/cibuildwheel.schema.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,6 @@
284284
],
285285
"title": "CIBW_ENVIRONMENT_PASS"
286286
},
287-
"free-threaded-support": {
288-
"type": "boolean",
289-
"default": false,
290-
"description": "The project supports free-threaded builds of Python (PEP703)",
291-
"deprecated": "Use the `enable` option instead.",
292-
"title": "CIBW_FREE_THREADED_SUPPORT"
293-
},
294287
"manylinux-aarch64-image": {
295288
"type": "string",
296289
"description": "Specify alternative manylinux / musllinux container images",

cibuildwheel/resources/defaults.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
build = "*"
33
skip = ""
44
test-skip = ""
5-
free-threaded-support = false
65
enable = []
76

87
archs = ["auto"]

cibuildwheel/util.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
__all__ = [
4646
"MANYLINUX_ARCHS",
47-
"EnableGroups",
47+
"EnableGroup",
4848
"call",
4949
"combine_constraints",
5050
"find_compatible_wheel",
@@ -67,7 +67,7 @@
6767
free_thread_enable_313: Final[Path] = resources_dir / "free-threaded-enable-313.xml"
6868

6969

70-
class EnableGroups(enum.Enum):
70+
class EnableGroup(enum.Enum):
7171
"""
7272
Groups of build selectors that are not enabled by default.
7373
"""
@@ -278,7 +278,7 @@ class BuildSelector:
278278
build_config: str
279279
skip_config: str
280280
requires_python: SpecifierSet | None = None
281-
enable: frozenset[EnableGroups] = frozenset()
281+
enable: frozenset[EnableGroup] = frozenset()
282282

283283
def __call__(self, build_id: str) -> bool:
284284
# Filter build selectors by python_requires if set
@@ -293,15 +293,15 @@ def __call__(self, build_id: str) -> bool:
293293
return False
294294

295295
# filter out groups that are not enabled
296-
if EnableGroups.CPythonFreeThreading not in self.enable and selector_matches(
296+
if EnableGroup.CPythonFreeThreading not in self.enable and selector_matches(
297297
"cp3??t-*", build_id
298298
):
299299
return False
300-
if EnableGroups.CPythonPrerelease not in self.enable and selector_matches(
300+
if EnableGroup.CPythonPrerelease not in self.enable and selector_matches(
301301
"cp314*", build_id
302302
):
303303
return False
304-
if EnableGroups.PyPy not in self.enable and selector_matches("pp*", build_id):
304+
if EnableGroup.PyPy not in self.enable and selector_matches("pp*", build_id):
305305
return False
306306

307307
should_build = selector_matches(self.build_config, build_id)

docs/options.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,14 @@ values are:
567567

568568

569569
- `cpython-prerelease`: Enables beta versions of Pythons if any are available
570-
(May-July, approximately). For backward compatibility, `CIBW_PRERELEASE_PYTHONS`
571-
is also supported until cibuildwheel 3.
570+
(May-July, approximately).
572571
- `cpython-freethreading`: [PEP 703](https://www.python.org/dev/peps/pep-0703)
573572
introduced variants of CPython that can be built without the Global
574573
Interpreter Lock (GIL). Those variants are also known as free-threaded /
575574
no-gil. This will enable building these wheels while they are experimental.
576575
The build identifiers for those variants have a `t` suffix in their
577-
`python_tag` (e.g. `cp313t-manylinux_x86_64`). For backward compatibility,
578-
`CIBW_FREE_THREADED_SUPPORT` is also supported until cibuildwheel 3.
579-
- `pypy`: Enable PyPy. For backward compatibility, this is always enabled until
580-
cibuildwheel 3 is released.
576+
`python_tag` (e.g. `cp313t-manylinux_x86_64`).
577+
- `pypy`: Enable PyPy.
581578

582579

583580
!!! caution
@@ -591,7 +588,7 @@ values are:
591588
!!! note
592589
Free threading is experimental: [What’s New In Python 3.13](https://docs.python.org/3.13/whatsnew/3.13.html#free-threaded-cpython)
593590

594-
Default: empty (`pypy` is always injected).
591+
Default: empty.
595592

596593
This option doesn't support overrides or platform specific variants; it is
597594
intended as a way to acknowledge that a project is aware that these extra

test/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def cibuildwheel_get_build_identifiers(
4747
for the current platform.
4848
"""
4949
cmd = [sys.executable, "-m", "cibuildwheel", "--print-build-identifiers", str(project_path)]
50-
if prerelease_pythons:
51-
cmd.append("--prerelease-pythons")
5250
if env is None:
5351
env = os.environ.copy()
54-
env.setdefault("CIBW_FREE_THREADED_SUPPORT", "1")
52+
env["CIBW_ENABLE"] = "cpython-freethreading pypy"
53+
if prerelease_pythons:
54+
env["CIBW_ENABLE"] += " cpython-prerelease"
5555

5656
cmd_output = subprocess.run(
5757
cmd,
@@ -115,7 +115,7 @@ def cibuildwheel_run(
115115

116116
_update_pip_cache_dir(env)
117117

118-
env.setdefault("CIBW_FREE_THREADED_SUPPORT", "1")
118+
env["CIBW_ENABLE"] = "cpython-prerelease cpython-freethreading pypy"
119119

120120
if single_python:
121121
env["CIBW_BUILD"] = "cp{}{}-*".format(*SINGLE_PYTHON_VERSION)
@@ -126,7 +126,6 @@ def cibuildwheel_run(
126126
sys.executable,
127127
"-m",
128128
"cibuildwheel",
129-
"--prerelease-pythons",
130129
"--output-dir",
131130
str(output_dir or tmp_output_dir),
132131
str(package_dir),

unit_test/build_selector_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from packaging.specifiers import SpecifierSet
44

5-
from cibuildwheel.util import BuildSelector, EnableGroups
5+
from cibuildwheel.util import BuildSelector, EnableGroup
66

77

88
def test_build():
99
build_selector = BuildSelector(
10-
build_config="cp3*-* *-manylinux*", skip_config="", enable=frozenset([EnableGroups.PyPy])
10+
build_config="cp3*-* *-manylinux*", skip_config="", enable=frozenset([EnableGroup.PyPy])
1111
)
1212

1313
assert build_selector("cp36-manylinux_x86_64")
@@ -45,7 +45,7 @@ def test_build_filter_pre():
4545
build_selector = BuildSelector(
4646
build_config="cp3*-* *-manylinux*",
4747
skip_config="",
48-
enable=frozenset([EnableGroups.CPythonPrerelease, EnableGroups.PyPy]),
48+
enable=frozenset([EnableGroup.CPythonPrerelease, EnableGroup.PyPy]),
4949
)
5050

5151
assert build_selector("cp37-manylinux_x86_64")
@@ -59,7 +59,7 @@ def test_skip():
5959
build_selector = BuildSelector(
6060
build_config="*",
6161
skip_config="pp36-* cp3?-manylinux_i686 cp36-win* *-win32",
62-
enable=frozenset([EnableGroups.PyPy]),
62+
enable=frozenset([EnableGroup.PyPy]),
6363
)
6464

6565
assert not build_selector("pp36-manylinux_x86_64")
@@ -85,7 +85,7 @@ def test_build_and_skip():
8585
build_selector = BuildSelector(
8686
build_config="cp36-* cp37-macosx* *-manylinux*",
8787
skip_config="pp37-* cp37-manylinux_i686",
88-
enable=frozenset([EnableGroups.PyPy]),
88+
enable=frozenset([EnableGroup.PyPy]),
8989
)
9090

9191
assert not build_selector("pp37-manylinux_x86_64")
@@ -119,7 +119,7 @@ def test_build_limited_python():
119119
build_config="*",
120120
skip_config="",
121121
requires_python=SpecifierSet(">=3.7"),
122-
enable=frozenset([EnableGroups.PyPy]),
122+
enable=frozenset([EnableGroup.PyPy]),
123123
)
124124

125125
assert not build_selector("cp36-manylinux_x86_64")
@@ -155,7 +155,7 @@ def test_build_limited_python_patch():
155155

156156

157157
def test_build_free_threaded_python():
158-
build_selector = BuildSelector(build_config="*", skip_config="", enable=frozenset(EnableGroups))
158+
build_selector = BuildSelector(build_config="*", skip_config="", enable=frozenset(EnableGroup))
159159

160160
assert build_selector("cp313t-manylinux_x86_64")
161161

0 commit comments

Comments
 (0)