[Nexus] Bug in python bindings: napi.py does not find libNeXus.so.0 on x86_64 systems

Rolf Krahl rolf.krahl at helmholtz-berlin.de
Thu Apr 11 18:34:58 BST 2013


Dear all,

I just installed NeXus 4.3.0 on a Linux x86_64 system and I believe
that I found a bug in the Python bindings.


Symptom
-------

Even trivial Python programs using the NeXus API fail with an error
message that libNeXus.so.0 cannot be found:

$  python -c "import nxs"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/nxs/__init__.py", line 20, in <module>
    from nxs.napi import *
  File "/usr/lib64/python2.7/site-packages/nxs/napi.py", line 268, in <module>
    nxlib = _init()
  File "/usr/lib64/python2.7/site-packages/nxs/napi.py", line 263, in _init
    lib = _libnexus()
  File "/usr/lib64/python2.7/site-packages/nxs/napi.py", line 260, in _libnexus
    raise OSError, "Set NEXUSLIB or move NeXus to one of: %s"%(", ".join(files))
OSError: Set NEXUSLIB or move NeXus to one of: /usr/lib64/python2.7/site-packages/nxs/libNeXus.so.0, /usr/lib/libNeXus.so.0, /usr/local/lib/libNeXus.so.0, /usr/lib/libNeXus.so.0


Analysis
--------

The NeXus API searches its lib in the following places in order:

 - os.environ['NEXUSLIB']
 - directory containing napi.py
 - os.environ['LD_LIBRARY_PATH']
 - PREFIX/lib
 - /usr/local/lib
 - /usr/lib

where PREFIX is set by configure during install, /usr in my case.  The
directory containing napi.py was /usr/lib64/python2.7/site-packages/nxs
here.  The environment variables NEXUSLIB and LD_LIBRARY_PATH have not
been set.  This boils the search patch down to
/usr/lib64/python2.7/site-packages/nxs, /usr/lib, /usr/local/lib,
/usr/lib.

But the lib has been installed as /usr/lib64/libNeXus.so.0 by make
install and that is exactly the place where it should be on a 64 bit
system.  So napi.py should have looked in /usr/lib64.


Suggested fix
-------------

Rather then in PREFIX/lib, /usr/local/lib, /usr/lib, napi.py should
look in LIBDIR as set by configure.  That is the directory where it
gets installed by make install.  See the attached patch.


Best regards,
Rolf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nexus-4.3.0-python-libdir.patch
Type: text/x-patch
Size: 3119 bytes
Desc: not available
URL: <http://lists.nexusformat.org/pipermail/nexus/attachments/20130411/1332166e/attachment.bin>


More information about the NeXus mailing list