Skip to content

Commit

Permalink
feature: allow specifying additional library paths (fixes: #373)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jlaine committed Feb 23, 2022
1 parent f3c7691 commit f560107
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/auditwheel/main_repair.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import logging
import os
from os.path import abspath, basename, exists, isfile

from auditwheel.patcher import Patchelf
Expand Down Expand Up @@ -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)


Expand All @@ -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)

Expand Down

0 comments on commit f560107

Please sign in to comment.