Skip to content

Commit 8f994bb

Browse files
committed
lint
1 parent d637359 commit 8f994bb

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN --mount=type=cache,target=/home/vscode/.cache/pip \
55
apt-get update; \
66
apt-get install -y moreutils; \
77
pip wheel --no-deps torch; \
8-
pip install patchelf ipdb torch-*.whl; \
8+
pip install patchelf pre-commit ipdb torch-*.whl; \
99
mkdir -p /usr/local/lib/nv; \
1010
ln -s /usr/local/lib/python3.12/site-packages/nvidia/*/lib/*.so* /usr/local/lib/nv/; \
1111
echo "/usr/local/lib/nv" > /etc/ld.so.conf.d/nv.conf; \

src/auditwheel/repair.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import re
88
import shutil
99
import stat
10+
import typing as t
1011
from concurrent.futures import Future, ThreadPoolExecutor, as_completed
1112
from fnmatch import fnmatch
1213
from os.path import isabs
1314
from pathlib import Path
1415
from subprocess import check_call
15-
from threading import Lock
1616

1717
from auditwheel.patcher import ElfPatcher
1818

@@ -69,8 +69,8 @@ def repair_wheel(
6969
dest_dir.mkdir()
7070

7171
pool = ThreadPoolExecutor()
72-
copy_works: dict[str, Future] = {}
73-
replace_works: dict[str, Future] = {}
72+
copy_works: dict[Path, Future[t.Any]] = {}
73+
replace_works: dict[Path, Future[t.Any]] = {}
7474

7575
# here, fn is a path to an ELF file (lib or executable) in
7676
# the wheel, and v['libs'] contains its required libs
@@ -88,22 +88,24 @@ def repair_wheel(
8888
raise ValueError(msg)
8989

9090
new_soname, new_path = copylib(src_path, dest_dir, patcher, dry=True)
91-
if (new_path_key := str(new_path)) not in copy_works:
92-
copy_works[new_path_key] = pool.submit(
91+
if new_path not in copy_works:
92+
copy_works[new_path] = pool.submit(
9393
copylib, src_path, dest_dir, patcher
9494
)
9595
else:
96-
if copy_works[new_path_key].running() or copy_works[new_path_key].done():
96+
if copy_works[new_path].running() or copy_works[new_path].done():
9797
assert new_path.exists()
9898
soname_map[soname] = (new_soname, new_path)
9999
replacements.append((soname, new_soname))
100100

101101
# Replace rpath do not need copy to be done
102-
def _inner_replace():
102+
def _inner_replace(
103+
fn: Path, replacements: list[tuple[str, str]], append_rpath: bool
104+
) -> None:
103105
if replacements:
104106
patcher.replace_needed(fn, *replacements)
105107

106-
if len(ext_libs) > 0:
108+
if append_rpath:
107109
new_fn = fn
108110
if _path_is_script(fn):
109111
new_fn = _replace_elf_script_with_shim(match.group("name"), fn)
@@ -112,15 +114,20 @@ def _inner_replace():
112114
new_rpath = os.path.join("$ORIGIN", new_rpath)
113115
append_rpath_within_wheel(new_fn, new_rpath, ctx.name, patcher)
114116

115-
replace_works[fn] = pool.submit(_inner_replace)
117+
replace_works[fn] = pool.submit(
118+
_inner_replace, fn, replacements, len(ext_libs) > 0
119+
)
116120

117121
# we grafted in a bunch of libraries and modified their sonames, but
118122
# they may have internal dependencies (DT_NEEDED) on one another, so
119123
# we need to update those records so each now knows about the new
120124
# name of the other.
121-
assert all(f.exception() is None for f in as_completed(itertools.chain(
122-
copy_works.values(), replace_works.values()
123-
)))
125+
assert all(
126+
f.exception() is None
127+
for f in as_completed(
128+
itertools.chain(copy_works.values(), replace_works.values())
129+
)
130+
)
124131
for _, path in soname_map.values():
125132
needed = elf_read_dt_needed(path)
126133
replacements = []
@@ -134,7 +141,7 @@ def _inner_replace():
134141
ctx.out_wheel = add_platforms(ctx, abis, get_replace_platforms(abis[0]))
135142

136143
if strip:
137-
for lib, future in itertools.chain(
144+
for lib in itertools.chain(
138145
[path for (_, path) in soname_map.values()], external_refs_by_fn.keys()
139146
):
140147
logger.info("Stripping symbols from %s", lib)
@@ -145,11 +152,6 @@ def _inner_replace():
145152
return ctx.out_wheel
146153

147154

148-
def then(pool: ThreadPoolExecutor, future: Future, *args, **kwargs):
149-
future.result()
150-
pool.submit(*args, **kwargs)
151-
152-
153155
def copylib(
154156
src_path: Path, dest_dir: Path, patcher: ElfPatcher, dry: bool = False
155157
) -> tuple[str, Path]:

0 commit comments

Comments
 (0)