ITADN

each_unignored_file does not handle Windows path separator

#1242Openltfish 创建于 2026-03-02
L
ltfishcommented
New logic is introduced in `_file_processor.py` (see [here](https://github.com/scikit-build/scikit-build-core/blob/dd8b099ef5530157ae518877122bb3c4d2d06b81/src/scikit_build_core/build/_file_processor.py#L92)) for pruning directories that do not start with an `include` directory. I copy-pasted the code snippet below. ```python if mode != "classic": for dname in dirs: if not match_path( dirpath, dirpath / dname, include_spec, global_exclude_spec, builtin_exclude_spec, user_exclude_spec, nested_excludes, is_path=True, ): # Check to see if any include rules start with this dstr = str(dirpath / dname).strip("/") + "/" if not any(p.lstrip("/").startswith(dstr) for p in include): dirs.remove(dname) ``` The above logic only works for Linux/macOS but fails on Windows, because on Windows `dstr` will contain Windows path separators (`\`) instead of `/`. All paths in `include` use `/` as the path separator. Therefore, all paths in `include` will not start with `dstr` on Windows, which leads to pruning directories incorrectly. One possible fix is changing `str(dirpath / dname).strip("/")` to `dstr = (dirpath / dname).as_posix().strip("/")`. I can submit a PR if you like, but you can also just fix it by yourself.
0 条评论