From ae0aae5cff4aca8538a1800a46224ab31d9fca4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Lain=C3=A9?= Date: Wed, 23 Feb 2022 13:01:10 +0100 Subject: [PATCH] feature: allow specifying additional library paths (fixes: #373) Add new --add-path option to auditwheel repair to search for libraries in additional directories. This avoid having to manipulate LD_LIBRARY_PATH in the calling process (e.g. cibuildwheel), as this can have undesirable side-effects. The name of the option is chosen to match the one provided by `delvewheel` on Windows. --- src/auditwheel/main_repair.py | 13 +++++++++++++ tests/integration/test_bundled_wheels.py | 1 + 2 files changed, 14 insertions(+) diff --git a/src/auditwheel/main_repair.py b/src/auditwheel/main_repair.py index c4fafa79..48906445 100644 --- a/src/auditwheel/main_repair.py +++ b/src/auditwheel/main_repair.py @@ -1,5 +1,6 @@ import argparse import logging +import os from os.path import abspath, basename, exists, isfile from auditwheel.patcher import Patchelf @@ -92,6 +93,12 @@ def configure_parser(sub_parsers): help="Do not check for higher policy compatibility", default=False, ) + p.add_argument( + "--add-path", + dest="PATHS", + default="", + help=f"Additional path(s) to search for libraries, {os.pathsep!r}-delimited", + ) p.set_defaults(func=execute) @@ -106,6 +113,12 @@ def execute(args, p): logger.info("Repairing %s", basename(args.WHEEL_FILE)) + if args.PATHS: + library_path = args.PATHS + if "LD_LIBRARY_PATH" in os.environ: + library_path += os.pathsep + os.environ["LD_LIBRARY_PATH"] + os.environ["LD_LIBRARY_PATH"] = library_path + if not exists(args.WHEEL_DIR): os.makedirs(args.WHEEL_DIR) diff --git a/tests/integration/test_bundled_wheels.py b/tests/integration/test_bundled_wheels.py index fa51f637..400a2012 100644 --- a/tests/integration/test_bundled_wheels.py +++ b/tests/integration/test_bundled_wheels.py @@ -62,6 +62,7 @@ def test_wheel_source_date_epoch(tmp_path, monkeypatch): args = Namespace( LIB_SDIR=".libs", ONLY_PLAT=False, + PATHS="", PLAT="manylinux_2_5_x86_64", STRIP=False, UPDATE_TAGS=True,