Skip to content

Always repair as a single wheel #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions auditwheel/main_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def configure_parser(sub_parsers):
action='store_true',
help='Strip symbols in the resulting wheel',
default=False)
p.add_argument('--only-plat',
dest='ONLY_PLAT',
action='store_true',
help='Do not check for higher policy compatibility',
default=False)
p.set_defaults(func=execute)


Expand Down Expand Up @@ -88,6 +93,15 @@ def execute(args, p):
p.error(msg)

abis = [policy['name']] + policy['aliases']
if not args.ONLY_PLAT:
if reqd_tag < get_priority_by_name(wheel_abi.overall_tag):
logger.info(('Wheel is eligible for a higher priority tag. '
'You requested %s but I have found this wheel is '
'eligible for %s.'),
args.PLAT, wheel_abi.overall_tag)
higher_policy = get_policy_by_name(wheel_abi.overall_tag)
abis = [higher_policy['name']] + higher_policy['aliases'] + abis

patcher = Patchelf()
out_wheel = repair_wheel(args.WHEEL_FILE,
abis=abis,
Expand All @@ -98,19 +112,4 @@ def execute(args, p):
strip=args.STRIP)

if out_wheel is not None:
analyzed_tag = analyze_wheel_abi(out_wheel).overall_tag
if reqd_tag < get_priority_by_name(analyzed_tag):
logger.info(('Wheel is eligible for a higher priority tag. '
'You requested %s but I have found this wheel is '
'eligible for %s.'),
args.PLAT, analyzed_tag)
policy = get_policy_by_name(analyzed_tag)
abis = [policy['name']] + policy['aliases']
out_wheel = repair_wheel(args.WHEEL_FILE,
abis=abis,
lib_sdir=args.LIB_SDIR,
out_dir=args.WHEEL_DIR,
update_tags=args.UPDATE_TAGS,
patcher=patcher)

logger.info('\nFixed-up wheel written to %s', out_wheel)
87 changes: 46 additions & 41 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,13 @@ def test_build_repair_numpy(any_manylinux_container, docker_python, io_folder):
assert 'manylinux' not in orig_wheel

# Repair the wheel using the manylinux container
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
repair_command = \
f'auditwheel repair --plat {policy} --only-plat -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 'manylinux' in fn]
assert repaired_wheels == [
f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{tag}.whl'
]
repaired_wheel = repaired_wheels[0]
repaired_wheel = f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
assert (
f'numpy-{NUMPY_VERSION}-{PYTHON_ABI}-{tag}.whl is consistent'
Expand Down Expand Up @@ -282,15 +279,13 @@ def test_build_wheel_with_binary_executable(any_manylinux_container, docker_pyth
assert 'manylinux' not in orig_wheel

# Repair the wheel using the appropriate manylinux container
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
repair_command = \
f'auditwheel repair --plat {policy} --only-plat -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-{tag}.whl'
assert repaired_wheels == [expected_wheel_name]
repaired_wheel = repaired_wheels[0]
repaired_wheel = f'testpackage-0.0.1-py3-none-{tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
assert (
f'testpackage-0.0.1-py3-none-{tag}.whl is consistent'
Expand Down Expand Up @@ -356,10 +351,8 @@ def test_build_wheel_with_image_dependencies(with_dependency, any_manylinux_cont
repair_command.format(policy=policy, orig_wheel=orig_wheel)])
filenames = os.listdir(io_folder)
assert len(filenames) == 2
repaired_wheels = [fn for fn in filenames if policy in fn]
expected_wheel_name = f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheels == [expected_wheel_name]
repaired_wheel = repaired_wheels[0]
repaired_wheel = f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
assert (
f'testdependencies-0.0.1-{PYTHON_ABI}-{tag}.whl is consistent'
Expand Down Expand Up @@ -452,17 +445,16 @@ def test_build_wheel_depending_on_library_with_rpath(any_manylinux_container, do
assert 'manylinux' not in orig_wheel

# Repair the wheel using the appropriate manylinux container
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
repair_command = \
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
docker_exec(
manylinux_ctr,
['bash', '-c', 'LD_LIBRARY_PATH=/auditwheel_src/tests/integration/testrpath/a:$LD_LIBRARY_PATH ' + repair_command],
)
filenames = os.listdir(io_folder)
repaired_wheels = [fn for fn in filenames if policy in fn]
# Wheel picks up newer symbols when built in manylinux2010
expected_wheel_name = f'testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl'
assert expected_wheel_name in repaired_wheels
repaired_wheel = expected_wheel_name
assert len(filenames) == 2
repaired_wheel = f'testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
if PLATFORM in {'x86_64', 'i686'}:
expect = f'manylinux_2_5_{PLATFORM}'
Expand Down Expand Up @@ -514,7 +506,8 @@ def test_build_repair_multiple_top_level_modules_wheel(any_manylinux_container,
assert 'manylinux' not in orig_wheel

# Repair the wheel using the appropriate manylinux container
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
repair_command = \
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
docker_exec(
manylinux_ctr,
[
Expand All @@ -530,11 +523,9 @@ def test_build_repair_multiple_top_level_modules_wheel(any_manylinux_container,
],
)
filenames = os.listdir(io_folder)
repaired_wheels = [fn for fn in filenames if policy in fn]
# Wheel picks up newer symbols when built in manylinux2010
expected_wheel_name = f'multiple_top_level-1.0-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheels == [expected_wheel_name]
repaired_wheel = expected_wheel_name
assert len(filenames) == 2
repaired_wheel = f'multiple_top_level-1.0-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
if PLATFORM in {'x86_64', 'i686'}:
expect = f'manylinux_2_5_{PLATFORM}'
Expand Down Expand Up @@ -590,7 +581,8 @@ def test_build_repair_wheel_with_internal_rpath(any_manylinux_container, docker_
assert 'manylinux' not in orig_wheel

# Repair the wheel using the appropriate manylinux container
repair_command = f'auditwheel repair --plat {policy} -w /io /io/{orig_wheel}'
repair_command = \
f'auditwheel repair --plat {policy} --only-plat -w /io /io/{orig_wheel}'
docker_exec(
manylinux_ctr,
[
Expand All @@ -605,11 +597,9 @@ def test_build_repair_wheel_with_internal_rpath(any_manylinux_container, docker_
],
)
filenames = os.listdir(io_folder)
repaired_wheels = [fn for fn in filenames if policy in fn]
# Wheel picks up newer symbols when built in manylinux2010
expected_wheel_name = f'internal_rpath-1.0-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheels == [expected_wheel_name]
repaired_wheel = expected_wheel_name
assert len(filenames) == 2
repaired_wheel = f'internal_rpath-1.0-{PYTHON_ABI}-{tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, 'auditwheel show /io/' + repaired_wheel)
if PLATFORM in {'x86_64', 'i686'}:
expect = f'manylinux_2_5_{PLATFORM}'
Expand Down Expand Up @@ -676,7 +666,8 @@ def test_strip_wheel(any_manylinux_container, docker_python, io_folder):
[f'{p}_{PLATFORM}' for p in list(MANYLINUX_IMAGES.keys())] +
[f'{p}_{PLATFORM}' for aliases in POLICY_ALIASES.values() for p in aliases]
)
def test_build_wheel_compat(target_policy, any_manylinux_container,
@pytest.mark.parametrize('only_plat', [True, False])
def test_build_wheel_compat(target_policy, only_plat, any_manylinux_container,
docker_python, io_folder):
# test building wheels with compatibility with older spec
# check aliases for older spec
Expand All @@ -694,18 +685,32 @@ def test_build_wheel_compat(target_policy, any_manylinux_container,

if PLATFORM in {'x86_64', 'i686'}:
expect = f'manylinux_2_5_{PLATFORM}'
expect_tag = f'manylinux_2_5_{PLATFORM}.manylinux1_{PLATFORM}'
else:
expect = f'manylinux_2_17_{PLATFORM}'
expect_tag = f'manylinux_2_17_{PLATFORM}.manylinux2014_{PLATFORM}'

target_tag = target_policy
for pep600_policy, aliases in POLICY_ALIASES.items():
policy_ = f'{pep600_policy}_{PLATFORM}'
aliases_ = [f'{p}_{PLATFORM}' for p in aliases]
if target_policy == policy_ or target_policy in aliases_:
target_tag = f'{policy_}.{".".join(aliases_)}'

only_plat_arg = '--only-plat' if only_plat else ''
# we shall ba able to repair the wheel for all targets
docker_exec(manylinux_ctr, [
'bash', '-c',
f'auditwheel -v repair --plat {target_policy} -w /io /io/{orig_wheel}'])
f'auditwheel -v repair --plat {target_policy} {only_plat_arg} -w /io'
f' /io/{orig_wheel}'])
filenames = os.listdir(io_folder)
assert len(filenames) >= 1
repaired_wheels = [fn for fn in filenames if target_policy in fn]
assert len(repaired_wheels) == 1
repaired_wheel = repaired_wheels[0]
assert len(filenames) == 2
if only_plat or target_tag == expect_tag:
repaired_tag = target_tag
else:
repaired_tag = f'{expect_tag}.{target_tag}'
repaired_wheel = f'testsimple-0.0.1-{PYTHON_ABI}-{repaired_tag}.whl'
assert repaired_wheel in filenames
output = docker_exec(manylinux_ctr, f'auditwheel show /io/{repaired_wheel}')
assert (
f'is consistent with the following platform tag: "{expect}"'
Expand Down