@@ -200,6 +200,34 @@ def any_manylinux_container(any_manylinux_img, io_folder):
200
200
yield f'{ policy } _{ PLATFORM } ' , platform_tag , container
201
201
202
202
203
+ SHOW_RE = re .compile (
204
+ r'[\s](?P<wheel>\S+) is consistent with the following platform tag: "(?P<tag>\S+)"' ,
205
+ flags = re .DOTALL
206
+ )
207
+ TAG_RE = re .compile (
208
+ r'^manylinux_(?P<major>[0-9]+)_(?P<minor>[0-9]+)_(?P<arch>\S+)$'
209
+ )
210
+
211
+
212
+ def assert_show_output (manylinux_ctr , wheel , expected_tag , strict ):
213
+ output = docker_exec (manylinux_ctr , f'auditwheel show /io/{ wheel } ' )
214
+ output = output .replace ('\n ' , ' ' )
215
+ match = SHOW_RE .match (output )
216
+ assert match
217
+ assert match ['wheel' ] == wheel
218
+ if strict :
219
+ assert match ['tag' ] == expected_tag
220
+ else :
221
+ expected_match = TAG_RE .match (expected_tag )
222
+ assert expected_match
223
+ expected_glibc = (int (expected_match ['major' ]), int (expected_match ['minor' ]))
224
+ actual_match = TAG_RE .match (match ['tag' ])
225
+ assert actual_match
226
+ actual_glibc = (int (actual_match ['major' ]), int (actual_match ['minor' ]))
227
+ assert expected_match ['arch' ] == actual_match ['arch' ]
228
+ assert actual_glibc <= expected_glibc
229
+
230
+
203
231
def test_build_repair_numpy (any_manylinux_container , docker_python , io_folder ):
204
232
# Integration test: repair numpy built from scratch
205
233
@@ -237,11 +265,7 @@ def test_build_repair_numpy(any_manylinux_container, docker_python, io_folder):
237
265
assert len (filenames ) == 2
238
266
repaired_wheel = f'numpy-{ NUMPY_VERSION } -{ PYTHON_ABI } -{ tag } .whl'
239
267
assert repaired_wheel in filenames
240
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + repaired_wheel )
241
- assert (
242
- f'numpy-{ NUMPY_VERSION } -{ PYTHON_ABI } -{ tag } .whl is consistent'
243
- f' with the following platform tag: "{ policy } "'
244
- ) in output .replace ('\n ' , ' ' )
268
+ assert_show_output (manylinux_ctr , repaired_wheel , policy , False )
245
269
246
270
# Check that the repaired numpy wheel can be installed and executed
247
271
# on a modern linux image.
@@ -286,11 +310,7 @@ def test_build_wheel_with_binary_executable(any_manylinux_container, docker_pyth
286
310
assert len (filenames ) == 2
287
311
repaired_wheel = f'testpackage-0.0.1-py3-none-{ tag } .whl'
288
312
assert repaired_wheel in filenames
289
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + repaired_wheel )
290
- assert (
291
- f'testpackage-0.0.1-py3-none-{ tag } .whl is consistent'
292
- f' with the following platform tag: "{ policy } "'
293
- ) in output .replace ('\n ' , ' ' )
313
+ assert_show_output (manylinux_ctr , repaired_wheel , policy , False )
294
314
295
315
docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
296
316
output = docker_exec (
@@ -353,25 +373,15 @@ def test_build_wheel_with_image_dependencies(with_dependency, any_manylinux_cont
353
373
assert len (filenames ) == 2
354
374
repaired_wheel = f'testdependencies-0.0.1-{ PYTHON_ABI } -{ tag } .whl'
355
375
assert repaired_wheel in filenames
356
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + repaired_wheel )
357
- assert (
358
- f'testdependencies-0.0.1-{ PYTHON_ABI } -{ tag } .whl is consistent'
359
- f' with the following platform tag: "{ policy } "'
360
- ) in output .replace ('\n ' , ' ' )
376
+ assert_show_output (manylinux_ctr , repaired_wheel , policy , True )
361
377
362
378
# check the original wheel with a dependency was not compliant
363
379
# and check the one without a dependency was already compliant
364
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + orig_wheel )
365
380
if with_dependency == '1' :
366
- assert (
367
- f'{ orig_wheel } is consistent with the following platform tag: '
368
- f'"linux_{ PLATFORM } "'
369
- ) in output .replace ('\n ' , ' ' )
381
+ expected = f'linux_{ PLATFORM } '
370
382
else :
371
- assert (
372
- f'{ orig_wheel } is consistent with the following platform tag: '
373
- f'"{ policy } "'
374
- ) in output .replace ('\n ' , ' ' )
383
+ expected = policy
384
+ assert_show_output (manylinux_ctr , orig_wheel , expected , True )
375
385
376
386
docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
377
387
docker_exec (
@@ -455,15 +465,7 @@ def test_build_wheel_depending_on_library_with_rpath(any_manylinux_container, do
455
465
assert len (filenames ) == 2
456
466
repaired_wheel = f'testrpath-0.0.1-{ PYTHON_ABI } -{ tag } .whl'
457
467
assert repaired_wheel in filenames
458
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + repaired_wheel )
459
- if PLATFORM in {'x86_64' , 'i686' }:
460
- expect = f'manylinux_2_5_{ PLATFORM } '
461
- else :
462
- expect = f'manylinux_2_17_{ PLATFORM } '
463
- assert (
464
- f'testrpath-0.0.1-{ PYTHON_ABI } -{ tag } .whl is consistent'
465
- f' with the following platform tag: "{ expect } "'
466
- ) in output .replace ('\n ' , ' ' )
468
+ assert_show_output (manylinux_ctr , repaired_wheel , policy , False )
467
469
468
470
docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
469
471
output = docker_exec (
@@ -526,15 +528,7 @@ def test_build_repair_multiple_top_level_modules_wheel(any_manylinux_container,
526
528
assert len (filenames ) == 2
527
529
repaired_wheel = f'multiple_top_level-1.0-{ PYTHON_ABI } -{ tag } .whl'
528
530
assert repaired_wheel in filenames
529
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + repaired_wheel )
530
- if PLATFORM in {'x86_64' , 'i686' }:
531
- expect = f'manylinux_2_5_{ PLATFORM } '
532
- else :
533
- expect = f'manylinux_2_17_{ PLATFORM } '
534
- assert (
535
- f'{ repaired_wheel } is consistent'
536
- f' with the following platform tag: "{ expect } "'
537
- ) in output .replace ('\n ' , ' ' )
531
+ assert_show_output (manylinux_ctr , repaired_wheel , policy , False )
538
532
539
533
docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
540
534
for mod , func , expected in [
@@ -600,15 +594,7 @@ def test_build_repair_wheel_with_internal_rpath(any_manylinux_container, docker_
600
594
assert len (filenames ) == 2
601
595
repaired_wheel = f'internal_rpath-1.0-{ PYTHON_ABI } -{ tag } .whl'
602
596
assert repaired_wheel in filenames
603
- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + repaired_wheel )
604
- if PLATFORM in {'x86_64' , 'i686' }:
605
- expect = f'manylinux_2_5_{ PLATFORM } '
606
- else :
607
- expect = f'manylinux_2_17_{ PLATFORM } '
608
- assert (
609
- f'{ repaired_wheel } is consistent'
610
- f' with the following platform tag: "{ expect } "'
611
- ) in output .replace ('\n ' , ' ' )
597
+ assert_show_output (manylinux_ctr , repaired_wheel , policy , False )
612
598
613
599
docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
614
600
for mod , func , expected in [
@@ -711,10 +697,8 @@ def test_build_wheel_compat(target_policy, only_plat, any_manylinux_container,
711
697
repaired_tag = f'{ expect_tag } .{ target_tag } '
712
698
repaired_wheel = f'testsimple-0.0.1-{ PYTHON_ABI } -{ repaired_tag } .whl'
713
699
assert repaired_wheel in filenames
714
- output = docker_exec (manylinux_ctr , f'auditwheel show /io/{ repaired_wheel } ' )
715
- assert (
716
- f'is consistent with the following platform tag: "{ expect } "'
717
- ) in output .replace ('\n ' , ' ' )
700
+ assert_show_output (manylinux_ctr , repaired_wheel , expect , True )
701
+
718
702
docker_exec (docker_python , f'pip install /io/{ repaired_wheel } ' )
719
703
docker_exec (
720
704
docker_python ,
0 commit comments