Skip to content

chore: drop deprecated options related to CIBW_ENABLE #2095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ jobs:
env:
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CIBW_BUILD_FRONTEND: 'build[uv]'
CIBW_FREE_THREADED_SUPPORT: 1
CIBW_PRERELEASE_PYTHONS: 1
CIBW_ENABLE: "cpython-prerelease cpython-freethreading pypy"

- name: Run a sample build (GitHub Action, only)
uses: ./
Expand Down
6 changes: 0 additions & 6 deletions bin/generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@
description: Set environment variables on the host to pass-through to the container
during the build.
type: string_array
free-threaded-support:
type: boolean
default: false
description: The project supports free-threaded builds of Python (PEP703)
deprecated: Use the `enable` option instead.
manylinux-aarch64-image:
type: string
description: Specify alternative manylinux / musllinux container images
Expand Down Expand Up @@ -277,7 +272,6 @@
del non_global_options["build"]
del non_global_options["skip"]
del non_global_options["test-skip"]
del non_global_options["free-threaded-support"]
del non_global_options["enable"]

overrides["items"]["properties"]["select"]["oneOf"] = string_array
Expand Down
18 changes: 12 additions & 6 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
CIBW_CACHE_PATH,
BuildSelector,
CIProvider,
EnableGroup,
Unbuffered,
detect_ci_provider,
fix_ansi_codes_for_github_actions,
Expand Down Expand Up @@ -100,6 +101,17 @@ def main_inner(global_options: GlobalOptions) -> None:
""",
)

enable_groups_str = ", ".join(g.value for g in EnableGroup)
parser.add_argument(
"--enable",
action="append",
default=[],
metavar="GROUP",
help=f"""
Enable an additional category of builds. Use multiple times to select multiple groups. Choices: {enable_groups_str}.
""",
)

parser.add_argument(
"--only",
default=None,
Expand Down Expand Up @@ -156,12 +168,6 @@ def main_inner(global_options: GlobalOptions) -> None:
help="Do not report an error code if the build does not match any wheels.",
)

parser.add_argument(
"--prerelease-pythons",
action="store_true",
help="Enable pre-release Python versions if available.",
)

parser.add_argument(
"--debug-traceback",
action="store_true",
Expand Down
54 changes: 12 additions & 42 deletions cibuildwheel/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
BuildFrontendConfig,
BuildSelector,
DependencyConstraints,
EnableGroups,
EnableGroup,
TestSelector,
format_safe,
read_python_configs,
resources_dir,
selector_matches,
strtobool,
Expand All @@ -50,8 +49,8 @@ class CommandLineArguments:
package_dir: Path
print_build_identifiers: bool
allow_empty: bool
prerelease_pythons: bool
debug_traceback: bool
enable: list[str]

@staticmethod
def defaults() -> CommandLineArguments:
Expand All @@ -63,9 +62,9 @@ def defaults() -> CommandLineArguments:
config_file="",
output_dir=Path("wheelhouse"),
package_dir=Path("."),
prerelease_pythons=False,
print_build_identifiers=False,
debug_traceback=False,
enable=[],
)


Expand Down Expand Up @@ -618,28 +617,13 @@ def globals(self) -> GlobalOptions:
enable_groups = self.reader.get(
"enable", env_plat=False, option_format=ListFormat(sep=" "), env_rule=InheritRule.APPEND
)
enable = {EnableGroups(group) for group in enable_groups.split()}

free_threaded_support = strtobool(
self.reader.get("free-threaded-support", env_plat=False, ignore_empty=True)
)

prerelease_pythons = args.prerelease_pythons or strtobool(
self.env.get("CIBW_PRERELEASE_PYTHONS", "0")
)

if free_threaded_support or prerelease_pythons:
msg = (
"free-threaded-support and prerelease-pythons should be specified by enable instead"
)
if enable:
raise OptionsReaderError(msg)
log.warning(msg)

if free_threaded_support:
enable.add(EnableGroups.CPythonFreeThreading)
if prerelease_pythons:
enable.add(EnableGroups.CPythonPrerelease)
try:
enable = {EnableGroup(group) for group in enable_groups.split()}
for command_line_group in args.enable:
enable.add(EnableGroup(command_line_group))
except ValueError as e:
msg = f"Failed to parse enable group. {e}. Valid group names are: {', '.join(g.value for g in EnableGroup)}"
raise errors.ConfigurationError(msg) from e

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

build_selector = BuildSelector(
build_config=build_config,
skip_config=skip_config,
requires_python=requires_python,
enable=frozenset(
enable | {EnableGroups.PyPy}
), # For backwards compatibility, we are adding PyPy for now
enable=frozenset(enable),
)
test_selector = TestSelector(skip_config=test_skip)

all_configs = read_python_configs(self.platform)
all_pypy_ids = {
config["identifier"] for config in all_configs if config["identifier"].startswith("pp")
}
if (
not self._defaults
and EnableGroups.PyPy not in enable
and any(build_selector(build_id) for build_id in all_pypy_ids)
):
msg = "PyPy builds will be disabled by default in version 3. Enabling PyPy builds should be specified by enable"
log.warning(msg)

return GlobalOptions(
package_dir=package_dir,
output_dir=output_dir,
Expand Down
7 changes: 0 additions & 7 deletions cibuildwheel/resources/cibuildwheel.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,6 @@
],
"title": "CIBW_ENVIRONMENT_PASS"
},
"free-threaded-support": {
"type": "boolean",
"default": false,
"description": "The project supports free-threaded builds of Python (PEP703)",
"deprecated": "Use the `enable` option instead.",
"title": "CIBW_FREE_THREADED_SUPPORT"
},
"manylinux-aarch64-image": {
"type": "string",
"description": "Specify alternative manylinux / musllinux container images",
Expand Down
1 change: 0 additions & 1 deletion cibuildwheel/resources/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
build = "*"
skip = ""
test-skip = ""
free-threaded-support = false
enable = []

archs = ["auto"]
Expand Down
12 changes: 6 additions & 6 deletions cibuildwheel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

__all__ = [
"MANYLINUX_ARCHS",
"EnableGroups",
"EnableGroup",
"call",
"combine_constraints",
"find_compatible_wheel",
Expand All @@ -67,7 +67,7 @@
free_thread_enable_313: Final[Path] = resources_dir / "free-threaded-enable-313.xml"


class EnableGroups(enum.Enum):
class EnableGroup(enum.Enum):
"""
Groups of build selectors that are not enabled by default.
"""
Expand Down Expand Up @@ -278,7 +278,7 @@ class BuildSelector:
build_config: str
skip_config: str
requires_python: SpecifierSet | None = None
enable: frozenset[EnableGroups] = frozenset()
enable: frozenset[EnableGroup] = frozenset()

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

# filter out groups that are not enabled
if EnableGroups.CPythonFreeThreading not in self.enable and selector_matches(
if EnableGroup.CPythonFreeThreading not in self.enable and selector_matches(
"cp3??t-*", build_id
):
return False
if EnableGroups.CPythonPrerelease not in self.enable and selector_matches(
if EnableGroup.CPythonPrerelease not in self.enable and selector_matches(
"cp314*", build_id
):
return False
if EnableGroups.PyPy not in self.enable and selector_matches("pp*", build_id):
if EnableGroup.PyPy not in self.enable and selector_matches("pp*", build_id):
return False

should_build = selector_matches(self.build_config, build_id)
Expand Down
11 changes: 4 additions & 7 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,14 @@ values are:


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


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

Default: empty (`pypy` is always injected).
Default: empty.

This option doesn't support overrides or platform specific variants; it is
intended as a way to acknowledge that a project is aware that these extra
Expand Down
9 changes: 4 additions & 5 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def cibuildwheel_get_build_identifiers(
for the current platform.
"""
cmd = [sys.executable, "-m", "cibuildwheel", "--print-build-identifiers", str(project_path)]
if prerelease_pythons:
cmd.append("--prerelease-pythons")
if env is None:
env = os.environ.copy()
env.setdefault("CIBW_FREE_THREADED_SUPPORT", "1")
env["CIBW_ENABLE"] = "cpython-freethreading pypy"
if prerelease_pythons:
env["CIBW_ENABLE"] += " cpython-prerelease"

cmd_output = subprocess.run(
cmd,
Expand Down Expand Up @@ -115,7 +115,7 @@ def cibuildwheel_run(

_update_pip_cache_dir(env)

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

if single_python:
env["CIBW_BUILD"] = "cp{}{}-*".format(*SINGLE_PYTHON_VERSION)
Expand All @@ -126,7 +126,6 @@ def cibuildwheel_run(
sys.executable,
"-m",
"cibuildwheel",
"--prerelease-pythons",
"--output-dir",
str(output_dir or tmp_output_dir),
str(package_dir),
Expand Down
14 changes: 7 additions & 7 deletions unit_test/build_selector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from packaging.specifiers import SpecifierSet

from cibuildwheel.util import BuildSelector, EnableGroups
from cibuildwheel.util import BuildSelector, EnableGroup


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

assert build_selector("cp36-manylinux_x86_64")
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_build_filter_pre():
build_selector = BuildSelector(
build_config="cp3*-* *-manylinux*",
skip_config="",
enable=frozenset([EnableGroups.CPythonPrerelease, EnableGroups.PyPy]),
enable=frozenset([EnableGroup.CPythonPrerelease, EnableGroup.PyPy]),
)

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

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

assert not build_selector("pp37-manylinux_x86_64")
Expand Down Expand Up @@ -119,7 +119,7 @@ def test_build_limited_python():
build_config="*",
skip_config="",
requires_python=SpecifierSet(">=3.7"),
enable=frozenset([EnableGroups.PyPy]),
enable=frozenset([EnableGroup.PyPy]),
)

assert not build_selector("cp36-manylinux_x86_64")
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_build_limited_python_patch():


def test_build_free_threaded_python():
build_selector = BuildSelector(build_config="*", skip_config="", enable=frozenset(EnableGroups))
build_selector = BuildSelector(build_config="*", skip_config="", enable=frozenset(EnableGroup))

assert build_selector("cp313t-manylinux_x86_64")

Expand Down
4 changes: 3 additions & 1 deletion unit_test/main_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

from cibuildwheel import linux, macos, util, windows
from cibuildwheel import linux, macos, pyodide, util, windows


class ArgsInterceptor:
Expand Down Expand Up @@ -42,6 +42,7 @@ def ignore_call(*args, **kwargs):
monkeypatch.setattr(windows, "build", fail_on_call)
monkeypatch.setattr(linux, "build", fail_on_call)
monkeypatch.setattr(macos, "build", fail_on_call)
monkeypatch.setattr(pyodide, "build", fail_on_call)

monkeypatch.setattr(Path, "mkdir", ignore_call)

Expand Down Expand Up @@ -88,6 +89,7 @@ def intercepted_build_args(monkeypatch):
monkeypatch.setattr(linux, "build", intercepted)
monkeypatch.setattr(macos, "build", intercepted)
monkeypatch.setattr(windows, "build", intercepted)
monkeypatch.setattr(pyodide, "build", intercepted)

yield intercepted

Expand Down
Loading
Loading