Files
cibuildwheel/test/test_manylinuxXXXX_only.py
T

116 lines
4.1 KiB
Python
Raw Normal View History

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
2019-11-12 23:51:27 +00:00
2020-05-02 16:54:19 +01:00
# TODO: specify these at runtime according to manylinux_image
project_with_manylinux_symbols = test_projects.new_c_project(
2021-04-30 17:56:34 -04:00
spam_c_top_level_add=textwrap.dedent(
2021-05-03 11:45:43 -04:00
r"""
2020-05-02 16:54:19 +01:00
#include <malloc.h>
2021-02-18 08:15:37 +01:00
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
2024-11-28 07:52:46 +01:00
#include <pthread.h>
2019-11-12 23:51:27 +00:00
2020-05-02 16:54:19 +01:00
#if !defined(__GLIBC_PREREQ)
#error "Must run on a glibc linux environment"
#endif
2025-03-22 17:26:38 +01:00
#if !__GLIBC_PREREQ(2, 17) /* manylinux2014 is glibc 2.17 */
2020-05-02 16:54:19 +01:00
#error "Must run on a glibc >= 2.5 linux environment"
#endif
2022-02-13 16:57:35 +01:00
#if __GLIBC_PREREQ(2, 28)
#include <threads.h>
#endif
2021-05-03 11:45:43 -04:00
"""
2021-04-30 17:56:34 -04:00
),
spam_c_function_add=textwrap.dedent(
2021-05-03 11:45:43 -04:00
r"""
2024-11-28 07:52:46 +01:00
#if __GLIBC_PREREQ(2, 34)
// pthread_mutexattr_init was moved to libc.so.6 in manylinux_2_34+
pthread_mutexattr_t attr;
sts = pthread_mutexattr_init(&attr);
if (sts == 0) {
pthread_mutexattr_destroy(&attr);
}
#elif __GLIBC_PREREQ(2, 28)
2022-02-13 16:57:35 +01:00
// thrd_equal & thrd_current are only available in manylinux_2_28+
2024-11-28 07:52:46 +01:00
sts = thrd_equal(thrd_current(), thrd_current()) ? 0 : 1;
2022-02-13 16:57:35 +01:00
#elif __GLIBC_PREREQ(2, 24)
2021-02-18 08:15:37 +01:00
// nextupf is only available in manylinux_2_24+
sts = (int)nextupf(0.0F);
2022-02-13 16:57:35 +01:00
#elif __GLIBC_PREREQ(2, 17) /* manylinux2014 is glibc 2.17 */
2021-02-18 08:15:37 +01:00
// secure_getenv is only available in manylinux2014+
sts = (int)(intptr_t)secure_getenv("NON_EXISTING_ENV_VARIABLE");
2020-05-02 16:54:19 +01:00
#endif
2021-05-03 11:45:43 -04:00
"""
2021-04-30 17:56:34 -04:00
),
2020-05-02 16:54:19 +01:00
)
2019-12-02 11:07:56 +01:00
2021-04-30 17:56:34 -04:00
@pytest.mark.parametrize(
2022-02-13 16:57:35 +01:00
"manylinux_image",
2024-11-28 07:52:46 +01:00
[
"manylinux2014",
"manylinux_2_28",
"manylinux_2_34",
],
2021-04-30 17:56:34 -04:00
)
2023-08-07 18:01:10 +02:00
@pytest.mark.usefixtures("docker_cleanup")
2020-05-03 14:08:57 +01:00
def test(manylinux_image, tmp_path):
2021-05-03 11:45:43 -04:00
if utils.platform != "linux":
pytest.skip("the container image test is only relevant to the linux build")
2024-11-28 07:52:46 +01:00
elif manylinux_image in {"manylinux_2_28", "manylinux_2_34"} and platform.machine() == "i686":
pytest.skip(f"{manylinux_image} doesn't exist for i686 architecture")
2019-12-02 11:07:56 +01:00
2021-05-03 11:45:43 -04:00
project_dir = tmp_path / "project"
2020-05-02 16:54:19 +01:00
project_with_manylinux_symbols.generate(project_dir)
2019-12-02 11:07:56 +01:00
# build the wheels
2025-03-22 17:26:38 +01:00
# CFLAGS environment variable is necessary to fail at build time,
2019-12-02 11:07:56 +01:00
# rather than when dynamically loading the Python
add_env = {
"CIBW_BUILD": "*-manylinux*",
2021-05-03 11:45:43 -04:00
"CIBW_ENVIRONMENT": 'CFLAGS="$CFLAGS -O0 -Werror=implicit-function-declaration"',
"CIBW_MANYLINUX_X86_64_IMAGE": manylinux_image,
"CIBW_MANYLINUX_I686_IMAGE": manylinux_image,
"CIBW_MANYLINUX_PYPY_X86_64_IMAGE": manylinux_image,
"CIBW_MANYLINUX_AARCH64_IMAGE": manylinux_image,
"CIBW_MANYLINUX_PPC64LE_IMAGE": manylinux_image,
"CIBW_MANYLINUX_S390X_IMAGE": manylinux_image,
2021-05-24 09:28:18 +02:00
"CIBW_MANYLINUX_PYPY_AARCH64_IMAGE": manylinux_image,
2021-05-24 09:44:50 +02:00
"CIBW_MANYLINUX_PYPY_I686_IMAGE": manylinux_image,
2019-12-02 11:07:56 +01:00
}
2024-11-28 07:52:46 +01:00
if manylinux_image in {"manylinux_2_28", "manylinux_2_34"} and platform.machine() == "x86_64":
# We don't have a manylinux_2_28+ image for i686
2022-02-13 16:57:35 +01:00
add_env["CIBW_ARCHS"] = "x86_64"
if platform.machine() == "aarch64":
# We just have a manylinux_2_31 image for armv7l
add_env["CIBW_ARCHS"] = "aarch64"
2021-02-14 20:44:20 +01:00
2019-12-02 11:07:56 +01:00
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
platform_tag_map = {
"manylinux2014": ["manylinux_2_17", "manylinux2014"],
}
expected_wheels = utils.expected_wheels(
"spam",
"0.1.0",
manylinux_versions=platform_tag_map.get(manylinux_image, [manylinux_image]),
musllinux_versions=[],
)
2022-02-13 16:57:35 +01:00
2024-11-28 07:52:46 +01:00
if manylinux_image in {"manylinux_2_28", "manylinux_2_34"} and platform.machine() == "x86_64":
# We don't have a manylinux_2_28+ image for i686
2022-02-13 16:57:35 +01:00
expected_wheels = [w for w in expected_wheels if "i686" not in w]
if platform.machine() == "aarch64":
# We just have a manylinux_2_31 image for armv7l
expected_wheels = [w for w in expected_wheels if "armv7l" not in w]
2019-12-02 11:07:56 +01:00
assert set(actual_wheels) == set(expected_wheels)