feat: add option to opt-in free-threaded builds
This commit is contained in:
@@ -117,7 +117,7 @@ class BuildOptions:
|
||||
return self.globals.architectures
|
||||
|
||||
|
||||
Setting = Union[Mapping[str, str], Sequence[str], str, int]
|
||||
Setting = Union[Mapping[str, str], Sequence[str], str, int, bool]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -196,7 +196,7 @@ def _resolve_cascade(
|
||||
if value is None:
|
||||
continue
|
||||
|
||||
if ignore_empty and not value:
|
||||
if ignore_empty and not value and value is not False:
|
||||
continue
|
||||
|
||||
value_string = _stringify_setting(value, list_sep, table_format)
|
||||
@@ -258,7 +258,7 @@ def _stringify_setting(
|
||||
raise ConfigOptionError(msg)
|
||||
return list_sep.join(setting)
|
||||
|
||||
if isinstance(setting, int):
|
||||
if isinstance(setting, (bool, int)):
|
||||
return str(setting)
|
||||
|
||||
return setting
|
||||
@@ -516,6 +516,10 @@ class Options:
|
||||
skip_config = self.reader.get("skip", env_plat=False, list_sep=" ")
|
||||
test_skip = self.reader.get("test-skip", env_plat=False, list_sep=" ")
|
||||
|
||||
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")
|
||||
)
|
||||
@@ -536,12 +540,14 @@ class Options:
|
||||
skip_config = ""
|
||||
architectures = Architecture.all_archs(self.platform)
|
||||
prerelease_pythons = True
|
||||
free_threaded_support = True
|
||||
|
||||
build_selector = BuildSelector(
|
||||
build_config=build_config,
|
||||
skip_config=skip_config,
|
||||
requires_python=requires_python,
|
||||
prerelease_pythons=prerelease_pythons,
|
||||
free_threaded_support=free_threaded_support,
|
||||
)
|
||||
test_selector = TestSelector(skip_config=test_skip)
|
||||
|
||||
|
||||
@@ -255,6 +255,12 @@
|
||||
],
|
||||
"title": "CIBW_ENVIRONMENT_PASS"
|
||||
},
|
||||
"free-threaded-support": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "The project supports free-threaded builds of Python (PEP703)",
|
||||
"title": "CIBW_FREE_THREADED_SUPPORT"
|
||||
},
|
||||
"manylinux-aarch64-image": {
|
||||
"type": "string",
|
||||
"description": "Specify alternative manylinux / musllinux container images",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
build = "*"
|
||||
skip = ""
|
||||
test-skip = ""
|
||||
free-threaded-support = false
|
||||
|
||||
archs = ["auto"]
|
||||
build-frontend = "default"
|
||||
|
||||
@@ -241,6 +241,8 @@ class BuildSelector:
|
||||
PRERELEASE_SKIP: ClassVar[str] = "cp313-* cp313t-*"
|
||||
prerelease_pythons: bool = False
|
||||
|
||||
free_threaded_support: bool = False
|
||||
|
||||
def __call__(self, build_id: str) -> bool:
|
||||
# Filter build selectors by python_requires if set
|
||||
if self.requires_python is not None:
|
||||
@@ -257,6 +259,10 @@ class BuildSelector:
|
||||
if not self.prerelease_pythons and selector_matches(self.PRERELEASE_SKIP, build_id):
|
||||
return False
|
||||
|
||||
# filter out free threaded pythons if self.free_threaded_support is False
|
||||
if not self.free_threaded_support and selector_matches("*t-*", build_id):
|
||||
return False
|
||||
|
||||
should_build = selector_matches(self.build_config, build_id)
|
||||
should_skip = selector_matches(self.skip_config, build_id)
|
||||
|
||||
@@ -268,6 +274,7 @@ class BuildSelector:
|
||||
"skip_config": self.skip_config,
|
||||
"requires_python": str(self.requires_python),
|
||||
"prerelease_pythons": self.prerelease_pythons,
|
||||
"free_threaded_support": self.free_threaded_support,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user