When we invoke pip, we use -I to avoid interference from other variables. However, this also means that we ignore legitimate user preferences that ought to be retained. We probably want PYTHONDONTWRITEBYTECODE, PYTHONUTF8, PYTHONIOENCODING, PYTHONMALLOC, PYTHONCOERCECLOCALE, PYTHONPYCACHEPREFIX at least, and maybe more (I just went through the help output of 3.10).
Interestingly, we don't use isolated mode later on when we upgrade the packages, so maybe we don't need it at all? Or perhaps we should be in some middle ground where we override PYTHONPATH and PYTHONHOME to point at the venv/be empty but leave everything else in place?
Perhaps not - IIUC the python -Im ensurepip was added by @ncoghlan originally, and I don't know what the logic was for the decision to use -I. From my perspective, a venv should only change the active sys.path (so overriding PYTHONHOME and PYTHONPATH seems necessary) but I can't see any reason not to respect the other PYTHON* environment variables.
Activity
vsajip commented on Oct 14, 2022
Perhaps not - IIUC the python -Im ensurepip was added by @ncoghlan originally, and I don't know what the logic was for the decision to use -I. From my perspective, a venv should only change the active sys.path (so overriding PYTHONHOME and PYTHONPATH seems necessary) but I can't see any reason not to respect the other PYTHON* environment variables.
pythongh-98251: Allow venv to pass along PYTHON* variables to pip whe…
gh-98251: Allow venv to pass along PYTHON* variables to pip and ensur…
pythongh-98251: Allow venv to pass along PYTHON* variables to pip and…
pythongh-98251: Allow venv to pass along PYTHON* variables to pip and…
gh-98251: Allow venv to pass along PYTHON* variables to pip and ensur…
gh-98251: Allow venv to pass along PYTHON* variables to pip and ensur…
Merge branch 'main' into typewatch
Merge branch 'main' into cached_property
various fixes
backport the fix for python/cpython#98251 _correctly_