|
| 1 | +import logging |
| 2 | +import os |
1 | 3 | from os.path import isfile, exists, abspath, basename
|
2 | 4 |
|
3 |
| -from auditwheel.patcher import Patchelf |
| 5 | +from .patcher import Patchelf |
4 | 6 | from .policy import (load_policies, get_policy_name, get_priority_by_name,
|
5 | 7 | POLICY_PRIORITY_HIGHEST)
|
| 8 | +from .repair import repair_wheel |
6 | 9 | from .tools import EnvironmentDefault
|
7 |
| -import logging |
| 10 | +from .wheel_abi import analyze_wheel_abi, NonPlatformWheel |
8 | 11 |
|
9 | 12 | logger = logging.getLogger(__name__)
|
10 | 13 |
|
@@ -50,10 +53,27 @@ def configure_parser(sub_parsers):
|
50 | 53 | p.set_defaults(func=execute)
|
51 | 54 |
|
52 | 55 |
|
| 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 | + |
53 | 76 | def execute(args, p):
|
54 |
| - import os |
55 |
| - from .repair import repair_wheel |
56 |
| - from .wheel_abi import analyze_wheel_abi, NonPlatformWheel |
57 | 77 |
|
58 | 78 | if not isfile(args.WHEEL_FILE):
|
59 | 79 | p.error('cannot access %s. No such file' % args.WHEEL_FILE)
|
@@ -86,26 +106,4 @@ def execute(args, p):
|
86 | 106 | p.error(msg)
|
87 | 107 |
|
88 | 108 | 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