replit / prybar

Pry open those interpreters.
GNU General Public License v2.0
253 stars 52 forks source link

prybar-python3 honors $VIRTUAL_ENV #53

Closed dan-stowell closed 4 years ago

dan-stowell commented 4 years ago

An embedded python interpreter computes sys.path based on the prefix of the interpreter name: https://docs.python.org/3/c-api/init.html#c.Py_SetProgramName

To make sure sys.path is set correctly (and the appropriate sitecustomize.py is loaded if present) when a virtualenv is activated, the program name needs to start with the virtualenv path. At startup, prybar-python3 looks for the $VIRTUAL_ENV environment variable and, if present, sets the program name to $VIRTUAL_ENV/bin/prybar-python3.

Testing this path requires adding machinery to the prybar tests. I don't want to take the time to add that machinery now, but I have tested this branch in polygott and it does indeed set the correct path.

replbot commented 4 years ago

unbooping: approved