leonardt / pycoreir

Python bindings for coreir
BSD 3-Clause "New" or "Revised" License
10 stars 6 forks source link

Explicitly load coreir libraries relative to binary path #123

Closed rswarbrick closed 4 years ago

rswarbrick commented 4 years ago

Suppose you installed coreir to somewhere non-standard (/opt/coreir, for example) and added the relevant bin directory (/opt/coreir/bin) to your PATH.

Then the existing code would set COREIR_BINARY_PATH to /opt/coreir/bin/coreir (good!) and then just try to load 'libcoreir.so' or similar. It should load /opt/coreir/lib/libcoreir.so.

This isn't quite as useful as you might hope, because of coreir issue number #851[1], but it gets most of the way (as a work-around for the coreir bug, it suffices to leave the coreir build directory uncleaned!).

[1] https://github.com/rdaly525/coreir/issues/851

rswarbrick commented 4 years ago

Yes, I did think about whether we could support something more flexible. For full generality, I guess you could imagine running ldd on the binary and looking at which library it picked up. Since cmake should have set up DT_RUNPATH, this should give you the right result but... ugh, that sounded hard, so I went for the stupid version :-)