1515def configure_parser (sub_parsers ) -> None : # type: ignore[no-untyped-def]
1616 wheel_policy = WheelPolicies ()
1717 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 ]
2020 epilog = """PLATFORMS:
2121These are the possible target platform tags, as specified by PEP 600.
2222Note that old, pre-PEP 600 tags are still usable and are listed as aliases
2323below.
2424"""
2525 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 )} )"
2929 epilog += "\n "
30- highest_policy = wheel_policy .get_policy_name ( wheel_policy . priority_highest )
30+ highest_policy = wheel_policy .highest . name
3131 help = """Vendor in external shared library dependencies of a wheel.
3232If multiple wheels are specified, an error processing one
3333wheel will abort processing of subsequent wheels.
3434"""
35- p = sub_parsers .add_parser (
35+ parser = sub_parsers .add_parser (
3636 "repair" ,
3737 help = help ,
3838 description = help ,
3939 epilog = epilog ,
4040 formatter_class = argparse .RawDescriptionHelpFormatter ,
4141 )
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 (
4444 "--plat" ,
4545 action = EnvironmentDefault ,
4646 metavar = "PLATFORM" ,
@@ -51,22 +51,22 @@ def configure_parser(sub_parsers) -> None: # type: ignore[no-untyped-def]
5151 choices = policy_names ,
5252 default = highest_policy ,
5353 )
54- p .add_argument (
54+ parser .add_argument (
5555 "-L" ,
5656 "--lib-sdir" ,
5757 dest = "LIB_SDIR" ,
5858 help = ('Subdirectory in packages to store copied libraries. (default: ".libs")' ),
5959 default = ".libs" ,
6060 )
61- p .add_argument (
61+ parser .add_argument (
6262 "-w" ,
6363 "--wheel-dir" ,
6464 dest = "WHEEL_DIR" ,
6565 type = abspath ,
6666 help = ('Directory to store delocated wheels (default: "wheelhouse/")' ),
6767 default = "wheelhouse/" ,
6868 )
69- p .add_argument (
69+ parser .add_argument (
7070 "--no-update-tags" ,
7171 dest = "UPDATE_TAGS" ,
7272 action = "store_false" ,
@@ -76,14 +76,14 @@ def configure_parser(sub_parsers) -> None: # type: ignore[no-untyped-def]
7676 ),
7777 default = True ,
7878 )
79- p .add_argument (
79+ parser .add_argument (
8080 "--strip" ,
8181 dest = "STRIP" ,
8282 action = "store_true" ,
8383 help = "Strip symbols in the resulting wheel" ,
8484 default = False ,
8585 )
86- p .add_argument (
86+ parser .add_argument (
8787 "--exclude" ,
8888 dest = "EXCLUDE" ,
8989 help = "Exclude SONAME from grafting into the resulting wheel "
@@ -94,21 +94,21 @@ def configure_parser(sub_parsers) -> None: # type: ignore[no-untyped-def]
9494 action = "append" ,
9595 default = [],
9696 )
97- p .add_argument (
97+ parser .add_argument (
9898 "--only-plat" ,
9999 dest = "ONLY_PLAT" ,
100100 action = "store_true" ,
101101 help = "Do not check for higher policy compatibility" ,
102102 default = False ,
103103 )
104- p .add_argument (
104+ parser .add_argument (
105105 "--disable-isa-ext-check" ,
106106 dest = "DISABLE_ISA_EXT_CHECK" ,
107107 action = "store_true" ,
108108 help = "Do not check for extended ISA compatibility (e.g. x86_64_v2)" ,
109109 default = False ,
110110 )
111- p .set_defaults (func = execute )
111+ parser .set_defaults (func = execute )
112112
113113
114114def execute (args : argparse .Namespace , parser : argparse .ArgumentParser ) -> int :
@@ -137,56 +137,54 @@ def execute(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:
137137 logger .info (e .message )
138138 return 1
139139
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 )
143141
144- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .sym_tag ) :
142+ if requested_policy > wheel_abi .sym_policy :
145143 msg = (
146144 f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because of the '
147145 "presence of too-recent versioned symbols. You'll need to compile "
148146 "the wheel on an older toolchain."
149147 )
150148 parser .error (msg )
151149
152- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .ucs_tag ) :
150+ if requested_policy > wheel_abi .ucs_policy :
153151 msg = (
154152 f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because it was '
155153 "compiled against a UCS2 build of Python. You'll need to compile "
156154 "the wheel against a wide-unicode build of Python."
157155 )
158156 parser .error (msg )
159157
160- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .blacklist_tag ) :
158+ if requested_policy > wheel_abi .blacklist_policy :
161159 msg = (
162160 f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because it '
163161 "depends on black-listed symbols."
164162 )
165163 parser .error (msg )
166164
167- if reqd_tag > wheel_policy . get_priority_by_name ( wheel_abi .machine_tag ) :
165+ if requested_policy > wheel_abi .machine_policy :
168166 msg = (
169167 f'cannot repair "{ wheel_file } " to "{ args .PLAT } " ABI because it '
170168 "depends on unsupported ISA extensions."
171169 )
172170 parser .error (msg )
173171
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 :
178174 logger .info (
179175 (
180176 "Wheel is eligible for a higher priority tag. "
181177 "You requested %s but I have found this wheel is "
182178 "eligible for %s."
183179 ),
184180 args .PLAT ,
185- wheel_abi .overall_tag ,
181+ wheel_abi .overall_policy . name ,
186182 )
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+ ]
190188
191189 patcher = Patchelf ()
192190 out_wheel = repair_wheel (
0 commit comments