Skip to content

Restore exclude/artifacts pattern support for force-include directories - #2347

Open
pctablet505 wants to merge 2 commits into
pypa:masterfrom
pctablet505:force-include-respect-exclude
Open

Restore exclude/artifacts pattern support for force-include directories#2347
pctablet505 wants to merge 2 commits into
pypa:masterfrom
pctablet505:force-include-respect-exclude

Conversation

@pctablet505

Copy link
Copy Markdown

Directories added via force-include used to have their contents filtered by the exclude and artifacts patterns (added in #297), but this got silently dropped when recurse_forced_files was split out from the shared file-selection logic in #299 (when only-include was introduced). Since then there's been no way to exclude specific files under a force-included directory.

This restores the old include_forced_path check for directory sources in force-include. To keep it correct, it uses a new forced_path_is_excluded helper rather than reusing path_is_excluded directly, 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

  • Added unit tests covering force-include + exclude, and force-include + exclude + artifacts (artifacts should still override exclude).
  • Added an integration-level test using WheelBuilder for the case where force-include is the only file-selection option configured (the trickiest interaction, due to the "exclude everything" flag mentioned above).
  • Ran the full tests/backend suite (939 passed) plus ruff check, ruff format --check, and mypy on the touched files.

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
pctablet505 marked this pull request as ready for review July 17, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does force-include support glob pattern to filter files force include vs exclude patterns?

2 participants