@@ -2440,28 +2440,29 @@ def patch_ldflags(flag_list: List[str]) -> List[str]:
2440
2440
def linking_patch (lib_dirs : List [str ], libs : List [str ]) -> List [str ]:
2441
2441
if sys .platform != "win32" :
2442
2442
return [f"-l{ l } " for l in libs ]
2443
-
2444
- def sort_key (lib ): # type: ignore
2445
- name , * numbers , extension = lib .split ("." )
2446
- return (extension == "dll" , tuple (map (int , numbers )))
2447
-
2448
- patched_lib_ldflags = []
2449
- for lib in libs :
2450
- ldflag = f"-l{ lib } "
2451
- for lib_dir in lib_dirs :
2452
- lib_dir = lib_dir .strip ('"' )
2453
- windows_styled_libs = [
2454
- fname
2455
- for fname in os .listdir (lib_dir )
2456
- if not (os .path .isdir (os .path .join (lib_dir , fname )))
2457
- and fname .split ("." )[0 ] == lib
2458
- and fname .split ("." )[- 1 ] in ["dll" , "lib" ]
2459
- ]
2460
- if windows_styled_libs :
2461
- selected_lib = sorted (windows_styled_libs , key = sort_key )[- 1 ]
2462
- ldflag = f'"{ os .path .join (lib_dir , selected_lib )} "'
2463
- patched_lib_ldflags .append (ldflag )
2464
- return patched_lib_ldflags
2443
+ else :
2444
+ # In explicit else because of https://github.com/python/mypy/issues/10773
2445
+ def sort_key (lib ):
2446
+ name , * numbers , extension = lib .split ("." )
2447
+ return (extension == "dll" , tuple (map (int , numbers )))
2448
+
2449
+ patched_lib_ldflags = []
2450
+ for lib in libs :
2451
+ ldflag = f"-l{ lib } "
2452
+ for lib_dir in lib_dirs :
2453
+ lib_dir = lib_dir .strip ('"' )
2454
+ windows_styled_libs = [
2455
+ fname
2456
+ for fname in os .listdir (lib_dir )
2457
+ if not (os .path .isdir (os .path .join (lib_dir , fname )))
2458
+ and fname .split ("." )[0 ] == lib
2459
+ and fname .split ("." )[- 1 ] in ["dll" , "lib" ]
2460
+ ]
2461
+ if windows_styled_libs :
2462
+ selected_lib = sorted (windows_styled_libs , key = sort_key )[- 1 ]
2463
+ ldflag = f'"{ os .path .join (lib_dir , selected_lib )} "'
2464
+ patched_lib_ldflags .append (ldflag )
2465
+ return patched_lib_ldflags
2465
2466
2466
2467
@staticmethod
2467
2468
def compile_str (
0 commit comments