Skip to content

Commit b36992d

Browse files
authored
Always repair as a single wheel (#289)
Add argument `--only-plat` to `auditwheel repair` for those who were keeping only the lowest priority tag wheel (i.e. the one requested by `--plat` argument).
1 parent 3ac70ff commit b36992d

File tree

2 files changed

+60
-56
lines changed

2 files changed

+60
-56
lines changed

auditwheel/main_repair.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def configure_parser(sub_parsers):
4848
action='store_true',
4949
help='Strip symbols in the resulting wheel',
5050
default=False)
51+
p.add_argument('--only-plat',
52+
dest='ONLY_PLAT',
53+
action='store_true',
54+
help='Do not check for higher policy compatibility',
55+
default=False)
5156
p.set_defaults(func=execute)
5257

5358

@@ -88,6 +93,15 @@ def execute(args, p):
8893
p.error(msg)
8994

9095
abis = [policy['name']] + policy['aliases']
96+
if not args.ONLY_PLAT:
97+
if reqd_tag < get_priority_by_name(wheel_abi.overall_tag):
98+
logger.info(('Wheel is eligible for a higher priority tag. '
99+
'You requested %s but I have found this wheel is '
100+
'eligible for %s.'),
101+
args.PLAT, wheel_abi.overall_tag)
102+
higher_policy = get_policy_by_name(wheel_abi.overall_tag)
103+
abis = [higher_policy['name']] + higher_policy['aliases'] + abis
104+
91105
patcher = Patchelf()
92106
out_wheel = repair_wheel(args.WHEEL_FILE,
93107
abis=abis,
@@ -98,19 +112,4 @@ def execute(args, p):
98112
strip=args.STRIP)
99113

100114
if out_wheel is not None:
101-
analyzed_tag = analyze_wheel_abi(out_wheel).overall_tag
102-
if reqd_tag < get_priority_by_name(analyzed_tag):
103-
logger.info(('Wheel is eligible for a higher priority tag. '
104-
'You requested %s but I have found this wheel is '
105-
'eligible for %s.'),
106-
args.PLAT, analyzed_tag)
107-
policy = get_policy_by_name(analyzed_tag)
108-
abis = [policy['name']] + policy['aliases']
109-
out_wheel = repair_wheel(args.WHEEL_FILE,
110-
abis=abis,
111-
lib_sdir=args.LIB_SDIR,
112-
out_dir=args.WHEEL_DIR,
113-
update_tags=args.UPDATE_TAGS,
114-
patcher=patcher)
115-
116115
logger.info('\nFixed-up wheel written to %s', out_wheel)

tests/integration/test_manylinux.py

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,13 @@ def test_build_repair_numpy(any_manylinux_container, docker_python, io_folder):
230230
assert 'manylinux' not in orig_wheel
231231

232232
# Repair the wheel using the manylinux container
233-
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
233+
repair_command = \
234+
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
234235
docker_exec(manylinux_ctr, repair_command)
235236
filenames = os.listdir(io_folder)
236-
237237
assert len(filenames) == 2
238-
repaired_wheels = [fn for fn in filenames if 'manylinux' in fn]
239-
assert repaired_wheels == [
240-
f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{tag}.whl'
241-
]
242-
repaired_wheel = repaired_wheels[0]
238+
repaired_wheel = f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{tag}.whl'
239+
assert repaired_wheel in filenames
243240
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
244241
assert (
245242
f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{tag}.whl is consistent'
@@ -282,15 +279,13 @@ def test_build_wheel_with_binary_executable(any_manylinux_container, docker_pyth
282279
assert 'manylinux' not in orig_wheel
283280

284281
# Repair the wheel using the appropriate manylinux container
285-
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
282+
repair_command = \
283+
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
286284
docker_exec(manylinux_ctr, repair_command)
287285
filenames = os.listdir(io_folder)
288286
assert len(filenames) == 2
289-
repaired_wheels = [fn for fn in filenames if policy in fn]
290-
# Wheel picks up newer symbols when built in manylinux2010
291-
expected_wheel_name = f'testpackage-0.0.1-py3-none-{tag}.whl'
292-
assert repaired_wheels == [expected_wheel_name]
293-
repaired_wheel = repaired_wheels[0]
287+
repaired_wheel = f'testpackage-0.0.1-py3-none-{tag}.whl'
288+
assert repaired_wheel in filenames
294289
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
295290
assert (
296291
f'testpackage-0.0.1-py3-none-{tag}.whl is consistent'
@@ -356,10 +351,8 @@ def test_build_wheel_with_image_dependencies(with_dependency, any_manylinux_cont
356351
repair_command.format(policy=policy, orig_wheel=orig_wheel)])
357352
filenames = os.listdir(io_folder)
358353
assert len(filenames) == 2
359-
repaired_wheels = [fn for fn in filenames if policy in fn]
360-
expected_wheel_name = f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl'
361-
assert repaired_wheels == [expected_wheel_name]
362-
repaired_wheel = repaired_wheels[0]
354+
repaired_wheel = f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl'
355+
assert repaired_wheel in filenames
363356
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
364357
assert (
365358
f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl is consistent'
@@ -452,17 +445,16 @@ def test_build_wheel_depending_on_library_with_rpath(any_manylinux_container, do
452445
assert 'manylinux' not in orig_wheel
453446

454447
# Repair the wheel using the appropriate manylinux container
455-
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
448+
repair_command = \
449+
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
456450
docker_exec(
457451
manylinux_ctr,
458452
['bash', '-c', 'LD_LIBRARY_PATH=/auditwheel_src/tests/integration/testrpath/a:$LD_LIBRARY_PATH ' + repair_command],
459453
)
460454
filenames = os.listdir(io_folder)
461-
repaired_wheels = [fn for fn in filenames if policy in fn]
462-
# Wheel picks up newer symbols when built in manylinux2010
463-
expected_wheel_name = f'testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl'
464-
assert expected_wheel_name in repaired_wheels
465-
repaired_wheel = expected_wheel_name
455+
assert len(filenames) == 2
456+
repaired_wheel = f'testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl'
457+
assert repaired_wheel in filenames
466458
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
467459
if PLATFORM in {'x86_64', 'i686'}:
468460
expect = f'manylinux_2_5_{PLATFORM}'
@@ -514,7 +506,8 @@ def test_build_repair_multiple_top_level_modules_wheel(any_manylinux_container,
514506
assert 'manylinux' not in orig_wheel
515507

516508
# Repair the wheel using the appropriate manylinux container
517-
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
509+
repair_command = \
510+
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
518511
docker_exec(
519512
manylinux_ctr,
520513
[
@@ -530,11 +523,9 @@ def test_build_repair_multiple_top_level_modules_wheel(any_manylinux_container,
530523
],
531524
)
532525
filenames = os.listdir(io_folder)
533-
repaired_wheels = [fn for fn in filenames if policy in fn]
534-
# Wheel picks up newer symbols when built in manylinux2010
535-
expected_wheel_name = f'multiple_top_level-1.0-{PYTHON_ABI}-{tag}.whl'
536-
assert repaired_wheels == [expected_wheel_name]
537-
repaired_wheel = expected_wheel_name
526+
assert len(filenames) == 2
527+
repaired_wheel = f'multiple_top_level-1.0-{PYTHON_ABI}-{tag}.whl'
528+
assert repaired_wheel in filenames
538529
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
539530
if PLATFORM in {'x86_64', 'i686'}:
540531
expect = f'manylinux_2_5_{PLATFORM}'
@@ -590,7 +581,8 @@ def test_build_repair_wheel_with_internal_rpath(any_manylinux_container, docker_
590581
assert 'manylinux' not in orig_wheel
591582

592583
# Repair the wheel using the appropriate manylinux container
593-
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
584+
repair_command = \
585+
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
594586
docker_exec(
595587
manylinux_ctr,
596588
[
@@ -605,11 +597,9 @@ def test_build_repair_wheel_with_internal_rpath(any_manylinux_container, docker_
605597
],
606598
)
607599
filenames = os.listdir(io_folder)
608-
repaired_wheels = [fn for fn in filenames if policy in fn]
609-
# Wheel picks up newer symbols when built in manylinux2010
610-
expected_wheel_name = f'internal_rpath-1.0-{PYTHON_ABI}-{tag}.whl'
611-
assert repaired_wheels == [expected_wheel_name]
612-
repaired_wheel = expected_wheel_name
600+
assert len(filenames) == 2
601+
repaired_wheel = f'internal_rpath-1.0-{PYTHON_ABI}-{tag}.whl'
602+
assert repaired_wheel in filenames
613603
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
614604
if PLATFORM in {'x86_64', 'i686'}:
615605
expect = f'manylinux_2_5_{PLATFORM}'
@@ -676,7 +666,8 @@ def test_strip_wheel(any_manylinux_container, docker_python, io_folder):
676666
[f'{p}_{PLATFORM}' for p in list(MANYLINUX_IMAGES.keys())] +
677667
[f'{p}_{PLATFORM}' for aliases in POLICY_ALIASES.values() for p in aliases]
678668
)
679-
def test_build_wheel_compat(target_policy, any_manylinux_container,
669+
@pytest.mark.parametrize('only_plat', [True, False])
670+
def test_build_wheel_compat(target_policy, only_plat, any_manylinux_container,
680671
docker_python, io_folder):
681672
# test building wheels with compatibility with older spec
682673
# check aliases for older spec
@@ -694,18 +685,32 @@ def test_build_wheel_compat(target_policy, any_manylinux_container,
694685

695686
if PLATFORM in {'x86_64', 'i686'}:
696687
expect = f'manylinux_2_5_{PLATFORM}'
688+
expect_tag = f'manylinux_2_5_{PLATFORM}.manylinux1_{PLATFORM}'
697689
else:
698690
expect = f'manylinux_2_17_{PLATFORM}'
691+
expect_tag = f'manylinux_2_17_{PLATFORM}.manylinux2014_{PLATFORM}'
692+
693+
target_tag = target_policy
694+
for pep600_policy, aliases in POLICY_ALIASES.items():
695+
policy_ = f'{pep600_policy}_{PLATFORM}'
696+
aliases_ = [f'{p}_{PLATFORM}' for p in aliases]
697+
if target_policy == policy_ or target_policy in aliases_:
698+
target_tag = f'{policy_}.{".".join(aliases_)}'
699699

700+
only_plat_arg = '--only-plat' if only_plat else ''
700701
# we shall ba able to repair the wheel for all targets
701702
docker_exec(manylinux_ctr, [
702703
'bash', '-c',
703-
f'auditwheel -v repair --plat {target_policy} -w /io /io/{orig_wheel}'])
704+
f'auditwheel -v repair --plat {target_policy} {only_plat_arg} -w /io'
705+
f' /io/{orig_wheel}'])
704706
filenames = os.listdir(io_folder)
705-
assert len(filenames) >= 1
706-
repaired_wheels = [fn for fn in filenames if target_policy in fn]
707-
assert len(repaired_wheels) == 1
708-
repaired_wheel = repaired_wheels[0]
707+
assert len(filenames) == 2
708+
if only_plat or target_tag == expect_tag:
709+
repaired_tag = target_tag
710+
else:
711+
repaired_tag = f'{expect_tag}.{target_tag}'
712+
repaired_wheel = f'testsimple-0.0.1-{PYTHON_ABI}-{repaired_tag}.whl'
713+
assert repaired_wheel in filenames
709714
output = docker_exec(manylinux_ctr, f'auditwheel show /io/{repaired_wheel}')
710715
assert (
711716
f'is consistent with the following platform tag: "{expect}"'

0 commit comments

Comments
 (0)