Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore build dir automatically #916

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
13 changes: 12 additions & 1 deletion src/scikit_build_core/build/_file_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def each_unignored_file(
starting_path: Path,
include: Sequence[str] = (),
exclude: Sequence[str] = (),
build_dir: str = "",
) -> Generator[Path, None, None]:
"""
Runs through all non-ignored files. Must be run from the root directory.
Expand All @@ -50,9 +51,19 @@ def each_unignored_file(
if p != Path(".gitignore")
}

exclude_build_dir = build_dir.format(
cache_tag="*",
wheel_tag="*",
build_type="*",
state="*",
)
exclude_lines = (
f"{EXCLUDE_LINES}\n{exclude_build_dir}" if exclude_build_dir else EXCLUDE_LINES
)

user_exclude_spec = pathspec.GitIgnoreSpec.from_lines(list(exclude))
global_exclude_spec = pathspec.GitIgnoreSpec.from_lines(global_exclude_lines)
builtin_exclude_spec = pathspec.GitIgnoreSpec.from_lines(EXCLUDE_LINES)
builtin_exclude_spec = pathspec.GitIgnoreSpec.from_lines(exclude_lines)

include_spec = pathspec.GitIgnoreSpec.from_lines(include)

Expand Down
2 changes: 2 additions & 0 deletions src/scikit_build_core/build/_pathutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def packages_to_file_mapping(
include: Sequence[str],
src_exclude: Sequence[str],
target_exclude: Sequence[str],
build_dir: str,
) -> dict[str, str]:
"""
This will output a mapping of source files to target files.
Expand All @@ -55,6 +56,7 @@ def packages_to_file_mapping(
source_dir,
include=include,
exclude=src_exclude,
build_dir=build_dir,
):
rel_path = filepath.relative_to(source_dir)
target_path = platlib_dir / package_dir / rel_path
Expand Down
1 change: 1 addition & 0 deletions src/scikit_build_core/build/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def build_sdist(
Path(),
include=settings.sdist.include,
exclude=settings.sdist.exclude,
build_dir=settings.build_dir,
)
)
for filepath in paths:
Expand Down
1 change: 1 addition & 0 deletions src/scikit_build_core/build/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ def _build_wheel_impl_impl(
include=settings.sdist.include,
src_exclude=settings.sdist.exclude,
target_exclude=settings.wheel.exclude,
build_dir=settings.build_dir,
)

if not editable:
Expand Down
1 change: 1 addition & 0 deletions tests/test_editable_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def test_navigate_editable_pkg(editable_package: EditablePackage, virtualenv: VE
include=[],
src_exclude=[],
target_exclude=[],
build_dir="",
)
assert mapping == {
str(Path("pkg/__init__.py")): str(pkg_dir / "__init__.py"),
Expand Down
Loading