Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

venv does not respect PYTHONDONTWRITEBYTECODE setting #98251

Closed
zooba opened this issue Oct 13, 2022 · 1 comment
Closed

venv does not respect PYTHONDONTWRITEBYTECODE setting #98251

zooba opened this issue Oct 13, 2022 · 1 comment
Assignees
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@zooba
Copy link
Member

zooba commented Oct 13, 2022

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.)

@zooba zooba added type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.10 only security fixes 3.12 bugs and security fixes labels Oct 13, 2022
@vsajip
Copy link
Member

vsajip commented Oct 14, 2022

so maybe we don't need it [python -I] at all?

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.

@zooba zooba self-assigned this Oct 14, 2022
zooba added a commit to zooba/cpython that referenced this issue Oct 14, 2022
zooba added a commit that referenced this issue Oct 14, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 14, 2022
… ensurepip when they do not impact path resolution (pythonGH-98259)

(cherry picked from commit 2fe44f7)

Co-authored-by: Steve Dower <steve.dower@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 14, 2022
… ensurepip when they do not impact path resolution (pythonGH-98259)

(cherry picked from commit 2fe44f7)

Co-authored-by: Steve Dower <steve.dower@python.org>
@zooba zooba closed this as completed Oct 14, 2022
miss-islington added a commit that referenced this issue Oct 14, 2022
…epip when they do not impact path resolution (GH-98259)

(cherry picked from commit 2fe44f7)

Co-authored-by: Steve Dower <steve.dower@python.org>
miss-islington added a commit that referenced this issue Oct 14, 2022
…epip when they do not impact path resolution (GH-98259)

(cherry picked from commit 2fe44f7)

Co-authored-by: Steve Dower <steve.dower@python.org>
carljm added a commit to carljm/cpython that referenced this issue Oct 14, 2022
* main: (38 commits)
  pythongh-98251: Allow venv to pass along PYTHON* variables to pip and ensurepip when they do not impact path resolution (pythonGH-98259)
  Bpo-41246: IOCP Proactor avoid callback code duplication (python#21399)
  bpo-46364: Use sockets for stdin of asyncio only on AIX (python#30596)
  pythongh-98178: syslog() is not thread-safe on macOS (python#98213)
  Mark all targets in `Doc/Makefile` as `PHONY` (pythonGH-98189)
  pythongh-97982: Factorize PyUnicode_Count() and unicode_count() code (python#98025)
  pythongh-96265: Formatting changes for faq/general (python#98129)
  tutorial: remove "with single quotes" (python#98204)
  pythongh-97669: Remove Tools/scripts/startuptime.py (python#98214)
  signalmodule.c uses _PyErr_WriteUnraisableMsg() (python#98217)
  pythongh-97669: Fix test_tools reference leak (python#98216)
  pythongh-97669: Create Tools/patchcheck/ directory (python#98186)
  pythongh-65046: Link to logging cookbook from asyncio docs (python#98207)
  Formatting fixes in contextlib docs (python#98111)
  pythongh-95276: Add callable entry to the glossary (python#95738)
  pythongh-96130: Rephrase use of "typecheck" verb for clarity (python#98144)
  Fix some incorrect indentation around the main switch (python#98177)
  pythongh-98172: Fix formatting in `except*` docs (python#98173)
  pythongh-97982: Remove asciilib_count() (python#98164)
  pythongh-95756: Free and NULL-out code caches when needed (pythonGH-98181)
  ...
carljm added a commit to carljm/cpython that referenced this issue Oct 14, 2022
* main: (37 commits)
  pythongh-98251: Allow venv to pass along PYTHON* variables to pip and ensurepip when they do not impact path resolution (pythonGH-98259)
  Bpo-41246: IOCP Proactor avoid callback code duplication (python#21399)
  bpo-46364: Use sockets for stdin of asyncio only on AIX (python#30596)
  pythongh-98178: syslog() is not thread-safe on macOS (python#98213)
  Mark all targets in `Doc/Makefile` as `PHONY` (pythonGH-98189)
  pythongh-97982: Factorize PyUnicode_Count() and unicode_count() code (python#98025)
  pythongh-96265: Formatting changes for faq/general (python#98129)
  tutorial: remove "with single quotes" (python#98204)
  pythongh-97669: Remove Tools/scripts/startuptime.py (python#98214)
  signalmodule.c uses _PyErr_WriteUnraisableMsg() (python#98217)
  pythongh-97669: Fix test_tools reference leak (python#98216)
  pythongh-97669: Create Tools/patchcheck/ directory (python#98186)
  pythongh-65046: Link to logging cookbook from asyncio docs (python#98207)
  Formatting fixes in contextlib docs (python#98111)
  pythongh-95276: Add callable entry to the glossary (python#95738)
  pythongh-96130: Rephrase use of "typecheck" verb for clarity (python#98144)
  Fix some incorrect indentation around the main switch (python#98177)
  pythongh-98172: Fix formatting in `except*` docs (python#98173)
  pythongh-97982: Remove asciilib_count() (python#98164)
  pythongh-95756: Free and NULL-out code caches when needed (pythonGH-98181)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants