55import re
66import shutil
77import stat
8- from collections import OrderedDict , defaultdict
8+ from collections import OrderedDict
99from os .path import abspath , basename , dirname , exists , isabs
1010from os .path import join as pjoin
1111from subprocess import check_call
12- from typing import Dict , Iterable , List , Optional , Set , Tuple
12+ from typing import Dict , Iterable , List , Optional , Tuple
1313
1414from auditwheel .patcher import ElfPatcher
1515
@@ -73,8 +73,7 @@ def repair_wheel(
7373 for fn , v in external_refs_by_fn .items ():
7474 ext_libs = v [abis [0 ]]["libs" ] # type: Dict[str, str]
7575 replacements = [] # type: List[Tuple[str, str]]
76- src_path_real_soname_map = {} # type: Dict[str, str]
77- same_soname_libs = defaultdict (set ) # type: Dict[str, Set[str]]
76+ copied_ext_libs = {} # type: Dict[str, str]
7877 for soname , src_path in ext_libs .items ():
7978 if src_path is None :
8079 raise ValueError (
@@ -85,21 +84,14 @@ def repair_wheel(
8584 % soname
8685 )
8786
88- real_soname = patcher .get_soname (src_path )
89- src_path_real_soname_map [real_soname ] = src_path
90- same_soname_libs [real_soname ].add (soname )
91-
92- if not copy_site_libs :
93- for soname , src_path in ext_libs .items ():
94- if "site-packages" in str (src_path ).split (os .path .sep ):
95- same_soname_libs .pop (src_path_real_soname_map [src_path ], None )
96-
97- for real_soname , sonames in same_soname_libs .items ():
98- if len (sonames ) == 0 :
87+ if not copy_site_libs and "site-packages" in str (src_path ).split (
88+ os .path .sep
89+ ):
9990 continue
100- soname = sonames .pop () # only keep one .so file (remove duplicates)
101- src_path = ext_libs [soname ]
10291
92+ copied_ext_libs [soname ] = src_path
93+
94+ for soname , src_path in copied_ext_libs .items ():
10395 new_soname , new_path = copylib (src_path , dest_dir , patcher )
10496 soname_map [soname ] = (new_soname , new_path )
10597 replacements .append ((soname , new_soname ))
0 commit comments