Files
cibuildwheel/test/test_manylinuxXXXX_only.py
T

85 lines
3.4 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(
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>
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
#if !__GLIBC_PREREQ(2, 5) /* manylinux1 is glibc 2.5 */
#error "Must run on a glibc >= 2.5 linux environment"
#endif
2021-04-30 17:56:34 -04:00
'''
),
spam_c_function_add=textwrap.dedent(
r'''
2021-02-18 08:15:37 +01:00
#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24)
// nextupf is only available in manylinux_2_24+
sts = (int)nextupf(0.0F);
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17) /* manylinux2014 is glibc 2.17 */
// 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
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10) /* manylinux2010 is glibc 2.12 */
// malloc_info is only available on manylinux2010+
2021-02-18 08:15:37 +01:00
sts = malloc_info(0, stdout);
2020-05-02 16:54:19 +01:00
#endif
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(
'manylinux_image', ['manylinux1', 'manylinux2010', 'manylinux2014', 'manylinux_2_24']
)
2020-05-03 14:08:57 +01:00
def test(manylinux_image, tmp_path):
2019-12-02 11:07:56 +01:00
if utils.platform != 'linux':
pytest.skip('the docker test is only relevant to the linux build')
elif platform.machine() not in ['x86_64', 'i686']:
2020-02-20 17:29:28 -05:00
if manylinux_image in ['manylinux1', 'manylinux2010']:
pytest.skip("manylinux1 and 2010 doesn't exist for non-x86 architectures")
2019-12-02 11:07:56 +01:00
2020-05-03 14:08:57 +01: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
# CFLAGS environment variable is necessary to fail on 'malloc_info' (on manylinux1) during compilation/linking,
# rather than when dynamically loading the Python
add_env = {
2021-02-18 08:15:37 +01:00
'CIBW_ENVIRONMENT': 'CFLAGS="$CFLAGS -O0 -Werror=implicit-function-declaration"',
2019-12-02 11:07:56 +01:00
'CIBW_MANYLINUX_X86_64_IMAGE': manylinux_image,
'CIBW_MANYLINUX_I686_IMAGE': manylinux_image,
'CIBW_MANYLINUX_PYPY_X86_64_IMAGE': manylinux_image,
2020-02-20 17:29:28 -05:00
'CIBW_MANYLINUX_AARCH64_IMAGE': manylinux_image,
'CIBW_MANYLINUX_PPC64LE_IMAGE': manylinux_image,
'CIBW_MANYLINUX_S390X_IMAGE': manylinux_image,
2019-12-02 11:07:56 +01:00
}
if manylinux_image == 'manylinux1':
# We don't have a manylinux1 image for PyPy
add_env['CIBW_SKIP'] = 'pp*'
2021-02-18 08:15:37 +01:00
elif manylinux_image in {'manylinux2014', 'manylinux_2_24'}:
# We don't have a manylinux2014 / 'manylinux_2_24' image for PyPy (yet?)
# Python 2.7 not available on manylinux2014 / 'manylinux_2_24'
add_env['CIBW_SKIP'] = 'cp27* pp*'
2019-12-02 11:07:56 +01:00
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
2021-04-30 17:56:34 -04:00
expected_wheels = [
w for w in utils.expected_wheels('spam', '0.1.0', manylinux_versions=[manylinux_image])
]
2021-02-18 08:15:37 +01:00
if manylinux_image in {'manylinux2014', 'manylinux_2_24'}:
2019-12-02 11:07:56 +01:00
expected_wheels = [w for w in expected_wheels if '-cp27' not in w]
2021-02-18 08:15:37 +01:00
if manylinux_image in {'manylinux1', 'manylinux2014', 'manylinux_2_24'}:
expected_wheels = [w for w in expected_wheels if '-pp' not in w]
2019-12-02 11:07:56 +01:00
assert set(actual_wheels) == set(expected_wheels)