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

Tobias.Richter at diamond.ac.uk Tobias.Richter at diamond.ac.uk
Thu Apr 11 19:17:12 BST 2013


Thanks Rolf,

The patch looks good. I've committed it ( http://trac.nexusformat.org/code/changeset/1893 ) and we'll give it a test.

Thanks for that contribution!

Tobias

________________________________________
From: nexus-bounces at nexusformat.org [nexus-bounces at nexusformat.org] on behalf of Rolf Krahl [rolf.krahl at helmholtz-berlin.de]
Sent: 11 April 2013 18:34
To: nexus at nexusformat.org
Subject: [Nexus] Bug in python bindings: napi.py does not find libNeXus.so.0    on x86_64 systems

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

-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 






More information about the NeXus mailing list