sashahart / vex

Run a command in the named virtualenv.
MIT License
372 stars 26 forks source link

Remove __PYVENV_LAUNCHER__ from the environment for child processes. #62

Open dmcooke opened 4 years ago

dmcooke commented 4 years ago

For framework builds of Python on macOS, if __PYVENV_LAUNCHER__ exists, it's used as the value of sys.executable, and thus is used as the base for a raft of values, including the system directories in sys.path. (See: site.py in Python source)

Additionally, python sets this in the environment for subprocesses, as a way to get around some technical issues with launching scripts that use the GUI. (See: Mac/Tools/pythonw.c in Python source)

Thus, when vex exec's /bin/python, the python launched thinks it's actually vex's python, at /opt/local/bin/python (or whatever), and so adds the non-virtualenv paths to sys.path.