Skip to content

🐛 fix(activation): honor .pth import precedence - #3727

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/adko-pth-precedence
Nov 20, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/adko-pth-precedence

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Previously, activate_this.py processed environment .pth files before moving environment libraries ahead of host paths. An executable .pth line could then import a same-name host module. During .pth processing, the script now puts interpreter libraries first, followed by environment libraries and host paths. Fixes #3623.

The temporary order keeps standard-library and GraalPy implementation modules ahead of site-packages. After site.addsitedir() runs, paths inserted by .pth hooks keep their positions ahead of the original host paths, including front insertions. Modules already loaded in sys.modules are not reloaded.

Reported by oss-scanner: ANT-2026-ADKO6NBD.

.pth imports run during site.addsitedir, before the old postprocessing
moved environment paths ahead of host paths. Put standard-library and
environment paths first for those imports, then restore the final order.

Fixes pypa#3623
@gaborbernat
gaborbernat force-pushed the fix/adko-pth-precedence branch from c1084fb to 6579d24 Compare November 20, 2026 15:27
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 16:27
@gaborbernat
gaborbernat merged commit c3c935d into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/adko-pth-precedence 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.

activate_this.py can resolve .pth imports from host first

1 participant