Load dynamic library for python library

Casey Deccio casey at deccio.net
Thu Feb 7 15:00:50 UTC 2019


Hi,

I've installed a python package (py27-libnacl) that loads a dynamic library (libsodium), but I can't access that library unless I explicitly set LD_LIBRARY_PATH:

$ python -m libnacl
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
    mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 111, in _get_module_details
    __import__(mod_name)  # Do not catch exceptions initializing package
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/libnacl/__init__.py", line 75, in <module>
    nacl = _get_nacl()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/libnacl/__init__.py", line 48, in _get_nacl
    raise OSError(msg)
OSError: Could not locate nacl lib, searched for libsodium, tweetnacl

But this one works (the error that follows doesn't matter, in this case since the import works):
$ LD_LIBRARY_PATH=/opt/local/lib python -m libnacl
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named libnacl.__main__; 'libnacl' is a package and cannot be directly executed

Here is some additional information:

$ port installed | grep libnacl
  py27-libnacl @1.4.0_0 (active)
$ port installed | grep libsodium
  libsodium @1.0.17_0 (active)
$ port select --list python
Available versions for python:
	none
	python27 (active)
	python27-apple
	python34
	python35
	python36
$ which python
/opt/local/bin/python
$ port version
Version: 2.5.4

The reason I'm asking on the dev list is because I'm updating a port which relies on py27-libnacl and libsodium, and I'm trying to figure out the right way to get it to work, e.g., if any special configuration is needed.  I would have thought that it should "just work", but since it doesn't, I'm seeking some guidance as to how I should update that port appropriately.

Thanks!
Casey


More information about the macports-dev mailing list