Skip to content

Commit d1c1355

Browse files
committed
tests: add a cross-compile test
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 7e5cf99 commit d1c1355

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/scikit_build_core/builder/cross_compile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from .._logging import logger
1111

12-
__all__ = ["set_cross_compile_env"]
12+
__all__ = ["set_cross_compile_env", "auto_cross_compile_env"]
1313

1414

1515
def __dir__() -> list[str]:

tests/test_cross_compile.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from __future__ import annotations
2+
3+
import os
4+
import subprocess
5+
import sys
6+
import sysconfig
7+
8+
import pytest
9+
10+
from scikit_build_core.builder.cross_compile import set_cross_compile_env
11+
12+
13+
@pytest.mark.skipif(
14+
sysconfig.get_config_var("SOABI") != "cp311-win_amd64",
15+
reason="Only tests 'cp311-win_amd64', got {sysconfig.get_config_var('SOABI')!r}",
16+
)
17+
def test_environment():
18+
env = os.environ.copy()
19+
cmd = [
20+
sys.executable,
21+
"-c",
22+
"import sysconfig; print(sysconfig.get_config_var('SOABI'), sysconfig.get_config_var('EXT_SUFFIX'))",
23+
]
24+
25+
with set_cross_compile_env(".cp311-win_arm64.pyd", env):
26+
result = subprocess.run(
27+
cmd, check=True, capture_output=True, text=True, env=env
28+
)
29+
soabi, ext_suffix = result.stdout.strip().split()
30+
assert soabi == "cp311-win_arm64"
31+
assert ext_suffix == ".cp311-win_arm64.pyd"
32+
33+
result = subprocess.run(cmd, check=True, capture_output=True, text=True, env=env)
34+
soabi, ext_suffix = result.stdout.strip().split()
35+
assert soabi == "cp311-win_amd64"
36+
assert ext_suffix == ".cp311-win_amd64.pyd"

0 commit comments

Comments
 (0)