Skip to content

lddtree: support alternative LD_LIBRARY_PATH called AUDITWHEEL_LD_LIBRARY_PATH #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ def load_ld_paths(
ldpaths: dict[str, list[str]] = {"conf": [], "env": [], "interp": []}

# Load up $LD_LIBRARY_PATH.
env_ldpath = os.environ.get("LD_LIBRARY_PATH")
env_ldpath = os.environ.get(
"AUDITWHEEL_LD_LIBRARY_PATH", default=os.environ.get("LD_LIBRARY_PATH")
)
if env_ldpath is not None:
if root != "/":
log.warning("ignoring LD_LIBRARY_PATH due to ROOT usage")
Expand Down
55 changes: 55 additions & 0 deletions tests/integration/test_bundled_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,61 @@ def test_analyze_wheel_abi(file, external_libs, exclude):
importlib.reload(lddtree)


@pytest.mark.parametrize(
("file", "external_libs", "exclude"),
[
("cffi-1.5.0-cp27-none-linux_x86_64.whl", {"libffi.so.5"}, frozenset()),
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.5"])),
(
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
{"libffi.so.5"},
frozenset(["libffi.so.noexist", "libnoexist.so.*"]),
),
(
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
set(),
frozenset(["libffi.so.[4,5]"]),
),
(
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
{"libffi.so.5"},
frozenset(["libffi.so.[6,7]"]),
),
(
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
set(),
frozenset([f"{HERE}/*"]),
),
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["libffi.so.*"])),
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"])),
(
"python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl",
{"libsnappy.so.1"},
frozenset(),
),
],
)
def test_analyze_wheel_abi_awllp(file, external_libs, exclude):
# Test that AUDITWHEEL_LD_LIBRARY_PATH takes precedence
modify_ld_library_path = any(isabs(e) for e in exclude)

with pytest.MonkeyPatch.context() as cp:
if modify_ld_library_path:
cp.setenv("LD_LIBRARY_PATH", "NOTHERE")
cp.setenv("AUDITWHEEL_LD_LIBRARY_PATH", f"{HERE}")
importlib.reload(lddtree)

winfo = analyze_wheel_abi(
Libc.GLIBC, Architecture.x86_64, HERE / file, exclude, False, True
)
assert set(winfo.external_refs["manylinux_2_5_x86_64"].libs) == external_libs, (
f"{HERE}, {exclude}, {os.environ}"
)

if modify_ld_library_path:
importlib.reload(lddtree)


def test_analyze_wheel_abi_pyfpe():
winfo = analyze_wheel_abi(
Libc.GLIBC,
Expand Down