66
77from auditwheel .patcher import Patchelf
88
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
1610from .tools import EnvironmentDefault
1711
1812logger = logging .getLogger (__name__ )
1913
2014
2115def configure_parser (sub_parsers ):
22- policies = load_policies ()
16+ wheel_policy = WheelPolicies ()
17+ policies = wheel_policy .policies
2318 policy_names = [p ["name" ] for p in policies ]
2419 policy_names += [alias for p in policies for alias in p ["aliases" ]]
2520 epilog = """PLATFORMS:
@@ -32,7 +27,7 @@ def configure_parser(sub_parsers):
3227 if len (p ["aliases" ]) > 0 :
3328 epilog += f" (aliased by { ', ' .join (p ['aliases' ])} )"
3429 epilog += "\n "
35- highest_policy = get_policy_name (POLICY_PRIORITY_HIGHEST )
30+ highest_policy = wheel_policy . get_policy_name (wheel_policy . priority_highest )
3631 help = """Vendor in external shared library dependencies of a wheel.
3732If multiple wheels are specified, an error processing one
3833wheel will abort processing of subsequent wheels.
@@ -114,6 +109,8 @@ def execute(args, p):
114109 from .repair import repair_wheel
115110 from .wheel_abi import NonPlatformWheel , analyze_wheel_abi
116111
112+ wheel_policy = WheelPolicies ()
113+
117114 for wheel_file in args .WHEEL_FILE :
118115 if not isfile (wheel_file ):
119116 p .error ("cannot access %s. No such file" % wheel_file )
@@ -124,23 +121,23 @@ def execute(args, p):
124121 os .makedirs (args .WHEEL_DIR )
125122
126123 try :
127- wheel_abi = analyze_wheel_abi (wheel_file )
124+ wheel_abi = analyze_wheel_abi (wheel_policy , wheel_file )
128125 except NonPlatformWheel :
129126 logger .info (NonPlatformWheel .LOG_MESSAGE )
130127 return 1
131128
132- policy = get_policy_by_name (args .PLAT )
129+ policy = wheel_policy . get_policy_by_name (args .PLAT )
133130 reqd_tag = policy ["priority" ]
134131
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 ):
136133 msg = (
137134 'cannot repair "%s" to "%s" ABI because of the presence '
138135 "of too-recent versioned symbols. You'll need to compile "
139136 "the wheel on an older toolchain." % (wheel_file , args .PLAT )
140137 )
141138 p .error (msg )
142139
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 ):
144141 msg = (
145142 'cannot repair "%s" to "%s" ABI because it was compiled '
146143 "against a UCS2 build of Python. You'll need to compile "
@@ -149,7 +146,7 @@ def execute(args, p):
149146 )
150147 p .error (msg )
151148
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 ):
153150 msg = (
154151 'cannot repair "%s" to "%s" ABI because it depends on '
155152 "black-listed symbols." % (wheel_file , args .PLAT )
@@ -158,7 +155,7 @@ def execute(args, p):
158155
159156 abis = [policy ["name" ]] + policy ["aliases" ]
160157 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 ):
162159 logger .info (
163160 (
164161 "Wheel is eligible for a higher priority tag. "
@@ -168,11 +165,12 @@ def execute(args, p):
168165 args .PLAT ,
169166 wheel_abi .overall_tag ,
170167 )
171- higher_policy = get_policy_by_name (wheel_abi .overall_tag )
168+ higher_policy = wheel_policy . get_policy_by_name (wheel_abi .overall_tag )
172169 abis = [higher_policy ["name" ]] + higher_policy ["aliases" ] + abis
173170
174171 patcher = Patchelf ()
175172 out_wheel = repair_wheel (
173+ wheel_policy ,
176174 wheel_file ,
177175 abis = abis ,
178176 lib_sdir = args .LIB_SDIR ,
0 commit comments