-
-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix pkg resource early import #750
Fix pkg resource early import #750
Conversation
…ate pkg_resources from namespace package
The CI error is reproducible locally. I'm taking a look... |
Remove a duplicate and buggy use of `pex_path` in `Pex.patch_sys`, fixup tests and "privatize" `PEXEnvironment` methods as appropriate for clarity.
+ Ensure pexes are added to the sys.path exactly once. + Surface explicit handling for the empty ns package list behavior seen in the wild - only consider non-empty lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this as it now stands. Since I added changes significant enough to fix failing tests, this should really get one more review before merging.
@jhamet93 could you please review the changes I made on top of yours? They are these: https://github.com/pantsbuild/pex/pull/750/files/62af44be964f6f916810a3ac4622241da1b34ff0..0489225aaa65cd41250b708e9210dd47a7e20695 Any comments would be great and if all looks good a LGTM would be good. Thanks for your contribution! |
LGTM. Thanks for the help finishing this one! |
As referenced in #749 , I ran into a situation where
pkg_resources
was imported too early beforesys.path
was finalized, occurring in the situation where a pex in myPEX_PATH
needed to invoke:pkg_resources.get_distribution
. This was failing because a namespace package causedpkg_resources
to be imported before the other pexes were merged into the environmentTherefore, wait until all deps from all pexes (i.e. pexes in
PEX_PATH
) have been resolved before attempting to declare the namespace packages. This ensuressys.path
is finalized beforepkg_resources
is possibly imported.