51
51
MAX_HASH_SEED = 4294967295
52
52
53
53
ABI_THREAD = 't' if sysconfig .get_config_var ('Py_GIL_DISABLED' ) else ''
54
+ # PLATSTDLIB_LANDMARK copied from Modules/getpath.py
55
+ if os .name == 'nt' :
56
+ PLATSTDLIB_LANDMARK = f'{ sys .platlibdir } '
57
+ else :
58
+ VERSION_MAJOR = sys .version_info .major
59
+ VERSION_MINOR = sys .version_info .minor
60
+ PLATSTDLIB_LANDMARK = (f'{ sys .platlibdir } /python{ VERSION_MAJOR } .'
61
+ f'{ VERSION_MINOR } { ABI_THREAD } /lib-dynload' )
54
62
55
63
56
64
# If we are running from a build dir, but the stdlib has been installed,
@@ -1596,7 +1604,13 @@ def test_init_pyvenv_cfg(self):
1596
1604
1597
1605
with self .tmpdir_with_python () as tmpdir , \
1598
1606
tempfile .TemporaryDirectory () as pyvenv_home :
1607
+
1599
1608
ver = sys .version_info
1609
+ base_prefix = sysconfig .get_config_var ("prefix" )
1610
+
1611
+ # gh-128690: base_exec_prefix depends if PLATSTDLIB_LANDMARK exists
1612
+ platstdlib = os .path .join (base_prefix , PLATSTDLIB_LANDMARK )
1613
+ change_exec_prefix = not os .path .isdir (platstdlib )
1600
1614
1601
1615
if not MS_WINDOWS :
1602
1616
lib_dynload = os .path .join (pyvenv_home ,
@@ -1620,7 +1634,8 @@ def test_init_pyvenv_cfg(self):
1620
1634
1621
1635
paths = self .module_search_paths ()
1622
1636
if not MS_WINDOWS :
1623
- paths [- 1 ] = lib_dynload
1637
+ if change_exec_prefix :
1638
+ paths [- 1 ] = lib_dynload
1624
1639
else :
1625
1640
paths = [
1626
1641
os .path .join (tmpdir , os .path .basename (paths [0 ])),
@@ -1630,16 +1645,16 @@ def test_init_pyvenv_cfg(self):
1630
1645
1631
1646
executable = self .test_exe
1632
1647
base_executable = os .path .join (pyvenv_home , os .path .basename (executable ))
1633
- exec_prefix = pyvenv_home
1634
1648
config = {
1635
- 'base_prefix' : sysconfig .get_config_var ("prefix" ),
1636
- 'base_exec_prefix' : exec_prefix ,
1649
+ 'base_prefix' : base_prefix ,
1637
1650
'exec_prefix' : tmpdir ,
1638
1651
'prefix' : tmpdir ,
1639
1652
'base_executable' : base_executable ,
1640
1653
'executable' : executable ,
1641
1654
'module_search_paths' : paths ,
1642
1655
}
1656
+ if change_exec_prefix :
1657
+ config ['base_exec_prefix' ] = pyvenv_home
1643
1658
if MS_WINDOWS :
1644
1659
config ['base_prefix' ] = pyvenv_home
1645
1660
config ['stdlib_dir' ] = os .path .join (pyvenv_home , 'Lib' )
0 commit comments