Skip to content

Commit 0cfd268

Browse files
committed
1/2 repair_wheel
1 parent 70dddf0 commit 0cfd268

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/auditwheel/pool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ def wait(self, path: Optional[Path] = None) -> None:
6262
elif path in self.working_map:
6363
self.working_map.pop(path).result()
6464

65+
def __contains__(self, fn: Path) -> bool:
66+
return self.executor is not None and fn in self.working_map
67+
6568

6669
POOL = FileTaskExecutor(2)

src/auditwheel/repair.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from subprocess import check_call
1515

1616
from auditwheel.patcher import ElfPatcher
17+
from auditwheel.pool import POOL
1718

1819
from .elfutils import elf_read_dt_needed, elf_read_rpaths, is_subdir
1920
from .hashfile import hashfile
@@ -82,9 +83,14 @@ def repair_wheel(
8283

8384
if not dest_dir.exists():
8485
dest_dir.mkdir()
85-
new_soname, new_path = copylib(src_path, dest_dir, patcher)
86+
new_soname, new_path = copylib(src_path, dest_dir, patcher, dry=True)
87+
if new_path not in POOL:
88+
POOL.submit(new_path, copylib, src_path, dest_dir, patcher)
8689
soname_map[soname] = (new_soname, new_path)
8790
replacements.append((soname, new_soname))
91+
92+
POOL.wait()
93+
8894
if replacements:
8995
patcher.replace_needed(fn, *replacements)
9096

@@ -127,7 +133,9 @@ def strip_symbols(libraries: Iterable[Path]) -> None:
127133
check_call(["strip", "-s", lib])
128134

129135

130-
def copylib(src_path: Path, dest_dir: Path, patcher: ElfPatcher) -> tuple[str, Path]:
136+
def copylib(
137+
src_path: Path, dest_dir: Path, patcher: ElfPatcher, dry: bool = False
138+
) -> tuple[str, Path]:
131139
"""Graft a shared library from the system into the wheel and update the
132140
relevant links.
133141
@@ -151,7 +159,7 @@ def copylib(src_path: Path, dest_dir: Path, patcher: ElfPatcher) -> tuple[str, P
151159
new_soname = src_name
152160

153161
dest_path = dest_dir / new_soname
154-
if dest_path.exists():
162+
if dry or dest_path.exists():
155163
return new_soname, dest_path
156164

157165
logger.debug("Grafting: %s -> %s", src_path, dest_path)

0 commit comments

Comments
 (0)