Skip to content

Commit

Permalink
tests: add a cross-compile test
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Jun 10, 2023
1 parent 7e5cf99 commit d1c1355
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scikit_build_core/builder/cross_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .._logging import logger

__all__ = ["set_cross_compile_env"]
__all__ = ["set_cross_compile_env", "auto_cross_compile_env"]


def __dir__() -> list[str]:
Expand Down
36 changes: 36 additions & 0 deletions tests/test_cross_compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from __future__ import annotations

import os
import subprocess
import sys
import sysconfig

import pytest

from scikit_build_core.builder.cross_compile import set_cross_compile_env


@pytest.mark.skipif(
sysconfig.get_config_var("SOABI") != "cp311-win_amd64",
reason="Only tests 'cp311-win_amd64', got {sysconfig.get_config_var('SOABI')!r}",
)
def test_environment():
env = os.environ.copy()
cmd = [
sys.executable,
"-c",
"import sysconfig; print(sysconfig.get_config_var('SOABI'), sysconfig.get_config_var('EXT_SUFFIX'))",
]

with set_cross_compile_env(".cp311-win_arm64.pyd", env):
result = subprocess.run(
cmd, check=True, capture_output=True, text=True, env=env
)
soabi, ext_suffix = result.stdout.strip().split()
assert soabi == "cp311-win_arm64"
assert ext_suffix == ".cp311-win_arm64.pyd"

result = subprocess.run(cmd, check=True, capture_output=True, text=True, env=env)
soabi, ext_suffix = result.stdout.strip().split()
assert soabi == "cp311-win_amd64"
assert ext_suffix == ".cp311-win_amd64.pyd"

0 comments on commit d1c1355

Please sign in to comment.