venv does not respect PYTHONDONTWRITEBYTECODE setting #98251
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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?
Ping @vsajip
(Discovered in a system where attempting to write .pyc files would break.)
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
vsajip commentedon Oct 14, 2022
Perhaps not - IIUC the
python -Im ensurepipwas 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 activesys.path(so overridingPYTHONHOMEandPYTHONPATHseems necessary) but I can't see any reason not to respect the otherPYTHON*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_