6
6
7
7
from auditwheel .patcher import Patchelf
8
8
9
- from .policy import (
10
- POLICY_PRIORITY_HIGHEST ,
11
- get_policy_by_name ,
12
- get_policy_name ,
13
- get_priority_by_name ,
14
- load_policies ,
15
- )
9
+ from .policy import WheelPolicies
16
10
from .tools import EnvironmentDefault
17
11
18
12
logger = logging .getLogger (__name__ )
19
13
20
14
21
15
def configure_parser (sub_parsers ):
22
- policies = load_policies ()
16
+ wheel_policy = WheelPolicies ()
17
+ policies = wheel_policy .policies
23
18
policy_names = [p ["name" ] for p in policies ]
24
19
policy_names += [alias for p in policies for alias in p ["aliases" ]]
25
20
epilog = """PLATFORMS:
@@ -32,7 +27,7 @@ def configure_parser(sub_parsers):
32
27
if len (p ["aliases" ]) > 0 :
33
28
epilog += f" (aliased by { ', ' .join (p ['aliases' ])} )"
34
29
epilog += "\n "
35
- highest_policy = get_policy_name (POLICY_PRIORITY_HIGHEST )
30
+ highest_policy = wheel_policy . get_policy_name (wheel_policy . priority_highest )
36
31
help = """Vendor in external shared library dependencies of a wheel.
37
32
If multiple wheels are specified, an error processing one
38
33
wheel will abort processing of subsequent wheels.
@@ -114,6 +109,8 @@ def execute(args, p):
114
109
from .repair import repair_wheel
115
110
from .wheel_abi import NonPlatformWheel , analyze_wheel_abi
116
111
112
+ wheel_policy = WheelPolicies ()
113
+
117
114
for wheel_file in args .WHEEL_FILE :
118
115
if not isfile (wheel_file ):
119
116
p .error ("cannot access %s. No such file" % wheel_file )
@@ -124,23 +121,23 @@ def execute(args, p):
124
121
os .makedirs (args .WHEEL_DIR )
125
122
126
123
try :
127
- wheel_abi = analyze_wheel_abi (wheel_file )
124
+ wheel_abi = analyze_wheel_abi (wheel_policy , wheel_file )
128
125
except NonPlatformWheel :
129
126
logger .info (NonPlatformWheel .LOG_MESSAGE )
130
127
return 1
131
128
132
- policy = get_policy_by_name (args .PLAT )
129
+ policy = wheel_policy . get_policy_by_name (args .PLAT )
133
130
reqd_tag = policy ["priority" ]
134
131
135
- if reqd_tag > get_priority_by_name (wheel_abi .sym_tag ):
132
+ if reqd_tag > wheel_policy . get_priority_by_name (wheel_abi .sym_tag ):
136
133
msg = (
137
134
'cannot repair "%s" to "%s" ABI because of the presence '
138
135
"of too-recent versioned symbols. You'll need to compile "
139
136
"the wheel on an older toolchain." % (wheel_file , args .PLAT )
140
137
)
141
138
p .error (msg )
142
139
143
- if reqd_tag > get_priority_by_name (wheel_abi .ucs_tag ):
140
+ if reqd_tag > wheel_policy . get_priority_by_name (wheel_abi .ucs_tag ):
144
141
msg = (
145
142
'cannot repair "%s" to "%s" ABI because it was compiled '
146
143
"against a UCS2 build of Python. You'll need to compile "
@@ -149,7 +146,7 @@ def execute(args, p):
149
146
)
150
147
p .error (msg )
151
148
152
- if reqd_tag > get_priority_by_name (wheel_abi .blacklist_tag ):
149
+ if reqd_tag > wheel_policy . get_priority_by_name (wheel_abi .blacklist_tag ):
153
150
msg = (
154
151
'cannot repair "%s" to "%s" ABI because it depends on '
155
152
"black-listed symbols." % (wheel_file , args .PLAT )
@@ -158,7 +155,7 @@ def execute(args, p):
158
155
159
156
abis = [policy ["name" ]] + policy ["aliases" ]
160
157
if not args .ONLY_PLAT :
161
- if reqd_tag < get_priority_by_name (wheel_abi .overall_tag ):
158
+ if reqd_tag < wheel_policy . get_priority_by_name (wheel_abi .overall_tag ):
162
159
logger .info (
163
160
(
164
161
"Wheel is eligible for a higher priority tag. "
@@ -168,11 +165,12 @@ def execute(args, p):
168
165
args .PLAT ,
169
166
wheel_abi .overall_tag ,
170
167
)
171
- higher_policy = get_policy_by_name (wheel_abi .overall_tag )
168
+ higher_policy = wheel_policy . get_policy_by_name (wheel_abi .overall_tag )
172
169
abis = [higher_policy ["name" ]] + higher_policy ["aliases" ] + abis
173
170
174
171
patcher = Patchelf ()
175
172
out_wheel = repair_wheel (
173
+ wheel_policy ,
176
174
wheel_file ,
177
175
abis = abis ,
178
176
lib_sdir = args .LIB_SDIR ,
0 commit comments