Match dotfiles in sdist include/exclude glob patterns - #805
Open
aopv wants to merge 1 commit into
Open
Conversation
The sdist include/exclude patterns were expanded with the stdlib glob module, whose wildcards do not match files whose names start with a dot. As a result a recursive pattern such as ``exclude = ["**/*.swp"]`` failed to exclude editor swap files like ``.foo.py.swp`` from the sdist. Expand the patterns with pathlib.Path.glob instead, which matches dotfiles by default and keeps the same recursive ``**`` semantics. This avoids glob's include_hidden option, which is only available on Python 3.11+, so it works on flit_core's minimum supported Python (3.8). Fixes pypa#746.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sdist
includeandexcludepatterns were expanded using the stdlibglobmodule.glob's wildcards do not match files whose names start with a dot, so a recursive pattern such as:failed to exclude editor swap files like
.foo.py.swpfrom the sdist, even though the docs advertise recursive**support. As reported in #746, an explicit full path to a dotfile did exclude it, but a**glob pattern did not, becauseglobskips dotfiles by default.Fix
flit_core/flit_core/sdist.pynow expands the patterns withpathlib.Path.globinstead ofglob.glob(..., recursive=True).Path.globmatches dotfiles by default and preserves the same recursive**semantics (including matching entries in the base directory). This deliberately avoidsglob'sinclude_hiddenkeyword, which is only available on Python 3.11+, so the fix works onflit_core's minimum supported Python (3.8).Tests / Verification
inclusionsample fixture with a hidden filedoc/subdir/.hidden.swpand anexcludeentrydoc/**/*.swp, and added an assertion totest_include_excludethat the dotfile is excluded.flit_coretest suite (flit_core/tests_core/) plus the top-leveltests/test_sdist.py: all green (218 passed, 1 pre-existing skip).doc/history.rstentry.Disclosure: prepared with AI assistance; reviewed and verified locally.