mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-115382: Fix cross compiles when host and target use same SOABI
Co-authored-by: Erlend E. Aasland <erlend@python.org>
This commit is contained in:
parent
aab3210271
commit
aecbc2e6f4
6 changed files with 19 additions and 3 deletions
|
@ -340,7 +340,20 @@ def _init_posix(vars):
|
|||
"""Initialize the module as appropriate for POSIX systems."""
|
||||
# _sysconfigdata is generated at build time, see _generate_posix_vars()
|
||||
name = _get_sysconfigdata_name()
|
||||
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
|
||||
|
||||
# For cross builds, the path to the target's sysconfigdata must be specified
|
||||
# so it can be imported. It cannot be in PYTHONPATH, as foreign modules in
|
||||
# sys.path can cause crashes when loaded by the host interpreter.
|
||||
# Rely on truthiness as a valueless env variable is still an empty string.
|
||||
# See OS X note in _generate_posix_vars re _sysconfigdata.
|
||||
if (path := os.environ.get('_PYTHON_SYSCONFIGDATA_PATH')):
|
||||
from importlib.machinery import FileFinder, SourceFileLoader, SOURCE_SUFFIXES
|
||||
from importlib.util import module_from_spec
|
||||
spec = FileFinder(path, (SourceFileLoader, SOURCE_SUFFIXES)).find_spec(name)
|
||||
_temp = module_from_spec(spec)
|
||||
spec.loader.exec_module(_temp)
|
||||
else:
|
||||
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
|
||||
build_time_vars = _temp.build_time_vars
|
||||
vars.update(build_time_vars)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue