@@ -63,15 +63,16 @@ def repair_wheel(
63
63
dest_dir = match .group ("name" ) + lib_sdir
64
64
65
65
if not exists (dest_dir ):
66
+ keep_dest_dir = False
66
67
os .mkdir (dest_dir )
68
+ else :
69
+ keep_dest_dir = True
67
70
68
71
# here, fn is a path to a python extension library in
69
72
# the wheel, and v['libs'] contains its required libs
70
73
for fn , v in external_refs_by_fn .items ():
71
74
ext_libs = v [abis [0 ]]["libs" ] # type: Dict[str, str]
72
75
replacements = [] # type: List[Tuple[str, str]]
73
- src_path_to_real_sonames = {} # type: Dict[str, str]
74
- same_soname_libs = defaultdict (set ) # type: Dict[str, Set[str]]
75
76
for soname , src_path in ext_libs .items ():
76
77
if src_path is None :
77
78
raise ValueError (
@@ -81,23 +82,11 @@ def repair_wheel(
81
82
)
82
83
% soname
83
84
)
84
- real_soname = patcher .get_soname (src_path )
85
- src_path_to_real_sonames [soname ] = real_soname
86
- same_soname_libs [real_soname ].add (soname )
87
-
88
- if not copy_site_libs :
89
- for soname , src_path in ext_libs .items ():
90
- if "site-packages" in str (src_path ).split (os .path .sep ):
91
- try :
92
- del same_soname_libs [src_path_to_real_sonames [soname ]]
93
- except KeyError :
94
- pass
95
-
96
- for real_soname , sonames in same_soname_libs .items ():
97
- if len (sonames ) == 0 :
85
+
86
+ if not copy_site_libs and "site-packages" in str (src_path ).split (
87
+ os .path .sep
88
+ ):
98
89
continue
99
- soname = sonames .pop () # only keep one .so file (remove duplicates)
100
- src_path = ext_libs [soname ]
101
90
102
91
new_soname , new_path = copylib (src_path , dest_dir , patcher )
103
92
soname_map [soname ] = (new_soname , new_path )
@@ -142,7 +131,7 @@ def repair_wheel(
142
131
libs_to_strip = [path for (_ , path ) in soname_map .values ()]
143
132
extensions = external_refs_by_fn .keys ()
144
133
strip_symbols (itertools .chain (libs_to_strip , extensions ))
145
- else :
134
+ elif not keep_dest_dir :
146
135
shutil .rmtree (dest_dir , ignore_errors = True ) # move unnecessary directory
147
136
148
137
return ctx .out_wheel
0 commit comments