Skip to content

Commit d637359

Browse files
committed
fix
1 parent 63664d0 commit d637359

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/auditwheel/repair.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from os.path import isabs
1313
from pathlib import Path
1414
from subprocess import check_call
15+
from threading import Lock
1516

1617
from auditwheel.patcher import ElfPatcher
1718

@@ -87,13 +88,17 @@ def repair_wheel(
8788
raise ValueError(msg)
8889

8990
new_soname, new_path = copylib(src_path, dest_dir, patcher, dry=True)
90-
if not new_path.exists() and str(new_path) not in copy_works:
91-
copy_works[str(new_path)] = pool.submit(
91+
if (new_path_key := str(new_path)) not in copy_works:
92+
copy_works[new_path_key] = pool.submit(
9293
copylib, src_path, dest_dir, patcher
9394
)
95+
else:
96+
if copy_works[new_path_key].running() or copy_works[new_path_key].done():
97+
assert new_path.exists()
9498
soname_map[soname] = (new_soname, new_path)
9599
replacements.append((soname, new_soname))
96100

101+
# Replace rpath do not need copy to be done
97102
def _inner_replace():
98103
if replacements:
99104
patcher.replace_needed(fn, *replacements)
@@ -113,7 +118,9 @@ def _inner_replace():
113118
# they may have internal dependencies (DT_NEEDED) on one another, so
114119
# we need to update those records so each now knows about the new
115120
# name of the other.
116-
as_completed(copy_works.values())
121+
assert all(f.exception() is None for f in as_completed(itertools.chain(
122+
copy_works.values(), replace_works.values()
123+
)))
117124
for _, path in soname_map.values():
118125
needed = elf_read_dt_needed(path)
119126
replacements = []
@@ -128,10 +135,10 @@ def _inner_replace():
128135

129136
if strip:
130137
for lib, future in itertools.chain(
131-
copy_works.items(), replace_works.items()
138+
[path for (_, path) in soname_map.values()], external_refs_by_fn.keys()
132139
):
133140
logger.info("Stripping symbols from %s", lib)
134-
then(future, check_call, ["strip", "-s", lib])
141+
pool.submit(check_call, ["strip", "-s", lib])
135142

136143
pool.shutdown()
137144

@@ -172,7 +179,7 @@ def copylib(
172179
if dry or dest_path.exists():
173180
return new_soname, dest_path
174181

175-
logger.debug("Grafting: %s -> %s", src_path, dest_path)
182+
logger.debug("Start grafting: %s -> %s", src_path, dest_path)
176183
rpaths = elf_read_rpaths(src_path)
177184
shutil.copy2(src_path, dest_path)
178185
statinfo = dest_path.stat()
@@ -184,6 +191,8 @@ def copylib(
184191
if any(itertools.chain(rpaths["rpaths"], rpaths["runpaths"])):
185192
patcher.set_rpath(dest_path, "$ORIGIN")
186193

194+
logger.debug("Done grafting to: %s", src_path)
195+
187196
return new_soname, dest_path
188197

189198

0 commit comments

Comments
 (0)