Skip to content

GH-126985: Don't override venv detection with PYTHONHOME - #127968

Merged
FFY00 merged 1 commit into
python:mainfrom
FFY00:gh-126985-ignore-home-when-calculation-venv-prefix
Dec 15, 2024
Merged

GH-126985: Don't override venv detection with PYTHONHOME#127968
FFY00 merged 1 commit into
python:mainfrom
FFY00:gh-126985-ignore-home-when-calculation-venv-prefix

Conversation

@FFY00

@FFY00FFY00 commented Dec 15, 2024

Copy link
Copy Markdown
Member

PYTHONHOME should only override the base prefix calculation, it should have no effect on detecting if we are running inside a virtual environment.

PYTHONHOME should only override the base prefix calculation, it should
have no effect on detecting if we are running inside a virtual
environment.
Signed-off-by: Filipe Laíns <lains@riseup.net
@FFY00

FFY00 commented Dec 15, 2024

Copy link
Copy Markdown
MemberAuthor

Without the fix prefix and exec_prefix would be set to PYTHONHOME:

test test_getpath failed -- Traceback (most recent call last):
File "/home/anubis/git/cpython/Lib/test/test_getpath.py", line 865, in test_PYTHONHOME_in_venv
self.assertEqual(expected, actual)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
AssertionError: {'exe[37 chars]': '/venv', 'exec_prefix': '/venv', 'base_pref[206 chars]ad']} != {'exe[37 chars]': '/pythonhome', 'exec_prefix': '/pythonhome'[218 chars]ad']}
{'base_exec_prefix': '/pythonhome',
'base_prefix': '/pythonhome',
- 'exec_prefix': '/venv',
? ^ --
+ 'exec_prefix': '/pythonhome',
? ^^^^^^^^^
'executable': '/venv/bin/python',
'module_search_paths': ['/pythonhome/lib/python98.zip',
'/pythonhome/lib/python9.8',
'/pythonhome/lib/python9.8/lib-dynload'],
'module_search_paths_set': 1,
- 'prefix': '/venv'}
+ 'prefix': '/pythonhome'}

@FFY00FFY00 changed the title GH-126985: Don't override venv dectection whith PYTHONHOMEGH-126985: Don't override venv dectection with PYTHONHOMEDec 15, 2024
@FFY00FFY00 changed the title GH-126985: Don't override venv dectection with PYTHONHOMEGH-126985: Don't override venv detection with PYTHONHOMEDec 15, 2024
@FFY00
FFY00 merged commit b74c8f5 into python:mainDec 15, 2024
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@FFY00