Skip to content

Commit 46a7274

Browse files
tipabuauvipy
authored andcommitted
Allow auditwheel repair to process multiple wheels
Closes #62
1 parent 4b98b17 commit 46a7274

File tree

2 files changed

+68
-64
lines changed

2 files changed

+68
-64
lines changed

src/auditwheel/main_repair.py

Lines changed: 67 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ def configure_parser(sub_parsers):
3131
epilog += f" (aliased by {', '.join(p['aliases'])})"
3232
epilog += "\n"
3333
highest_policy = get_policy_name(POLICY_PRIORITY_HIGHEST)
34-
help = "Vendor in external shared library dependencies of a wheel."
34+
help = """Vendor in external shared library dependencies of a wheel.
35+
If multiple wheels are specified, an error processing one
36+
wheel will abort processing of subsequent wheels.
37+
"""
3538
p = sub_parsers.add_parser(
3639
"repair",
3740
help=help,
3841
description=help,
3942
epilog=epilog,
4043
formatter_class=argparse.RawDescriptionHelpFormatter,
4144
)
42-
p.add_argument("WHEEL_FILE", help="Path to wheel file.")
45+
p.add_argument("WHEEL_FILE", help="Path to wheel file.", nargs="+")
4346
p.add_argument(
4447
"--plat",
4548
action=EnvironmentDefault,
@@ -101,72 +104,73 @@ def execute(args, p):
101104
from .repair import repair_wheel
102105
from .wheel_abi import NonPlatformWheel, analyze_wheel_abi
103106

104-
if not isfile(args.WHEEL_FILE):
105-
p.error("cannot access %s. No such file" % args.WHEEL_FILE)
107+
for wheel_file in args.WHEEL_FILE:
108+
if not isfile(wheel_file):
109+
p.error("cannot access %s. No such file" % wheel_file)
106110

107-
logger.info("Repairing %s", basename(args.WHEEL_FILE))
111+
logger.info("Repairing %s", basename(wheel_file))
108112

109-
if not exists(args.WHEEL_DIR):
110-
os.makedirs(args.WHEEL_DIR)
113+
if not exists(args.WHEEL_DIR):
114+
os.makedirs(args.WHEEL_DIR)
111115

112-
try:
113-
wheel_abi = analyze_wheel_abi(args.WHEEL_FILE)
114-
except NonPlatformWheel:
115-
logger.info("This does not look like a platform wheel")
116-
return 1
116+
try:
117+
wheel_abi = analyze_wheel_abi(wheel_file)
118+
except NonPlatformWheel:
119+
logger.info("This does not look like a platform wheel")
120+
return 1
117121

118-
policy = get_policy_by_name(args.PLAT)
119-
reqd_tag = policy["priority"]
122+
policy = get_policy_by_name(args.PLAT)
123+
reqd_tag = policy["priority"]
120124

121-
if reqd_tag > get_priority_by_name(wheel_abi.sym_tag):
122-
msg = (
123-
'cannot repair "%s" to "%s" ABI because of the presence '
124-
"of too-recent versioned symbols. You'll need to compile "
125-
"the wheel on an older toolchain." % (args.WHEEL_FILE, args.PLAT)
126-
)
127-
p.error(msg)
128-
129-
if reqd_tag > get_priority_by_name(wheel_abi.ucs_tag):
130-
msg = (
131-
'cannot repair "%s" to "%s" ABI because it was compiled '
132-
"against a UCS2 build of Python. You'll need to compile "
133-
"the wheel against a wide-unicode build of Python."
134-
% (args.WHEEL_FILE, args.PLAT)
135-
)
136-
p.error(msg)
125+
if reqd_tag > get_priority_by_name(wheel_abi.sym_tag):
126+
msg = (
127+
'cannot repair "%s" to "%s" ABI because of the presence '
128+
"of too-recent versioned symbols. You'll need to compile "
129+
"the wheel on an older toolchain." % (wheel_file, args.PLAT)
130+
)
131+
p.error(msg)
132+
133+
if reqd_tag > get_priority_by_name(wheel_abi.ucs_tag):
134+
msg = (
135+
'cannot repair "%s" to "%s" ABI because it was compiled '
136+
"against a UCS2 build of Python. You'll need to compile "
137+
"the wheel against a wide-unicode build of Python."
138+
% (wheel_file, args.PLAT)
139+
)
140+
p.error(msg)
137141

138-
if reqd_tag > get_priority_by_name(wheel_abi.blacklist_tag):
139-
msg = (
140-
'cannot repair "%s" to "%s" ABI because it depends on '
141-
"black-listed symbols." % (args.WHEEL_FILE, args.PLAT)
142-
)
143-
p.error(msg)
144-
145-
abis = [policy["name"]] + policy["aliases"]
146-
if not args.ONLY_PLAT:
147-
if reqd_tag < get_priority_by_name(wheel_abi.overall_tag):
148-
logger.info(
149-
(
150-
"Wheel is eligible for a higher priority tag. "
151-
"You requested %s but I have found this wheel is "
152-
"eligible for %s."
153-
),
154-
args.PLAT,
155-
wheel_abi.overall_tag,
142+
if reqd_tag > get_priority_by_name(wheel_abi.blacklist_tag):
143+
msg = (
144+
'cannot repair "%s" to "%s" ABI because it depends on '
145+
"black-listed symbols." % (wheel_file, args.PLAT)
156146
)
157-
higher_policy = get_policy_by_name(wheel_abi.overall_tag)
158-
abis = [higher_policy["name"]] + higher_policy["aliases"] + abis
159-
160-
patcher = Patchelf()
161-
out_wheel = repair_wheel(
162-
args.WHEEL_FILE,
163-
abis=abis,
164-
lib_sdir=args.LIB_SDIR,
165-
out_dir=args.WHEEL_DIR,
166-
update_tags=args.UPDATE_TAGS,
167-
patcher=patcher,
168-
strip=args.STRIP,
169-
)
147+
p.error(msg)
148+
149+
abis = [policy["name"]] + policy["aliases"]
150+
if not args.ONLY_PLAT:
151+
if reqd_tag < get_priority_by_name(wheel_abi.overall_tag):
152+
logger.info(
153+
(
154+
"Wheel is eligible for a higher priority tag. "
155+
"You requested %s but I have found this wheel is "
156+
"eligible for %s."
157+
),
158+
args.PLAT,
159+
wheel_abi.overall_tag,
160+
)
161+
higher_policy = get_policy_by_name(wheel_abi.overall_tag)
162+
abis = [higher_policy["name"]] + higher_policy["aliases"] + abis
163+
164+
patcher = Patchelf()
165+
out_wheel = repair_wheel(
166+
wheel_file,
167+
abis=abis,
168+
lib_sdir=args.LIB_SDIR,
169+
out_dir=args.WHEEL_DIR,
170+
update_tags=args.UPDATE_TAGS,
171+
patcher=patcher,
172+
strip=args.STRIP,
173+
)
170174

171-
if out_wheel is not None:
172-
logger.info("\nFixed-up wheel written to %s", out_wheel)
175+
if out_wheel is not None:
176+
logger.info("\nFixed-up wheel written to %s", out_wheel)

tests/integration/test_bundled_wheels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_wheel_source_date_epoch(tmp_path, monkeypatch):
6666
STRIP=False,
6767
UPDATE_TAGS=True,
6868
WHEEL_DIR=str(wheel_output_path),
69-
WHEEL_FILE=str(wheel_path),
69+
WHEEL_FILE=[str(wheel_path)],
7070
cmd="repair",
7171
func=Mock(),
7272
prog="auditwheel",

0 commit comments

Comments
 (0)