mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-128690: Update test_embed for getpath.py exec_prefix change (#129137)
This commit is contained in:
parent
a95dca7b98
commit
b23b27bc55
1 changed files with 19 additions and 4 deletions
|
@ -51,6 +51,14 @@ INIT_LOOPS = 4
|
||||||
MAX_HASH_SEED = 4294967295
|
MAX_HASH_SEED = 4294967295
|
||||||
|
|
||||||
ABI_THREAD = 't' if sysconfig.get_config_var('Py_GIL_DISABLED') else ''
|
ABI_THREAD = 't' if sysconfig.get_config_var('Py_GIL_DISABLED') else ''
|
||||||
|
# PLATSTDLIB_LANDMARK copied from Modules/getpath.py
|
||||||
|
if os.name == 'nt':
|
||||||
|
PLATSTDLIB_LANDMARK = f'{sys.platlibdir}'
|
||||||
|
else:
|
||||||
|
VERSION_MAJOR = sys.version_info.major
|
||||||
|
VERSION_MINOR = sys.version_info.minor
|
||||||
|
PLATSTDLIB_LANDMARK = (f'{sys.platlibdir}/python{VERSION_MAJOR}.'
|
||||||
|
f'{VERSION_MINOR}{ABI_THREAD}/lib-dynload')
|
||||||
|
|
||||||
|
|
||||||
# If we are running from a build dir, but the stdlib has been installed,
|
# If we are running from a build dir, but the stdlib has been installed,
|
||||||
|
@ -1596,7 +1604,13 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
|
|
||||||
with self.tmpdir_with_python() as tmpdir, \
|
with self.tmpdir_with_python() as tmpdir, \
|
||||||
tempfile.TemporaryDirectory() as pyvenv_home:
|
tempfile.TemporaryDirectory() as pyvenv_home:
|
||||||
|
|
||||||
ver = sys.version_info
|
ver = sys.version_info
|
||||||
|
base_prefix = sysconfig.get_config_var("prefix")
|
||||||
|
|
||||||
|
# gh-128690: base_exec_prefix depends if PLATSTDLIB_LANDMARK exists
|
||||||
|
platstdlib = os.path.join(base_prefix, PLATSTDLIB_LANDMARK)
|
||||||
|
change_exec_prefix = not os.path.isdir(platstdlib)
|
||||||
|
|
||||||
if not MS_WINDOWS:
|
if not MS_WINDOWS:
|
||||||
lib_dynload = os.path.join(pyvenv_home,
|
lib_dynload = os.path.join(pyvenv_home,
|
||||||
|
@ -1620,6 +1634,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
|
|
||||||
paths = self.module_search_paths()
|
paths = self.module_search_paths()
|
||||||
if not MS_WINDOWS:
|
if not MS_WINDOWS:
|
||||||
|
if change_exec_prefix:
|
||||||
paths[-1] = lib_dynload
|
paths[-1] = lib_dynload
|
||||||
else:
|
else:
|
||||||
paths = [
|
paths = [
|
||||||
|
@ -1630,16 +1645,16 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
|
|
||||||
executable = self.test_exe
|
executable = self.test_exe
|
||||||
base_executable = os.path.join(pyvenv_home, os.path.basename(executable))
|
base_executable = os.path.join(pyvenv_home, os.path.basename(executable))
|
||||||
exec_prefix = pyvenv_home
|
|
||||||
config = {
|
config = {
|
||||||
'base_prefix': sysconfig.get_config_var("prefix"),
|
'base_prefix': base_prefix,
|
||||||
'base_exec_prefix': exec_prefix,
|
|
||||||
'exec_prefix': tmpdir,
|
'exec_prefix': tmpdir,
|
||||||
'prefix': tmpdir,
|
'prefix': tmpdir,
|
||||||
'base_executable': base_executable,
|
'base_executable': base_executable,
|
||||||
'executable': executable,
|
'executable': executable,
|
||||||
'module_search_paths': paths,
|
'module_search_paths': paths,
|
||||||
}
|
}
|
||||||
|
if change_exec_prefix:
|
||||||
|
config['base_exec_prefix'] = pyvenv_home
|
||||||
if MS_WINDOWS:
|
if MS_WINDOWS:
|
||||||
config['base_prefix'] = pyvenv_home
|
config['base_prefix'] = pyvenv_home
|
||||||
config['stdlib_dir'] = os.path.join(pyvenv_home, 'Lib')
|
config['stdlib_dir'] = os.path.join(pyvenv_home, 'Lib')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue