matthew-brett / delocate

Find and copy needed dynamic libraries into python wheels
BSD 2-Clause "Simplified" License
267 stars 59 forks source link

DYLD_LIBRARY_PATH not searched for libraries #222

Open peastman opened 4 months ago

peastman commented 4 months ago

Describe the bug I'm setting DYLD_LIBRARY_PATH to tell delocate where to find my libraries, but it still fails to find them:

$ export DYLD_LIBRARY_PATH=/usr/local/openmm/lib
(openmm) CHM-Q05002H061:build peastman$ delocate-listdeps python/dist/OpenMM-8.1.0-cp39-cp39-macosx_11_0_arm64.whl
ERROR:delocate.libsana:
@rpath/libOpenMM.dylib not found:
  Needed by: /usr/local/openmm/lib/libOpenMMAmoeba.dylib
  Search path:

On the other hand, if I invoke it as a python module then it does work:

$ python -m delocate.cmd.delocate_listdeps python/dist/OpenMM-8.1.0-cp39-cp39-macosx_11_0_arm64.whl 
/Users/peastman/miniconda3/envs/openmm/lib/libc++.1.0.dylib
/usr/local/openmm/lib/libOpenMM.dylib
/usr/local/openmm/lib/libOpenMMAmoeba.dylib
/usr/local/openmm/lib/libOpenMMDrude.dylib
/usr/local/openmm/lib/libOpenMMRPMD.dylib

I tried modifying delocate_listdeps.main() to add the line

print(os.environ.get('DYLD_LIBRARY_PATH'))

at the very start. This confirms that the environment variable is seen when I run it with python -m, but not when I use the delocate-listdeps command line tool. Something in there is blocking the environment variables.

Platform (please complete the following information):

isuruf commented 4 months ago

See https://briandfoy.github.io/macos-s-system-integrity-protection-sanitizes-your-environment

HexDecimal commented 4 months ago

Should Delocate add an alternative syntax for handing DYLD_LIBRARY_PATH? Such as an --extra-library-path <dir> argument?

peastman commented 4 months ago

That would be really useful. In the mean time, it's no problem to use python -m. Maybe document it so people know about the issue?

qartik commented 1 month ago

Should Delocate add an alternative syntax for handing DYLD_LIBRARY_PATH? Such as an --extra-library-path <dir> argument?

This could be quite helpful in general as macOS SIP can be quite confusing.