Skip to content

Commit fd2fede

Browse files
committed
chore: do not remove duplicate libraries
1 parent aeed150 commit fd2fede

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/auditwheel/repair.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ def repair_wheel(
6363
dest_dir = match.group("name") + lib_sdir
6464

6565
if not exists(dest_dir):
66+
keep_dest_dir = False
6667
os.mkdir(dest_dir)
68+
else:
69+
keep_dest_dir = True
6770

6871
# here, fn is a path to a python extension library in
6972
# the wheel, and v['libs'] contains its required libs
7073
for fn, v in external_refs_by_fn.items():
7174
ext_libs = v[abis[0]]["libs"] # type: Dict[str, str]
7275
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]]
7576
for soname, src_path in ext_libs.items():
7677
if src_path is None:
7778
raise ValueError(
@@ -81,23 +82,11 @@ def repair_wheel(
8182
)
8283
% soname
8384
)
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+
):
9889
continue
99-
soname = sonames.pop() # only keep one .so file (remove duplicates)
100-
src_path = ext_libs[soname]
10190

10291
new_soname, new_path = copylib(src_path, dest_dir, patcher)
10392
soname_map[soname] = (new_soname, new_path)
@@ -142,7 +131,7 @@ def repair_wheel(
142131
libs_to_strip = [path for (_, path) in soname_map.values()]
143132
extensions = external_refs_by_fn.keys()
144133
strip_symbols(itertools.chain(libs_to_strip, extensions))
145-
else:
134+
elif not keep_dest_dir:
146135
shutil.rmtree(dest_dir, ignore_errors=True) # move unnecessary directory
147136

148137
return ctx.out_wheel

0 commit comments

Comments
 (0)