Skip to content

venv does not respect PYTHONDONTWRITEBYTECODE setting #98251

Description

@zooba

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.10only security fixes3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions