Skip to content
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 default sys.path injected into PYTHONPATH #229

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

f3flight
Copy link
Contributor

@f3flight f3flight commented Nov 2, 2022

When SHIV_EXTEND_PYTHONPATH is used, PYTHONPATH env variable gets not only zipapp site-packages and other new stuff, but also the default sys.path of the current Python (for ex. Python3.10). This breaks ability to run a different version of Python in a subprocess, because PYTHONPATH takes precedence over default sys.path, and so a subprocess starting Python3.9 will attempt to use Python 3.10 builtin modules, and will most likely break in unpredictable ways. This change fixes that by only adding new paths which appear after injecting zipapp site-packages.

When SHIV_EXTED_PYTHONPATH is used, PYTHONPATH env variable gets not only
zipapp sit-packages and other new stuff, but also the default sys.path
of the current Python (for ex. Python3.10). This breaks ability to run
a different version of Python in a subprocess, because PYTHONPATH takes
precedence over default sys.path, and so a subprocess starting Python3.9
will attempt to use Python 3.10 builtin modules, and will most likely break
in unpredictable ways. This change fixes that by only adding new paths
which appear after injecting zipapp site-packages.
@f3flight f3flight changed the title Fix python-version-specific paths in PYTHONPATH Fix default sys.path injected into PYTHONPATH Nov 2, 2022
@lorencarvalho lorencarvalho merged commit 2c44b7a into linkedin:main Nov 2, 2022
@lorencarvalho
Copy link
Contributor

Thanks @f3flight !

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.

2 participants