Skip to content

Commit 8672e8a

Browse files
committed
Only create a single repaired wheel
When repairing wheels, the result can be compliant with a lower-level manylinux spec and in this case auditwheel creates another .whl file for the lower spec as well. This is unnecessary as the lower spec can always be used on newer compliant platforms. By only producing a single wheel, we can probably save some space on PyPI as automated build scripts won't upload multiple copies of the same wheel. This also avoids an extra call to repair_wheel which can speed things up for larger libraries.
1 parent 22c8451 commit 8672e8a

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

auditwheel/main_repair.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import logging
2+
import os
13
from os.path import isfile, exists, abspath, basename
24

3-
from auditwheel.patcher import Patchelf
5+
from .patcher import Patchelf
46
from .policy import (load_policies, get_policy_name, get_priority_by_name,
57
POLICY_PRIORITY_HIGHEST)
8+
from .repair import repair_wheel
69
from .tools import EnvironmentDefault
7-
import logging
10+
from .wheel_abi import analyze_wheel_abi, NonPlatformWheel
811

912
logger = logging.getLogger(__name__)
1013

@@ -50,10 +53,27 @@ def configure_parser(sub_parsers):
5053
p.set_defaults(func=execute)
5154

5255

56+
def _repair_wheel(requested_tag, args, patcher):
57+
analyzed_tag = analyze_wheel_abi(args.WHEEL_FILE).overall_tag
58+
if requested_tag < get_priority_by_name(analyzed_tag):
59+
logger.info(('Wheel is eligible for a higher priority tag. '
60+
'You requested %s but I have found this wheel is '
61+
'eligible for %s.'),
62+
args.PLAT, analyzed_tag)
63+
requested_tag = analyzed_tag
64+
out_wheel = repair_wheel(args.WHEEL_FILE,
65+
abi=requested_tag,
66+
lib_sdir=args.LIB_SDIR,
67+
out_dir=args.WHEEL_DIR,
68+
update_tags=args.UPDATE_TAGS,
69+
patcher=patcher,
70+
strip=args.STRIP)
71+
72+
if out_wheel is not None:
73+
logger.info('\nFixed-up wheel written to %s', out_wheel)
74+
75+
5376
def execute(args, p):
54-
import os
55-
from .repair import repair_wheel
56-
from .wheel_abi import analyze_wheel_abi, NonPlatformWheel
5777

5878
if not isfile(args.WHEEL_FILE):
5979
p.error('cannot access %s. No such file' % args.WHEEL_FILE)
@@ -86,26 +106,4 @@ def execute(args, p):
86106
p.error(msg)
87107

88108
patcher = Patchelf()
89-
out_wheel = repair_wheel(args.WHEEL_FILE,
90-
abi=args.PLAT,
91-
lib_sdir=args.LIB_SDIR,
92-
out_dir=args.WHEEL_DIR,
93-
update_tags=args.UPDATE_TAGS,
94-
patcher=patcher,
95-
strip=args.STRIP)
96-
97-
if out_wheel is not None:
98-
analyzed_tag = analyze_wheel_abi(out_wheel).overall_tag
99-
if reqd_tag < get_priority_by_name(analyzed_tag):
100-
logger.info(('Wheel is eligible for a higher priority tag. '
101-
'You requested %s but I have found this wheel is '
102-
'eligible for %s.'),
103-
args.PLAT, analyzed_tag)
104-
out_wheel = repair_wheel(args.WHEEL_FILE,
105-
abi=analyzed_tag,
106-
lib_sdir=args.LIB_SDIR,
107-
out_dir=args.WHEEL_DIR,
108-
update_tags=args.UPDATE_TAGS,
109-
patcher=patcher)
110-
111-
logger.info('\nFixed-up wheel written to %s', out_wheel)
109+
_repair_wheel(reqd_tag, args, patcher)

0 commit comments

Comments
 (0)