@@ -200,6 +200,34 @@ def any_manylinux_container(any_manylinux_img, io_folder):
200200 yield f'{ policy } _{ PLATFORM } ' , platform_tag , container
201201
202202
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+
203231def test_build_repair_numpy (any_manylinux_container , docker_python , io_folder ):
204232 # Integration test: repair numpy built from scratch
205233
@@ -237,11 +265,7 @@ def test_build_repair_numpy(any_manylinux_container, docker_python, io_folder):
237265 assert len (filenames ) == 2
238266 repaired_wheel = f'numpy-{ NUMPY_VERSION } -{ PYTHON_ABI } -{ tag } .whl'
239267 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 )
245269
246270 # Check that the repaired numpy wheel can be installed and executed
247271 # on a modern linux image.
@@ -286,11 +310,7 @@ def test_build_wheel_with_binary_executable(any_manylinux_container, docker_pyth
286310 assert len (filenames ) == 2
287311 repaired_wheel = f'testpackage-0.0.1-py3-none-{ tag } .whl'
288312 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 )
294314
295315 docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
296316 output = docker_exec (
@@ -353,25 +373,15 @@ def test_build_wheel_with_image_dependencies(with_dependency, any_manylinux_cont
353373 assert len (filenames ) == 2
354374 repaired_wheel = f'testdependencies-0.0.1-{ PYTHON_ABI } -{ tag } .whl'
355375 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 )
361377
362378 # check the original wheel with a dependency was not compliant
363379 # and check the one without a dependency was already compliant
364- output = docker_exec (manylinux_ctr , 'auditwheel show /io/' + orig_wheel )
365380 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 } '
370382 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 )
375385
376386 docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
377387 docker_exec (
@@ -455,15 +465,7 @@ def test_build_wheel_depending_on_library_with_rpath(any_manylinux_container, do
455465 assert len (filenames ) == 2
456466 repaired_wheel = f'testrpath-0.0.1-{ PYTHON_ABI } -{ tag } .whl'
457467 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 )
467469
468470 docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
469471 output = docker_exec (
@@ -526,15 +528,7 @@ def test_build_repair_multiple_top_level_modules_wheel(any_manylinux_container,
526528 assert len (filenames ) == 2
527529 repaired_wheel = f'multiple_top_level-1.0-{ PYTHON_ABI } -{ tag } .whl'
528530 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 )
538532
539533 docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
540534 for mod , func , expected in [
@@ -600,15 +594,7 @@ def test_build_repair_wheel_with_internal_rpath(any_manylinux_container, docker_
600594 assert len (filenames ) == 2
601595 repaired_wheel = f'internal_rpath-1.0-{ PYTHON_ABI } -{ tag } .whl'
602596 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 )
612598
613599 docker_exec (docker_python , 'pip install /io/' + repaired_wheel )
614600 for mod , func , expected in [
@@ -711,10 +697,8 @@ def test_build_wheel_compat(target_policy, only_plat, any_manylinux_container,
711697 repaired_tag = f'{ expect_tag } .{ target_tag } '
712698 repaired_wheel = f'testsimple-0.0.1-{ PYTHON_ABI } -{ repaired_tag } .whl'
713699 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+
718702 docker_exec (docker_python , f'pip install /io/{ repaired_wheel } ' )
719703 docker_exec (
720704 docker_python ,
0 commit comments