Opened 3 years ago

Closed 3 years ago

#7860 closed defect (fixed)

Add other bundles' lib dirs to rpaths

Reported by: Zach Pearson Owned by: Zach Pearson
Priority: high Milestone: 1.6
Component: Build System Version:
Keywords: Cc: Greg Couch, Eric Pettersen
Blocked By: Blocking: 7748
Notify when closed: Platform: all
Project: ChimeraX

Description

Trying to install mmcif into a virtual environment for readthedocs, I found that it couldn't find pdb_lib's headers. The root cause was that pdb_lib was unimportable without importing atomic_lib first.

>>> import chimerax.pdb_lib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/__init__.py", line 37, in <module>
    from . import _load_libs
ImportError: dlopen(/Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/_load_libs.cpython-39-darwin.so, 0x0002): Library not loaded: @rpath/libatomstruct.dylib
  Referenced from: <725333F6-9F69-30E0-B8AB-CE73F83D5E1A> /Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/_load_libs.cpython-39-darwin.so
  Reason: tried: '/Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/lib/libatomstruct.dylib' (no such file), '/Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/lib/libatomstruct.dylib' (no such file), '/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libatomstruct.dylib' (no such file), '/Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/lib/libatomstruct.dylib' (no such file), '/Users/zjp/git/rbvi/ChimeraX-zjp/.venv/lib/python3.9/site-packages/chimerax/pdb_lib/lib/libatomstruct.dylib' (no such file), '/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/libatomstruct.dylib' (no such file), '/usr/local/lib/libatomstruct.dylib' (no such file), '/usr/lib/libatomstruct.dylib' (no such file, not in dyld cache)

vs

Python 3.9.15 (main, Oct 11 2022, 21:39:54)
[Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import chimerax.atomic_lib
>>> import chimerax.pdb_lib

Since we have to at some point know where libatomstruct is to compile _load_libs, it should be trivial to add e.g. atomic_lib/lib to pdb_lib/_load_libs's rpaths. I did that exact thing for the pure setuptools ChimeraX experiment.

Change History (11)

comment:1 by Zach Pearson, 3 years ago

Owner: set to Zach Pearson
Status: newassigned

comment:2 by Zach Pearson, 3 years ago

Blocking: 7748

comment:3 by Greg Couch, 3 years ago

So that is the expected behavior. Not sure where rpath comes into play. Requiring that atomic_lib be imported first gets rid of the need for rpath.

comment:4 by Zach Pearson, 3 years ago

Should pdb_lib/init.py import atomic_lib? That would be the other possible workaround, besides adding ../atomic_lib/lib/, ../core/lib, etc. (depending on what required libraries there are) to bundle rpaths.

comment:5 by Greg Couch, 3 years ago

Cc: Eric Pettersen added

Your terminology is confusing. The only rpath should be in the ChimeraX/python executables that points to ../lib. Windows does not have the concept of rpath. On Windows, there are dlls in the application binary directory, which is searched for missing dlls in addition to system locations. That acts as the equivalent of setting a rpath on the application binary on Linux. So for Windows, you either need to put all of the dlls in the application binary directory, or you need to load them before they are referenced. We choose to do the latter on all platforms, both so the wheels aren't putting files all over the place, and to minimize our cross platform differences.

The workaround that has pdb_lib/init.py importing atomic_lib is the "right" workaround. But consult with Eric to see if that breaks anything.

comment:6 by Zach Pearson, 3 years ago

Aha, OK. Thanks for explaining that nuance to me with respect to *nix vs Windows loading.

comment:7 by Eric Pettersen, 3 years ago

Line 15 of pdb/init.py is: "import chimerax.atomic_lib. # noqa", so unless I'm misunderstanding something, that's not the problem.

Version 0, edited 3 years ago by Eric Pettersen (next)

comment:8 by Zach Pearson, 3 years ago

This is for pdb_lib.

comment:9 by Eric Pettersen, 3 years ago

Ah. I guess I'm okay with importing atomic_lib. I guess we'll see if anything blows up. :-)

comment:10 by Zach Pearson, 3 years ago

Thanks!

comment:11 by Zach Pearson, 3 years ago

Resolution: fixed
Status: assignedclosed

I was able to build that bundle after adding the import to pdb_lib. So far as I can see, my build and the daily builds work.

Note: See TracTickets for help on using tickets.