Skip to content

Commit c915d32

Browse files
committed
fix: ignore build dir automatically
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 4fbd3b7 commit c915d32

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

Diff for: src/scikit_build_core/build/_file_processor.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def each_unignored_file(
3232
starting_path: Path,
3333
include: Sequence[str] = (),
3434
exclude: Sequence[str] = (),
35+
build_dir: str = "",
3536
) -> Generator[Path, None, None]:
3637
"""
3738
Runs through all non-ignored files. Must be run from the root directory.
@@ -50,9 +51,19 @@ def each_unignored_file(
5051
if p != Path(".gitignore")
5152
}
5253

54+
exclude_build_dir = build_dir.format(
55+
cache_tag="*",
56+
wheel_tag="*",
57+
build_type="*",
58+
state="*",
59+
)
60+
exclude_lines = (
61+
f"{EXCLUDE_LINES}\n{exclude_build_dir}" if exclude_build_dir else EXCLUDE_LINES
62+
)
63+
5364
user_exclude_spec = pathspec.GitIgnoreSpec.from_lines(list(exclude))
5465
global_exclude_spec = pathspec.GitIgnoreSpec.from_lines(global_exclude_lines)
55-
builtin_exclude_spec = pathspec.GitIgnoreSpec.from_lines(EXCLUDE_LINES)
66+
builtin_exclude_spec = pathspec.GitIgnoreSpec.from_lines(exclude_lines)
5667

5768
include_spec = pathspec.GitIgnoreSpec.from_lines(include)
5869

Diff for: src/scikit_build_core/build/_pathutil.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def packages_to_file_mapping(
4141
include: Sequence[str],
4242
src_exclude: Sequence[str],
4343
target_exclude: Sequence[str],
44+
build_dir: str,
4445
) -> dict[str, str]:
4546
"""
4647
This will output a mapping of source files to target files.
@@ -55,6 +56,7 @@ def packages_to_file_mapping(
5556
source_dir,
5657
include=include,
5758
exclude=src_exclude,
59+
build_dir=build_dir,
5860
):
5961
rel_path = filepath.relative_to(source_dir)
6062
target_path = platlib_dir / package_dir / rel_path

Diff for: src/scikit_build_core/build/sdist.py

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def build_sdist(
154154
Path(),
155155
include=settings.sdist.include,
156156
exclude=settings.sdist.exclude,
157+
build_dir=settings.build_dir,
157158
)
158159
)
159160
for filepath in paths:

Diff for: src/scikit_build_core/build/wheel.py

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ def _build_wheel_impl_impl(
467467
include=settings.sdist.include,
468468
src_exclude=settings.sdist.exclude,
469469
target_exclude=settings.wheel.exclude,
470+
build_dir=settings.build_dir,
470471
)
471472

472473
if not editable:

Diff for: tests/test_editable_unit.py

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_navigate_editable_pkg(editable_package: EditablePackage, virtualenv: VE
141141
include=[],
142142
src_exclude=[],
143143
target_exclude=[],
144+
build_dir="",
144145
)
145146
assert mapping == {
146147
str(Path("pkg/__init__.py")): str(pkg_dir / "__init__.py"),

0 commit comments

Comments
 (0)