From 4c46ece2988667ef8d868e50f315375cacea8e84 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Mon, 2 Jun 2025 15:02:45 -0700 Subject: [PATCH] pack_wheel: Work on OS X with SIP The old DYLD_LIBRARY_PATH tricks don't work any more (at least, not while System Integrity Protection is on). Even just getting that into os.environ seems difficult on recent OS X! % DYLD_LIBRARY_PATH=$HOME/local/lib python -c \ 'import os; print(os.environ.get("DYLD_LIBRARY_PATH"))' None LDFLAGS still get passed around OK, though, so go looking for extra library search paths in them. Presumably there's something like -L$HOME/local/lib in there if the developer needs it. Signed-off-by: Tim Burke Change-Id: I85f7a1b4308e01858bff5fccda1f5a4b54957da8 --- pack_wheel.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pack_wheel.py b/pack_wheel.py index b8e2273..04501e1 100644 --- a/pack_wheel.py +++ b/pack_wheel.py @@ -72,6 +72,16 @@ def locate_library(name, missing_ok=False): if libpath: for d in libpath.split(':'): cmd.extend(['-L', d.rstrip('/')]) + should_read_path = False + for flg in os.environ.get('LDFLAGS', '').split(' '): + if should_read_path: + cmd.append(flg) + should_read_path = False + elif flg == '-L': + cmd.append(flg) + should_read_path = True + elif flg.startswith('-L'): + cmd.append(flg) cmd.extend(['-o', os.devnull, '-l%s' % name]) p = subprocess.run(cmd, capture_output=True, text=True) # Note that we don't expect the command to exit cleanly; we just want