Skip to content

Commit 496e92e

Browse files
committed
lddtree: support alternative LD_LIBRARY_PATH called AUDITWHEEL_LD_LIBRARY_PATH
Sometimes wheels are different only just by shared libraries that are vendored in. Sometimes the wheel being repaired and the libraries that need to be vendored in are accessible on the host that was not used for building the wheel. In such cases, it could be the case that shared libraries used by python that is executing the auditwheel script, are incompatible (too old or too new) than those that need to be vendored. In such cases, LD_LIBRARY_PATH is not convenient to use, as the python interpreter for the auditwheel script is crashing. Add an AUDITWHEEL_LD_LIBRARY_PATH whichis used by lddtree, but otherwise does not affect the python interpreter executing auditwheel script. This helps vendoring in older libraries from an alternative path, into a wheel built against an older python, whilst otherwise running auditwheel repair on a modern system with a much newer python. This is particularly useful when stripping a wheel of vendored libraries, and repair it again to update the shared library dependencies coming from an unpacked chroot. Separately it also helps creating alternative wheels with shared libraries rebuilt with higher march settings. Given that python upstream doesn't support loading optimised libraries as has been implemented and supported in Intel ClearLinux Python which allows one to have alternative march setting shared library deps.
1 parent e2063e3 commit 496e92e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/auditwheel/lddtree.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,17 @@ def load_ld_paths(
321321
"""
322322
ldpaths: dict[str, list[str]] = {"conf": [], "env": [], "interp": []}
323323

324-
# Load up $LD_LIBRARY_PATH.
325-
env_ldpath = os.environ.get("LD_LIBRARY_PATH")
324+
# Load up $AUDITWHEEL_LD_LIBRARY_PATH and $LD_LIBRARY_PATH
325+
env_ldpath = ":".join(
326+
filter(
327+
None,
328+
(
329+
os.environ.get("AUDITWHEEL_LD_LIBRARY_PATH"),
330+
os.environ.get("LD_LIBRARY_PATH"),
331+
),
332+
)
333+
)
334+
326335
if env_ldpath is not None:
327336
if root != "/":
328337
log.warning("ignoring LD_LIBRARY_PATH due to ROOT usage")

tests/integration/test_bundled_wheels.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
frozenset([f"{HERE}/*"]),
6161
"LD_LIBRARY_PATH",
6262
),
63+
(
64+
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
65+
{"libpython2.7.so.1.0"},
66+
frozenset([f"{HERE}/*"]),
67+
"AUDITWHEEL_LD_LIBRARY_PATH",
68+
),
6369
(
6470
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
6571
{"libffi.so.5", "libpython2.7.so.1.0"},

0 commit comments

Comments
 (0)