Skip to content
Open
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
14 changes: 14 additions & 0 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,20 @@ wheel.exclude = ["**.pyx"]
Previously these were matched on the source path, rather than the wheel path,
and didn't apply to CMake output.

You can exclude files from the built wheel based on file extension as well (not
guaranteed to be respected by editable installs):

```toml
[tool.scikit-build]
wheel.exclude-exts = [".c", ".cuh", ".h"]
```

Default value: `[".pyc", ".pyo"]`

:::{versionadded} 0.12

Support to exclude based on file extension.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the format looks right here, can you rearrange it? https://scikit-build-core--1128.org.readthedocs.build/en/1128/configuration/index.html#customizing-the-built-wheel

Also, this is new since the introduction of Config Reference, but can you use :confval:... role to reference the new option? There's a nice pop-up of the information about it, so you could de-duplicate some documentation with that.


:::

:::{note}
Expand Down
7 changes: 5 additions & 2 deletions src/scikit_build_core/build/_wheelfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ def dist_info_contents(self) -> dict[str, bytes]:
}

def build(
self, wheel_dirs: Mapping[str, Path], exclude: Sequence[str] = ()
self,
wheel_dirs: Mapping[str, Path],
exclude: Sequence[str] = (),
exclude_exts: Sequence[str] = (),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we have defaults for these. But anyway it's an existing pattern.

) -> None:
(targetlib,) = {"platlib", "purelib"} & set(wheel_dirs)
assert {
Expand All @@ -175,7 +178,7 @@ def build(
continue
if any(x.endswith(".dist-info") for x in filename.parts):
continue
if filename.suffix in {".pyc", ".pyo"}:
if filename.suffix in exclude_exts:
continue
relpath = filename.relative_to(path)
if exclude_spec.match_file(relpath):
Expand Down
6 changes: 5 additions & 1 deletion src/scikit_build_core/build/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,11 @@ def _build_wheel_impl_impl(
),
wheel_dirs["metadata"],
) as wheel:
wheel.build(wheel_dirs, exclude=settings.wheel.exclude)
wheel.build(
wheel_dirs,
exclude=settings.wheel.exclude,
exclude_exts=settings.wheel.exclude_exts,
)

str_pkgs = (
str(Path.cwd().joinpath(p).parent.resolve()) for p in packages.values()
Expand Down
12 changes: 12 additions & 0 deletions src/scikit_build_core/settings/skbuild_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ class WheelSettings:
may not respect this exclusion.
"""

exclude_exts: List[str] = dataclasses.field(
default_factory=lambda: [".pyc", ".pyo"],
metadata=SettingsFieldMetadata(display_default="true"),
Comment on lines +313 to +314
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default_factory=lambda: [".pyc", ".pyo"],
metadata=SettingsFieldMetadata(display_default="true"),
default=[".pyc", ".pyo"],

display_default will show that literal text in the documentation, I believe you don't want it to display true there right? Also, the lambda is unnecessary.

)
"""
A set of file extensions to exclude from the wheel.

This is additive to the SDist/Wheel exclude patterns. This applies to the final paths
in the wheel, and can exclude files from CMake output as well. Editable installs
may not respect this exclusion.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a :::{versionadded} 0.12 in here and any other sphinx relevant parts you see fit.

"""

build_tag: str = ""
"""
The build tag to use for the wheel. If empty, no build tag is used.
Expand Down
Loading