Skip to content

Commit 31a9f96

Browse files
committed
Add a setting to manually specify wheel tags
Signed-off-by: Cristian Le <[email protected]>
1 parent ad0dcbe commit 31a9f96

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ wheel.exclude = []
260260
# The build tag to use for the wheel. If empty, no build tag is used.
261261
wheel.build-tag = ""
262262

263+
# Manually specify the wheel tags to use, ignoring other inputs such as
264+
# ``wheel.py-api``. Each tag must be of the format
265+
# {interpreter}-{abi}-{platform}. If not specified, these tags are automatically
266+
# calculated.
267+
wheel.tags = []
268+
263269
# If CMake is less than this value, backport a copy of FindPython. Set to 0
264270
# disable this, or the empty string.
265271
backport.find-python = "3.26.1"

src/scikit_build_core/build/wheel.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import TYPE_CHECKING, Any, Literal
1111

1212
from packaging.requirements import Requirement
13+
from packaging.tags import Tag
1314
from packaging.utils import canonicalize_name
1415

1516
from .._compat import tomllib
@@ -260,6 +261,10 @@ def _build_wheel_impl_impl(
260261
f"{{red}}({state})",
261262
)
262263

264+
override_wheel_tags = None
265+
if settings.wheel.tags:
266+
override_wheel_tags = {Tag(*tag.split("-")) for tag in settings.wheel.tags}
267+
263268
with tempfile.TemporaryDirectory() as tmpdir:
264269
build_tmp_folder = Path(tmpdir)
265270
wheel_dir = build_tmp_folder / "wheel"
@@ -364,7 +369,7 @@ def _build_wheel_impl_impl(
364369
wheel = WheelWriter(
365370
metadata,
366371
Path(metadata_directory),
367-
tags.as_tags_set(),
372+
override_wheel_tags or tags.as_tags_set(),
368373
WheelMetadata(
369374
root_is_purelib=targetlib == "purelib",
370375
build_tag=settings.wheel.build_tag,
@@ -480,7 +485,7 @@ def _build_wheel_impl_impl(
480485
with WheelWriter(
481486
metadata,
482487
Path(wheel_directory),
483-
tags.as_tags_set(),
488+
override_wheel_tags or tags.as_tags_set(),
484489
WheelMetadata(
485490
root_is_purelib=targetlib == "purelib",
486491
build_tag=settings.wheel.build_tag,

src/scikit_build_core/resources/scikit-build.schema.json

+10
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@
243243
"type": "string",
244244
"default": "",
245245
"description": "The build tag to use for the wheel. If empty, no build tag is used."
246+
},
247+
"tags": {
248+
"type": "array",
249+
"items": {
250+
"type": "string"
251+
},
252+
"description": "Manually specify the wheel tags to use, ignoring other inputs such as ``wheel.py-api``. Each tag must be of the format {interpreter}-{abi}-{platform}. If not specified, these tags are automatically calculated."
246253
}
247254
}
248255
},
@@ -570,6 +577,9 @@
570577
},
571578
"exclude": {
572579
"$ref": "#/$defs/inherit"
580+
},
581+
"tags": {
582+
"$ref": "#/$defs/inherit"
573583
}
574584
}
575585
},

src/scikit_build_core/settings/skbuild_model.py

+7
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ class WheelSettings:
244244
The build tag to use for the wheel. If empty, no build tag is used.
245245
"""
246246

247+
tags: List[str] = dataclasses.field(default_factory=list)
248+
"""
249+
Manually specify the wheel tags to use, ignoring other inputs such as
250+
``wheel.py-api``. Each tag must be of the format {interpreter}-{abi}-{platform}.
251+
If not specified, these tags are automatically calculated.
252+
"""
253+
247254

248255
@dataclasses.dataclass
249256
class BackportSettings:

0 commit comments

Comments
 (0)