Skip to content

🐛 fix(create): keep distutils paths inside environments - #3696

Merged
gaborbernat merged 4 commits into
pypa:mainfrom
gaborbernat:fix/filter-distutils-after-decode-error
Nov 20, 2026
Merged

gaborbernat merged 4 commits into
pypa:mainfrom
gaborbernat:fix/filter-distutils-after-decode-error

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Python 3.9 environments could install packages outside the environment when distutils configuration set an install directory. A later config decode error left earlier options in place, and install_lib could also override the destination. The hook now filters those options after a successful parse or a decoding error. Fixes #3602. Fixes #3606.

The hook removes config-file destinations for the install command and its subcommands, including install_egg_info, so package metadata stays with the installed package. It keeps an explicit environment prefix so distutils resolves the remaining defaults inside the environment. A decoding error still aborts parsing.

A Python 3.9 environment registers the distutils import hook. On newer interpreters it stays inactive even if they load a Python 3.9 environment's .pth file. Raising the minimum Python version to 3.10 makes Ruff flag the registration for removal.

Reported by oss-scanner: ANT-2026-7PG08GIP, ANT-2026-YQ6XOMQR.

@gaborbernat
gaborbernat force-pushed the fix/filter-distutils-after-decode-error branch from c09bb0b to d68d861 Compare November 20, 2026 15:13
@gaborbernat gaborbernat changed the title 🐛 fix(create): filter paths after config errors 🐛 fix(create): keep distutils paths inside environments Nov 20, 2026
Parsing can leave unsafe options behind after a decoding error. Distutils
also accepts destinations on install subcommands. Filter both forms before
an install uses the partial configuration.
@gaborbernat
gaborbernat force-pushed the fix/filter-distutils-after-decode-error branch from d68d861 to 4532005 Compare November 20, 2026 15:31
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 16:49
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 20:26
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 20:47
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 20:56
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 22:11
@gaborbernat
gaborbernat merged commit 3e8e771 into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/filter-distutils-after-decode-error branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3.9 distutils hook leaves install_lib override active Python 3.9 distutils filter skips a decoding error

1 participant