Skip to content

Commit 072a5bc

Browse files
authored
feat: add wheel.exclude (#560)
This is actually really easy to implement, and there already was a test file named for this feature, so let's add it. :) --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 91d9e60 commit 072a5bc

File tree

7 files changed

+36
-2
lines changed

7 files changed

+36
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ wheel.cmake = true
241241
# platlib if wheel.cmake is true, and the purelib otherwise.
242242
wheel.platlib = ""
243243

244+
# A set of patterns to exclude from the wheel. This is additive to the SDist
245+
# exclude patterns. This applies to the source files, not the final paths.
246+
# Editable installs may not respect this exclusion.
247+
wheel.exclude = []
248+
244249
# If CMake is less than this value, backport a copy of FindPython. Set to 0
245250
# disable this, or the empty string.
246251
backport.find-python = "3.26.1"

docs/configuration.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@ Globbing patterns are supported.
251251
wheel.license-files = ["LICENSE"]
252252
```
253253

254+
You can exclude files from the built wheel (on top of the `sdist.exclude` list)
255+
as well (not guaranteed to be respected by editable installs):
256+
257+
```toml
258+
[tool.scikit-build]
259+
wheel.exclude = ["**.pyx"]
260+
```
261+
254262
:::{note}
255263

256264
There are two more settings that are primarily intended for `overrides` (see

src/scikit_build_core/build/wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def _build_wheel_impl(
329329
packages=packages,
330330
platlib_dir=wheel_dirs[targetlib],
331331
include=settings.sdist.include,
332-
exclude=settings.sdist.exclude,
332+
exclude=[*settings.sdist.exclude, *settings.wheel.exclude],
333333
)
334334

335335
if not editable:

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@
166166
"platlib": {
167167
"type": "boolean",
168168
"description": "Target the platlib or the purelib. If not set, the default is to target the platlib if wheel.cmake is true, and the purelib otherwise."
169+
},
170+
"exclude": {
171+
"type": "array",
172+
"items": {
173+
"type": "string"
174+
},
175+
"description": "A set of patterns to exclude from the wheel. This is additive to the SDist exclude patterns. This applies to the source files, not the final paths. Editable installs may not respect this exclusion."
169176
}
170177
}
171178
},

src/scikit_build_core/settings/skbuild_model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ class WheelSettings:
177177
platlib if wheel.cmake is true, and the purelib otherwise.
178178
"""
179179

180+
exclude: List[str] = dataclasses.field(default_factory=list)
181+
"""
182+
A set of patterns to exclude from the wheel. This is additive to the SDist
183+
exclude patterns. This applies to the source files, not the final paths.
184+
Editable installs may not respect this exclusion.
185+
"""
186+
180187

181188
@dataclasses.dataclass
182189
class BackportSettings:

tests/test_simplest_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def test_pep517_wheel_incexl(tmp_path, monkeypatch, virtualenv):
110110
{
111111
"sdist.include": "src/simplest/*included*.txt",
112112
"sdist.exclude": "src/simplest/*excluded*.txt",
113+
"wheel.exclude": "src/simplest/sdist_only.txt",
113114
"wheel.packages": ["src/simplest", "src/not_a_package"],
114115
},
115116
)
@@ -135,7 +136,6 @@ def test_pep517_wheel_incexl(tmp_path, monkeypatch, virtualenv):
135136
"data.txt",
136137
"ignored_included.txt",
137138
"generated.txt",
138-
"sdist_only.txt",
139139
"generated_ignored.txt",
140140
} == filtered_pkg
141141
assert {"simple.txt"} == not_a_pkg

tests/test_skbuild_settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_skbuild_settings_default(tmp_path: Path):
4848
"NOTICE*",
4949
"AUTHORS*",
5050
]
51+
assert settings.wheel.exclude == []
5152
assert settings.backport.find_python == Version("3.26.1")
5253
assert settings.strict_config
5354
assert not settings.experimental
@@ -84,6 +85,7 @@ def test_skbuild_settings_envvar(tmp_path: Path, monkeypatch: pytest.MonkeyPatch
8485
monkeypatch.setenv("SKBUILD_WHEEL_PY_API", "cp39")
8586
monkeypatch.setenv("SKBUILD_WHEEL_EXPAND_MACOS_UNIVERSAL_TAGS", "True")
8687
monkeypatch.setenv("SKBUILD_WHEEL_LICENSE_FILES", "a;b;c")
88+
monkeypatch.setenv("SKBUILD_WHEEL_EXCLUDE", "b;y;e")
8789
monkeypatch.setenv("SKBUILD_BACKPORT_FIND_PYTHON", "0")
8890
monkeypatch.setenv("SKBUILD_STRICT_CONFIG", "0")
8991
monkeypatch.setenv("SKBUILD_EXPERIMENTAL", "1")
@@ -122,6 +124,7 @@ def test_skbuild_settings_envvar(tmp_path: Path, monkeypatch: pytest.MonkeyPatch
122124
assert settings.wheel.py_api == "cp39"
123125
assert settings.wheel.expand_macos_universal_tags
124126
assert settings.wheel.license_files == ["a", "b", "c"]
127+
assert settings.wheel.exclude == ["b", "y", "e"]
125128
assert settings.backport.find_python == Version("0")
126129
assert not settings.strict_config
127130
assert settings.experimental
@@ -166,6 +169,7 @@ def test_skbuild_settings_config_settings(
166169
"wheel.py-api": "cp39",
167170
"wheel.expand-macos-universal-tags": "True",
168171
"wheel.license-files": ["a", "b", "c"],
172+
"wheel.exclude": ["b", "y", "e"],
169173
"backport.find-python": "0",
170174
"strict-config": "false",
171175
"experimental": "1",
@@ -203,6 +207,7 @@ def test_skbuild_settings_config_settings(
203207
assert settings.wheel.py_api == "cp39"
204208
assert settings.wheel.expand_macos_universal_tags
205209
assert settings.wheel.license_files == ["a", "b", "c"]
210+
assert settings.wheel.exclude == ["b", "y", "e"]
206211
assert settings.backport.find_python == Version("0")
207212
assert not settings.strict_config
208213
assert settings.experimental
@@ -245,6 +250,7 @@ def test_skbuild_settings_pyproject_toml(
245250
wheel.py-api = "cp39"
246251
wheel.expand-macos-universal-tags = true
247252
wheel.license-files = ["a", "b", "c"]
253+
wheel.exclude = ["b", "y", "e"]
248254
backport.find-python = "3.18"
249255
strict-config = false
250256
experimental = true
@@ -292,6 +298,7 @@ def test_skbuild_settings_pyproject_toml(
292298
assert settings.wheel.py_api == "cp39"
293299
assert settings.wheel.expand_macos_universal_tags
294300
assert settings.wheel.license_files == ["a", "b", "c"]
301+
assert settings.wheel.exclude == ["b", "y", "e"]
295302
assert settings.backport.find_python == Version("3.18")
296303
assert not settings.strict_config
297304
assert settings.experimental

0 commit comments

Comments
 (0)