Restore exclude/artifacts pattern support for force-include directories - #2347
Open
pctablet505 wants to merge 2 commits into
Open
Restore exclude/artifacts pattern support for force-include directories#2347pctablet505 wants to merge 2 commits into
pctablet505 wants to merge 2 commits into
Conversation
Directories added via `force-include` used to have their contents filtered by the `exclude` and `artifacts` patterns (added in pypa#297), but this was silently dropped when `recurse_forced_files` was split out from the shared file-selection code in pypa#299. Since then there has been no way to exclude files under a force-included directory. This restores the `include_forced_path` check for directory sources, using a dedicated `forced_path_is_excluded` helper so the "exclude everything" mode used for default project file selection (when force-include is the sole selection mechanism) doesn't also blank out the forced files themselves. Fixes pypa#2090, fixes pypa#1989
pctablet505
marked this pull request as ready for review
July 17, 2026 12:47
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.
Directories added via
force-includeused to have their contents filtered by theexcludeandartifactspatterns (added in #297), but this got silently dropped whenrecurse_forced_fileswas split out from the shared file-selection logic in #299 (whenonly-includewas introduced). Since then there's been no way to exclude specific files under a force-included directory.This restores the old
include_forced_pathcheck for directory sources inforce-include. To keep it correct, it uses a newforced_path_is_excludedhelper rather than reusingpath_is_excludeddirectly, since the latter also honors the "exclude everything" flag that's set when force-include is the sole file-selection mechanism for a build target — that flag is meant to blank out the default project file walk, not the forced files themselves.Closes #2090
Closes #1989
Testing
force-include+exclude, andforce-include+exclude+artifacts(artifacts should still override exclude).WheelBuilderfor the case whereforce-includeis the only file-selection option configured (the trickiest interaction, due to the "exclude everything" flag mentioned above).tests/backendsuite (939 passed) plusruff check,ruff format --check, andmypyon the touched files.