Skip to content

Commit f7b210a

Browse files
committed
Improve .gitignore iteration speed
1 parent 73e44ce commit f7b210a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/scikit_build_core/build/_file_processor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ def each_unignored_file(
4646
global_exclude_lines += f.readlines()
4747

4848
nested_excludes = {
49-
p.parent: pathspec.GitIgnoreSpec.from_lines(
50-
p.read_text(encoding="utf-8").splitlines()
49+
dirpath: pathspec.GitIgnoreSpec.from_lines(
50+
(Path(dirpath) / filename).read_text(encoding="utf-8").splitlines()
5151
)
52-
for p in Path().rglob("**/.gitignore")
53-
if p != Path(".gitignore")
52+
for dirpath, _, filenames in os.walk(".")
53+
for filename in filenames
54+
if filename == ".gitignore" and dirpath != "."
5455
}
5556

5657
exclude_build_dir = build_dir.format(**pyproject_format(dummy=True))

0 commit comments

Comments
 (0)