Skip to content

Commit d89292c

Browse files
committed
Correct cross-env script to include prefixes.
1 parent a03a047 commit d89292c

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

patch/Python/_cross_target.py.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import sysconfig
1212
sys.cross_compiling = True
1313
sys.platform = "{{platform}}"
1414
sys.implementation._multiarch = "{{arch}}-{{sdk}}"
15+
sys.base_prefix = sysconfig.get_config_var("prefix")
16+
sys.base_exec_prefix = sysconfig.get_config_var("prefix")
1517

1618
###########################################################################
1719
# subprocess module patches
@@ -74,5 +76,9 @@ def cross_get_sysconfigdata_name():
7476
sysconfig.get_platform = cross_get_platform
7577
sysconfig._get_sysconfigdata_name = cross_get_sysconfigdata_name
7678

79+
# Ensure module-level values cached at time of import are updated.
80+
sysconfig._BASE_PREFIX = sys.base_prefix
81+
sysconfig._BASE_EXEC_PREFIX = sys.base_exec_prefix
82+
7783
# Force sysconfig data to be loaded (and cached).
7884
sysconfig._init_config_vars()

tests/test_cross_env.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
# Determine some file system anchor points for the tests
1616
# Assumes that the tests are run in a virtual environment named
1717
# `cross-venv`,
18-
VENV_PREFIX = Path(__file__).parent.parent / "cross-venv"
19-
default_support_base = f"support/{sys.version_info.major}.{sys.version_info.minor}/{PYTHON_CROSS_PLATFORM}"
18+
VENV_PREFIX = os.getenv("VIRTUAL_ENV", Path(__file__).parent.parent / "cross-venv")
19+
default_support_base = (
20+
f"support/{sys.version_info.major}.{sys.version_info.minor}/{PYTHON_CROSS_PLATFORM}"
21+
)
2022
SUPPORT_PREFIX = (
2123
Path(__file__).parent.parent
2224
/ os.getenv("PYTHON_SUPPORT_BASE", default_support_base)
@@ -29,6 +31,7 @@
2931
# sys
3032
###########################################################################
3133

34+
3235
def test_sys_platform():
3336
assert sys.platform == PYTHON_CROSS_PLATFORM.lower()
3437

@@ -53,6 +56,7 @@ def test_sys_base_exec_prefix():
5356
# platform
5457
###########################################################################
5558

59+
5660
def test_platform_system():
5761
assert platform.system() == PYTHON_CROSS_PLATFORM
5862

@@ -61,6 +65,7 @@ def test_platform_system():
6165
# sysconfig
6266
###########################################################################
6367

68+
6469
def test_sysconfig_get_platform():
6570
parts = sysconfig.get_platform().split("-", 2)
6671
assert parts[0] == PYTHON_CROSS_PLATFORM.lower()
@@ -87,7 +92,7 @@ def test_sysconfig_get_sysconfigdata_name():
8792
("platlib", VENV_PREFIX),
8893
("scripts", VENV_PREFIX),
8994
("data", VENV_PREFIX),
90-
]
95+
],
9196
)
9297
def test_sysconfig_get_paths(name, prefix):
9398
assert sysconfig.get_paths()[name].startswith(str(prefix))

0 commit comments

Comments
 (0)