https://github.com/python/cpython/commit/876b1a5a8624d7c3394143967ab9072502a747f6
commit: 876b1a5a8624d7c3394143967ab9072502a747f6
branch: main
author: Ćukasz Langa <[email protected]>
committer: ambv <[email protected]>
date: 2026-10-21T16:36:39-07:00
summary:
gh-128779: Fix system site-packages test inside a virtual environment (#160133)
Use the base interpreter prefixes when expanding the system install scheme so
nested virtual environments are compared with the base interpreter
site-packages rather than the outer virtual environment.
Co-authored-by: Muse Code (Meta Muse Spark)
files:
M Lib/test/test_site.py
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 69e5ec25ca247e..9bc7bc8b710b57 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -618,9 +618,13 @@ def test_system_site_packages(self):
))
""")
- # Use _get_preferred_schemes to find the system scheme, in case we are
in a virtual environment
+ # Use the base interpreter's scheme and prefixes, even when running
+ # inside a virtual environment.
system_scheme_name = sysconfig._get_preferred_schemes()['prefix']
- system_paths = sysconfig.get_paths(system_scheme_name)
+ system_paths = sysconfig.get_paths(system_scheme_name, vars={
+ 'base': sys.base_prefix,
+ 'platbase': sys.base_exec_prefix,
+ })
with self.venv(system_site_packages=False) as venv:
sys_path = json.loads(venv.run('-c', script).stdout)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]