linkedin / shiv

shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
BSD 2-Clause "Simplified" License
1.73k stars 94 forks source link

Fix default sys.path injected into PYTHONPATH #229

Closed f3flight closed 1 year ago

f3flight commented 1 year ago

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.

lorencarvalho commented 1 year ago

Thanks @f3flight !