Skip to content

Commit

Permalink
Add manylinux_2_24 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Nov 14, 2020
1 parent fbf4518 commit 961c1cf
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
70 changes: 49 additions & 21 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@

ENCODING = 'utf-8'
PLATFORM = get_arch_name()
MANYLINUX1_IMAGE_ID = f'quay.io/pypa/manylinux1_{PLATFORM}'
MANYLINUX2010_IMAGE_ID = f'quay.io/pypa/manylinux2010_{PLATFORM}'
MANYLINUX1_IMAGE_ID = f'quay.io/pypa/manylinux1_{PLATFORM}:latest'
MANYLINUX2010_IMAGE_ID = f'quay.io/pypa/manylinux2010_{PLATFORM}:latest'
MANYLINUX2014_IMAGE_ID = f'quay.io/pypa/manylinux2014_{PLATFORM}:latest'
MANYLINUX_2_24_IMAGE_ID = f'quay.io/pypa/manylinux_2_24_{PLATFORM}:latest'
if PLATFORM in {'i686', 'x86_64'}:
MANYLINUX_IMAGES = {
'manylinux1': MANYLINUX1_IMAGE_ID,
'manylinux2010': MANYLINUX2010_IMAGE_ID,
'manylinux2014': MANYLINUX2014_IMAGE_ID,
'manylinux_2_24': MANYLINUX_2_24_IMAGE_ID,
}
else:
MANYLINUX_IMAGES = {
'manylinux2014': MANYLINUX2014_IMAGE_ID,
'manylinux_2_24': MANYLINUX_2_24_IMAGE_ID,
}
DOCKER_CONTAINER_NAME = 'auditwheel-test-manylinux'
PYTHON_MAJ_MIN = [str(i) for i in sys.version_info[:2]]
Expand All @@ -43,6 +46,7 @@
'manylinux1': 'devtoolset-2',
'manylinux2010': 'devtoolset-8',
'manylinux2014': 'devtoolset-9',
'manylinux_2_24': 'devtoolset-not-present',
}
PATH_DIRS = [
f'/opt/python/{PYTHON_ABI}/bin',
Expand Down Expand Up @@ -150,7 +154,7 @@ def tmp_docker_image(base, commands, setup_env={}):
@pytest.fixture(scope='session')
def docker_python_img():
"""The Python base image with up-to-date pip"""
with tmp_docker_image(PYTHON_IMAGE_ID, ['pip install pip']) as img_id:
with tmp_docker_image(PYTHON_IMAGE_ID, ['pip install -U pip']) as img_id:
yield img_id

@pytest.fixture(scope='session', params=MANYLINUX_IMAGES.keys())
Expand Down Expand Up @@ -192,7 +196,14 @@ def test_build_repair_numpy(any_manylinux_container, docker_python, io_folder):
# First build numpy from source as a naive linux wheel that is tied
# to system libraries (atlas, libgfortran...)
policy, manylinux_ctr = any_manylinux_container
docker_exec(manylinux_ctr, 'yum install -y atlas atlas-devel')
if f'{policy}'.startswith('manylinux_2_24'):
docker_exec(manylinux_ctr, 'apt-get update')
docker_exec(
manylinux_ctr,
'apt-get install -y --no-install-recommends libatlas-dev'
)
else:
docker_exec(manylinux_ctr, 'yum install -y atlas atlas-devel')

if op.exists(op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_NUMPY_WHEEL)):
# If numpy has already been built and put in cache, let's reuse this.
Expand Down Expand Up @@ -220,16 +231,21 @@ def test_build_repair_numpy(any_manylinux_container, docker_python, io_folder):
docker_exec(manylinux_ctr, repair_command)
filenames = os.listdir(io_folder)

assert len(filenames) == 2
assert len(filenames) in {2, 3} # linux & current policy only or also a higher priority policy
repaired_wheels = [fn for fn in filenames if 'manylinux' in fn]
assert repaired_wheels == [
f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{policy}.whl'
]
repaired_wheel = repaired_wheels[0]
repaired_wheel = f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{policy}.whl'
assert repaired_wheel in repaired_wheels
consistent_policy = policy
if len(repaired_wheels) == 2:
# consistency with previous policy
consistent_policy, _ = os.path.splitext(
[fn for fn in repaired_wheels if fn != repaired_wheel][0].split('-')[-1]
)

output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
assert (
f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{policy}.whl is consistent'
f' with the following platform tag: "{policy}"'
f'{repaired_wheel} is consistent with the following platform tag: '
f'"{consistent_policy}"'
) in output.replace('\n', ' ')

# Check that the repaired numpy wheel can be installed and executed
Expand All @@ -255,7 +271,14 @@ def test_build_wheel_with_binary_executable(any_manylinux_container, docker_pyth
# Test building a wheel that contains a binary executable (e.g., a program)

policy, manylinux_ctr = any_manylinux_container
docker_exec(manylinux_ctr, 'yum install -y gsl-devel')
if f'{policy}'.startswith('manylinux_2_24'):
docker_exec(manylinux_ctr, 'apt-get update')
docker_exec(
manylinux_ctr,
'apt-get install -y --no-install-recommends libgsl-dev'
)
else:
docker_exec(manylinux_ctr, 'yum install -y gsl-devel')

docker_exec(
manylinux_ctr,
Expand All @@ -271,16 +294,21 @@ def test_build_wheel_with_binary_executable(any_manylinux_container, docker_pyth
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
docker_exec(manylinux_ctr, repair_command)
filenames = os.listdir(io_folder)
assert len(filenames) == 2
repaired_wheels = [fn for fn in filenames if policy in fn]
# Wheel picks up newer symbols when built in manylinux2010
expected_wheel_name = f'testpackage-0.0.1-py3-none-{policy}.whl'
assert repaired_wheels == [expected_wheel_name]
repaired_wheel = repaired_wheels[0]
assert len(filenames) in {2, 3} # linux & current policy only or also a higher priority policy
repaired_wheels = [fn for fn in filenames if 'manylinux' in fn]
repaired_wheel = f'testpackage-0.0.1-py3-none-{policy}.whl'
assert repaired_wheel in repaired_wheels
consistent_policy = policy
if len(repaired_wheels) == 2:
# consistency with previous policy
consistent_policy, _ = os.path.splitext(
[fn for fn in repaired_wheels if fn != repaired_wheel][0].split('-')[-1]
)

output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
assert (
f'testpackage-0.0.1-py3-none-{policy}.whl is consistent'
f' with the following platform tag: "{policy}"'
f'{repaired_wheel} is consistent with the following platform tag: '
f'"{consistent_policy}"'
) in output.replace('\n', ' ')

docker_exec(docker_python, 'pip install /io/' + repaired_wheel)
Expand Down Expand Up @@ -324,7 +352,7 @@ def test_build_wheel_with_image_dependencies(with_dependency, any_manylinux_cont

policy_priority = get_priority_by_name(policy)
older_policies = \
[p for p in MANYLINUX_IMAGES.keys()
[f'{p}_{PLATFORM}' for p in MANYLINUX_IMAGES.keys()
if policy_priority < get_priority_by_name(f'{p}_{PLATFORM}')]
for target_policy in older_policies:
# we shall fail to repair the wheel when targeting an older policy than
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/testdependencies/dependency.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#include <malloc.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>

int dep_run()
{
#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17)
#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24)
return (int)nextupf(0.0F);
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17)
return (int)(intptr_t)secure_getenv("NON_EXISTING_ENV_VARIABLE");
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
return malloc_info(0, stdout);
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/testdependencies/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from os import path
from os import getenv

cmd = 'gcc -shared -fPIC -D_GNU_SOURCE dependency.c -o libdependency.so'
cmd = 'gcc -shared -fPIC -D_GNU_SOURCE dependency.c -o libdependency.so -lm -lc'
subprocess.check_call(cmd.split())

define_macros = [('_GNU_SOURCE', None)]
Expand All @@ -15,6 +15,8 @@
library_dirs.append(path.abspath(path.dirname(__file__)))
define_macros.append(('WITH_DEPENDENCY', '1'))

libraries.extend(['m', 'c'])

setup(
name='testdependencies',
version='0.0.1',
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/testdependencies/testdependencies.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <malloc.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#endif
#include <Python.h>

Expand All @@ -19,6 +20,8 @@ run(PyObject *self, PyObject *args)

#ifdef WITH_DEPENDENCY
res = dep_run();
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 24)
res = (int)nextupf(0.0F);
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 17)
res = (int)(intptr_t)secure_getenv("NON_EXISTING_ENV_VARIABLE");
#elif defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
Expand Down

0 comments on commit 961c1cf

Please sign in to comment.