Skip to content

Commit b0fde3d

Browse files
authored
Merge pull request #147 from takluyver/tests-update
Update tests for manylinux2010
2 parents 2dad10d + 46619cd commit b0fde3d

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

tests/test_manylinux.py

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,29 @@
1414

1515
ENCODING = 'utf-8'
1616
MANYLINUX1_IMAGE_ID = 'quay.io/pypa/manylinux1_x86_64'
17-
#TODO: use the pypa manylinux2010 image on release
18-
MANYLINUX2010_IMAGE_ID = 'zombiefeynman/manylinux2010_x86_64'
17+
MANYLINUX2010_IMAGE_ID = 'quay.io/pypa/manylinux2010_x86_64'
1918
MANYLINUX_IMAGES = {
2019
'manylinux1': MANYLINUX1_IMAGE_ID,
2120
'manylinux2010': MANYLINUX2010_IMAGE_ID,
2221
}
2322
DOCKER_CONTAINER_NAME = 'auditwheel-test-manylinux'
2423
PYTHON_IMAGE_ID = 'python:3.5'
25-
PATH = ('/opt/python/cp35-cp35m/bin:/opt/rh/devtoolset-2/root/usr/bin:'
26-
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin')
24+
DEVTOOLSET = {
25+
'manylinux1': 'devtoolset-2',
26+
'manylinux2010': 'devtoolset-8',
27+
}
28+
PATH_DIRS = [
29+
'/opt/python/cp35-cp35m/bin',
30+
'/opt/rh/{devtoolset}/root/usr/bin',
31+
'/usr/local/sbin',
32+
'/usr/local/bin',
33+
'/usr/sbin',
34+
'/usr/bin',
35+
'/sbin',
36+
'/bin',
37+
]
38+
PATH = {k: ':'.join(PATH_DIRS).format(devtoolset=v)
39+
for k, v in DEVTOOLSET.items()}
2740
WHEEL_CACHE_FOLDER = op.expanduser('~/.cache/auditwheel_tests')
2841
ORIGINAL_NUMPY_WHEEL = 'numpy-1.11.0-cp35-cp35m-linux_x86_64.whl'
2942
ORIGINAL_SIX_WHEEL = 'six-1.11.0-py2.py3-none-any.whl'
@@ -71,14 +84,16 @@ def docker_exec(container_id, cmd):
7184
def docker_container(request):
7285
if find_executable("docker") is None:
7386
pytest.skip('docker is required')
74-
if not op.exists(WHEEL_CACHE_FOLDER):
75-
os.makedirs(WHEEL_CACHE_FOLDER)
87+
88+
policy = request.param
89+
if not op.exists(op.join(WHEEL_CACHE_FOLDER, policy)):
90+
os.makedirs(op.join(WHEEL_CACHE_FOLDER, policy))
7691
src_folder = find_src_folder()
7792
if src_folder is None:
7893
pytest.skip('Can only be run from the source folder')
7994
io_folder = tempfile.mkdtemp(prefix='tmp_auditwheel_test_manylinux_',
8095
dir=src_folder)
81-
policy = request.param
96+
8297
manylinux_id, python_id = None, None
8398
try:
8499
# Launch a docker container with volumes and pre-configured Python
@@ -89,7 +104,7 @@ def docker_container(request):
89104
manylinux_id = docker_start(
90105
MANYLINUX_IMAGES[policy],
91106
volumes={'/io': io_folder, '/auditwheel_src': src_folder},
92-
env_variables={'PATH': PATH})
107+
env_variables={'PATH': PATH[policy]})
93108
# Install the development version of auditwheel from source:
94109
docker_exec(manylinux_id, 'pip install -U pip setuptools')
95110
docker_exec(manylinux_id, 'pip install -U /auditwheel_src')
@@ -121,9 +136,9 @@ def test_build_repair_numpy(docker_container):
121136
policy, manylinux_id, python_id, io_folder = docker_container
122137
docker_exec(manylinux_id, 'yum install -y atlas atlas-devel')
123138

124-
if op.exists(op.join(WHEEL_CACHE_FOLDER, ORIGINAL_NUMPY_WHEEL)):
139+
if op.exists(op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_NUMPY_WHEEL)):
125140
# If numpy has already been built and put in cache, let's reuse this.
126-
shutil.copy2(op.join(WHEEL_CACHE_FOLDER, ORIGINAL_NUMPY_WHEEL),
141+
shutil.copy2(op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_NUMPY_WHEEL),
127142
op.join(io_folder, ORIGINAL_NUMPY_WHEEL))
128143
else:
129144
# otherwise build the original linux_x86_64 numpy wheel from source
@@ -133,7 +148,7 @@ def test_build_repair_numpy(docker_container):
133148
docker_exec(manylinux_id,
134149
'pip wheel -w /io --no-binary=:all: numpy==1.11.0')
135150
shutil.copy2(op.join(io_folder, ORIGINAL_NUMPY_WHEEL),
136-
op.join(WHEEL_CACHE_FOLDER, ORIGINAL_NUMPY_WHEEL))
151+
op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_NUMPY_WHEEL))
137152
filenames = os.listdir(io_folder)
138153
assert filenames == [ORIGINAL_NUMPY_WHEEL]
139154
orig_wheel = filenames[0]
@@ -146,21 +161,15 @@ def test_build_repair_numpy(docker_container):
146161
docker_exec(manylinux_id, repair_command)
147162
filenames = os.listdir(io_folder)
148163

149-
if policy == 'manylinux1':
150-
expected_files = 2
151-
elif policy == 'manylinux2010':
152-
expected_files = 3 # We end up repairing the wheel twice to manylinux1
153-
154-
assert len(filenames) == expected_files
155-
# Regardless of build environment, wheel only needs manylinux1 symbols
156-
repaired_wheels = [fn for fn in filenames if 'manylinux1' in fn]
157-
assert repaired_wheels == ['numpy-1.11.0-cp35-cp35m-manylinux1_x86_64.whl']
164+
assert len(filenames) == 2
165+
repaired_wheels = [fn for fn in filenames if 'manylinux' in fn]
166+
assert repaired_wheels == ['numpy-1.11.0-cp35-cp35m-{}_x86_64.whl'.format(policy)]
158167
repaired_wheel = repaired_wheels[0]
159168
output = docker_exec(manylinux_id, 'auditwheel show /io/' + repaired_wheel)
160169
assert (
161-
'numpy-1.11.0-cp35-cp35m-manylinux1_x86_64.whl is consistent'
162-
' with the following platform tag: "manylinux1_x86_64"'
163-
) in output.replace('\n', ' ')
170+
'numpy-1.11.0-cp35-cp35m-{policy}_x86_64.whl is consistent'
171+
' with the following platform tag: "{policy}_x86_64"'
172+
).format(policy=policy) in output.replace('\n', ' ')
164173

165174
# Check that the repaired numpy wheel can be installed and executed
166175
# on a modern linux image.
@@ -211,12 +220,6 @@ def test_build_wheel_with_binary_executable(docker_container):
211220
' with the following platform tag: "{policy}_x86_64"'
212221
).format(policy=policy) in output.replace('\n', ' ')
213222

214-
# TODO: Remove once pip supports manylinux2010
215-
docker_exec(
216-
python_id,
217-
"pip install git+https://github.com/wtolson/pip.git@manylinux2010",
218-
)
219-
220223
docker_exec(python_id, 'pip install /io/' + repaired_wheel)
221224
output = docker_exec(
222225
python_id, ['python', '-c', 'from testpackage import runit; print(runit(1.5))']).strip()
@@ -226,15 +229,15 @@ def test_build_wheel_with_binary_executable(docker_container):
226229
def test_build_repair_pure_wheel(docker_container):
227230
policy, manylinux_id, python_id, io_folder = docker_container
228231

229-
if op.exists(op.join(WHEEL_CACHE_FOLDER, ORIGINAL_SIX_WHEEL)):
232+
if op.exists(op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_SIX_WHEEL)):
230233
# If six has already been built and put in cache, let's reuse this.
231-
shutil.copy2(op.join(WHEEL_CACHE_FOLDER, ORIGINAL_SIX_WHEEL),
234+
shutil.copy2(op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_SIX_WHEEL),
232235
op.join(io_folder, ORIGINAL_SIX_WHEEL))
233236
else:
234237
docker_exec(manylinux_id,
235238
'pip wheel -w /io --no-binary=:all: six==1.11.0')
236239
shutil.copy2(op.join(io_folder, ORIGINAL_SIX_WHEEL),
237-
op.join(WHEEL_CACHE_FOLDER, ORIGINAL_SIX_WHEEL))
240+
op.join(WHEEL_CACHE_FOLDER, policy, ORIGINAL_SIX_WHEEL))
238241

239242
filenames = os.listdir(io_folder)
240243
assert filenames == [ORIGINAL_SIX_WHEEL]

0 commit comments

Comments
 (0)