2026-05-28 00:20:08 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2020-05-02 22:50:52 +01:00
|
|
|
import platform
|
|
|
|
|
import textwrap
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2021-01-06 13:50:58 -05:00
|
|
|
from . import test_projects, utils
|
2020-05-02 16:54:19 +01:00
|
|
|
|
2026-05-28 00:20:08 +02:00
|
|
|
TYPE_CHECKING = False
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2020-05-17 16:54:33 +01:00
|
|
|
dockcross_only_project = test_projects.new_c_project(
|
2021-04-30 17:56:34 -04:00
|
|
|
setup_py_add=textwrap.dedent(
|
2021-05-03 11:45:43 -04:00
|
|
|
r"""
|
2021-02-18 08:15:37 +01:00
|
|
|
import os
|
2020-05-02 16:54:19 +01:00
|
|
|
|
|
|
|
|
# check that we're running in the correct docker image as specified in the
|
2025-03-22 17:26:38 +01:00
|
|
|
# environment options CIBW_MANYLINUX_*_IMAGE
|
2020-05-02 16:54:19 +01:00
|
|
|
if "linux" in sys.platform and not os.path.exists("/dockcross"):
|
|
|
|
|
raise Exception(
|
|
|
|
|
"/dockcross directory not found. Is this test running in the correct docker image?"
|
|
|
|
|
)
|
2021-05-03 11:45:43 -04:00
|
|
|
"""
|
2021-04-30 17:56:34 -04:00
|
|
|
)
|
2020-05-02 16:54:19 +01:00
|
|
|
)
|
|
|
|
|
|
2020-05-02 22:50:52 +01:00
|
|
|
|
2023-08-07 18:01:10 +02:00
|
|
|
@pytest.mark.usefixtures("docker_cleanup")
|
2026-04-01 10:23:02 -04:00
|
|
|
def test(tmp_path: Path) -> None:
|
2025-05-16 11:11:16 +01:00
|
|
|
if utils.get_platform() != "linux":
|
2021-05-03 11:45:43 -04:00
|
|
|
pytest.skip("the test is only relevant to the linux build")
|
|
|
|
|
if platform.machine() not in ["x86_64", "i686"]:
|
2021-04-30 17:56:34 -04:00
|
|
|
pytest.skip(
|
2021-05-03 11:45:43 -04:00
|
|
|
"this test is currently only possible on x86_64/i686 due to availability of alternative images"
|
2021-04-30 17:56:34 -04:00
|
|
|
)
|
2020-05-02 16:54:19 +01:00
|
|
|
|
2021-05-03 11:45:43 -04:00
|
|
|
project_dir = tmp_path / "project"
|
2020-05-02 16:54:19 +01:00
|
|
|
dockcross_only_project.generate(project_dir)
|
|
|
|
|
|
2021-04-30 17:56:34 -04:00
|
|
|
actual_wheels = utils.cibuildwheel_run(
|
|
|
|
|
project_dir,
|
|
|
|
|
add_env={
|
2021-11-20 17:51:57 +00:00
|
|
|
"CIBW_MANYLINUX_X86_64_IMAGE": "dockcross/manylinux2014-x64",
|
|
|
|
|
"CIBW_MANYLINUX_I686_IMAGE": "dockcross/manylinux2014-x86",
|
2025-02-25 20:23:01 +01:00
|
|
|
"CIBW_BUILD": "cp3{8,9}-manylinux*",
|
2021-04-30 17:56:34 -04:00
|
|
|
},
|
|
|
|
|
)
|
2020-05-02 16:54:19 +01:00
|
|
|
|
|
|
|
|
# also check that we got the right wheels built
|
2025-03-24 18:00:44 +01:00
|
|
|
manylinux_versions = ["manylinux_2_5", "manylinux1", "manylinux_2_17", "manylinux2014"]
|
2021-04-30 17:56:34 -04:00
|
|
|
expected_wheels = [
|
2021-04-03 16:59:10 +02:00
|
|
|
w
|
2025-03-24 18:00:44 +01:00
|
|
|
for w in utils.expected_wheels(
|
|
|
|
|
"spam", "0.1.0", manylinux_versions=manylinux_versions, musllinux_versions=[]
|
|
|
|
|
)
|
2026-05-11 03:19:36 +02:00
|
|
|
if "-cp39-" in w
|
2021-04-30 17:56:34 -04:00
|
|
|
]
|
2020-05-02 16:54:19 +01:00
|
|
|
assert set(actual_wheels) == set(expected_wheels)
|