15
15
def configure_parser (sub_parsers ) -> None : # type: ignore[no-untyped-def]
16
16
wheel_policy = WheelPolicies ()
17
17
policies = wheel_policy .policies
18
- policy_names = [p [ " name" ] for p in policies ]
19
- policy_names += [alias for p in policies for alias in p [ " aliases" ] ]
18
+ policy_names = [p . name for p in policies ]
19
+ policy_names += [alias for p in policies for alias in p . aliases ]
20
20
epilog = """PLATFORMS:
21
21
These are the possible target platform tags, as specified by PEP 600.
22
22
Note that old, pre-PEP 600 tags are still usable and are listed as aliases
23
23
below.
24
24
"""
25
25
for p in policies :
26
- epilog += f"- { p [ ' name' ] } "
27
- if len (p [ " aliases" ] ) > 0 :
28
- epilog += f" (aliased by { ', ' .join (p [ ' aliases' ] )} )"
26
+ epilog += f"- { p . name } "
27
+ if len (p . aliases ) > 0 :
28
+ epilog += f" (aliased by { ', ' .join (p . aliases )} )"
29
29
epilog += "\n "
30
- highest_policy = wheel_policy .get_policy_name ( wheel_policy . priority_highest )
30
+ highest_policy = wheel_policy .highest . name
31
31
help = """Vendor in external shared library dependencies of a wheel.
32
32
If multiple wheels are specified, an error processing one
33
33
wheel will abort processing of subsequent wheels.
34
34
"""
35
- p = sub_parsers .add_parser (
35
+ parser = sub_parsers .add_parser (
36
36
"repair" ,
37
37
help = help ,
38
38
description = help ,
39
39
epilog = epilog ,
40
40
formatter_class = argparse .RawDescriptionHelpFormatter ,
41
41
)
42
- p .add_argument ("WHEEL_FILE" , help = "Path to wheel file." , nargs = "+" )
43
- p .add_argument (
42
+ parser .add_argument ("WHEEL_FILE" , help = "Path to wheel file." , nargs = "+" )
43
+ parser .add_argument (
44
44
"--plat" ,
45
45
action = EnvironmentDefault ,
46
46
metavar = "PLATFORM" ,
@@ -51,22 +51,22 @@ def configure_parser(sub_parsers) -> None: # type: ignore[no-untyped-def]
51
51
choices = policy_names ,
52
52
default = highest_policy ,
53
53
)
54
- p .add_argument (
54
+ parser .add_argument (
55
55
"-L" ,
56
56
"--lib-sdir" ,
57
57
dest = "LIB_SDIR" ,
58
58
help = ('Subdirectory in packages to store copied libraries. (default: ".libs")' ),
59
59
default = ".libs" ,
60
60
)
61
- p .add_argument (
61
+ parser .add_argument (
62
62
"-w" ,
63
63
"--wheel-dir" ,
64
64
dest = "WHEEL_DIR" ,
65
65
type = abspath ,
66
66
help = ('Directory to store delocated wheels (default: "wheelhouse/")' ),
67
67
default = "wheelhouse/" ,
68
68
)
69
- p .add_argument (
69
+ parser .add_argument (
70
70
"--no-update-tags" ,
71
71
dest = "UPDATE_TAGS" ,
72
72
action = "store_false" ,
@@ -76,14 +76,14 @@ def configure_parser(sub_parsers) -> None: # type: ignore[no-untyped-def]
76
76
),
77
77
default = True ,
78
78
)
79
- p .add_argument (
79
+ parser .add_argument (
80
80
"--strip" ,
81
81
dest = "STRIP" ,
82
82
action = "store_true" ,
83
83
help = "Strip symbols in the resulting wheel" ,
84
84
default = False ,
85
85
)
86
- p .add_argument (
86
+ parser .add_argument (
87
87
"--exclude" ,
88
88
dest = "EXCLUDE" ,
89
89
help = "Exclude SONAME from grafting into the resulting wheel "
@@ -94,21 +94,21 @@ def configure_parser(sub_parsers) -> None: # type: ignore[no-untyped-def]
94
94
action = "append" ,
95
95
default = [],
96
96
)
97
- p .add_argument (
97
+ parser .add_argument (
98
98
"--only-plat" ,
99
99
dest = "ONLY_PLAT" ,
100
100
action = "store_true" ,
101
101
help = "Do not check for higher policy compatibility" ,
102
102
default = False ,
103
103
)
104
- p .add_argument (
104
+ parser .add_argument (
105
105
"--disable-isa-ext-check" ,
106
106
dest = "DISABLE_ISA_EXT_CHECK" ,
107
107
action = "store_true" ,
108
108
help = "Do not check for extended ISA compatibility (e.g. x86_64_v2)" ,
109
109
default = False ,
110
110
)
111
- p .set_defaults (func = execute )
111
+ parser .set_defaults (func = execute )
112
112
113
113
114
114
def execute (args : argparse .Namespace , parser : argparse .ArgumentParser ) -> int :
@@ -137,56 +137,54 @@ def execute(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:
137
137
logger .info (e .message )
138
138
return 1
139
139
140
- policy = wheel_policy .get_policy_by_name (args .PLAT )
141
- assert policy is not None
142
- reqd_tag = policy ["priority" ]
140
+ requested_policy = wheel_policy .get_policy_by_name (args .PLAT )
143
141
144
- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .sym_tag ) :
142
+ if requested_policy > wheel_abi .sym_policy :
145
143
msg = (
146
144
f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because of the '
147
145
"presence of too-recent versioned symbols. You'll need to compile "
148
146
"the wheel on an older toolchain."
149
147
)
150
148
parser .error (msg )
151
149
152
- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .ucs_tag ) :
150
+ if requested_policy > wheel_abi .ucs_policy :
153
151
msg = (
154
152
f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because it was '
155
153
"compiled against a UCS2 build of Python. You'll need to compile "
156
154
"the wheel against a wide-unicode build of Python."
157
155
)
158
156
parser .error (msg )
159
157
160
- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .blacklist_tag ) :
158
+ if requested_policy > wheel_abi .blacklist_policy :
161
159
msg = (
162
160
f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because it '
163
161
"depends on black-listed symbols."
164
162
)
165
163
parser .error (msg )
166
164
167
- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .machine_tag ) :
165
+ if requested_policy > wheel_abi .machine_policy :
168
166
msg = (
169
167
f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because it '
170
168
"depends on unsupported ISA extensions."
171
169
)
172
170
parser .error (msg )
173
171
174
- abis = [policy ["name" ]] + policy ["aliases" ]
175
- if (not args .ONLY_PLAT ) and reqd_tag < wheel_policy .get_priority_by_name (
176
- wheel_abi .overall_tag
177
- ):
172
+ abis = [requested_policy .name , * requested_policy .aliases ]
173
+ if (not args .ONLY_PLAT ) and requested_policy < wheel_abi .overall_policy :
178
174
logger .info (
179
175
(
180
176
"Wheel is eligible for a higher priority tag. "
181
177
"You requested %s but I have found this wheel is "
182
178
"eligible for %s."
183
179
),
184
180
args .PLAT ,
185
- wheel_abi .overall_tag ,
181
+ wheel_abi .overall_policy . name ,
186
182
)
187
- higher_policy = wheel_policy .get_policy_by_name (wheel_abi .overall_tag )
188
- assert higher_policy is not None
189
- abis = [higher_policy ["name" ]] + higher_policy ["aliases" ] + abis
183
+ abis = [
184
+ wheel_abi .overall_policy .name ,
185
+ * wheel_abi .overall_policy .aliases ,
186
+ * abis ,
187
+ ]
190
188
191
189
patcher = Patchelf ()
192
190
out_wheel = repair_wheel (
0 commit comments