Skip to content

Commit a8fc09e

Browse files
committed
gh-128779: Fix system site-packages test inside a virtual environment
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)
1 parent 6839f8c commit a8fc09e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎Lib/test/test_site.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,13 @@ def test_system_site_packages(self):
618618
))
619619
""")
620620

621-
# Use _get_preferred_schemes to find the system scheme, in case we are in a virtual environment
621+
# Use the base interpreter's scheme and prefixes, even when running
622+
# inside a virtual environment.
622623
system_scheme_name = sysconfig._get_preferred_schemes()['prefix']
623-
system_paths = sysconfig.get_paths(system_scheme_name)
624+
system_paths = sysconfig.get_paths(system_scheme_name, vars={
625+
'base': sys.base_prefix,
626+
'platbase': sys.base_exec_prefix,
627+
})
624628

625629
with self.venv(system_site_packages=False) as venv:
626630
sys_path = json.loads(venv.run('-c', script).stdout)

0 commit comments

Comments
 (0)