sys-bio / sbml2matlab

An SBML to MATLAB Converter
Other
1 stars 0 forks source link

sbml2matlab python bindings on linux not working #1

Open kirichoi opened 8 years ago

kirichoi commented 8 years ago

via @matthiaskoenig in sys-bio/tellurium#71:

Hi all, sorry for being of topic, but somehow sbml2matlab https://github.com/sys-bio/sbml2matlab has no issue tracker where I could post issues. Please open an issue tracker there.

[1] Link in description of the project is broken -> An SBML to MATLAB Converter http://stanley-gu.github.com/sbml2matlab/

[2] The python bindings are broken in linux, i.e. they are registered under a wrong name and not linked properly. The installed files are:

Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/local/./sbml2matlab
-- Removed runtime path from "/usr/local/./sbml2matlab"
-- Installing: /usr/local/./liblibsbml2matlab.so
-- Removed runtime path from "/usr/local/./liblibsbml2matlab.so"
-- Installing: /usr/local/./README.markdown
-- Installing: /usr/local/./LICENSE.txt
-- Installing: /usr/local/./help/help.zip
-- Installing: /usr/local/./libNOM.so
-- Installing: /usr/local/lib/python2.7/site-packages/sbml2matlab/libNOM.so
-- Installing: /usr/local/lib/python2.7/site-packages/sbml2matlab/_libsbml2matlab.so
-- Removed runtime path from "/usr/local/lib/python2.7/site-packages/sbml2matlab/_libsbml2matlab.so"
-- Installing: /usr/local/lib/python2.7/site-packages/libsbml2matlab.pth
-- Installing: /usr/local/lib/python2.7/site-packages/sbml2matlab/libsbml2matlab.py

The naming is libsbml2matlab and sbml2matlab mixed, which breaks on linux.

Trying to import in python results than in

import libsbml2matlab
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-fae0f8675722> in <module>()
----> 1 import libsbml2matlab

/usr/local/lib/python2.7/site-packages/sbml2matlab/libsbml2matlab.py in <module>()
     26                 fp.close()
     27             return _mod
---> 28     _libsbml2matlab = swig_import_helper()
     29     del swig_import_helper
     30 else:

/usr/local/lib/python2.7/site-packages/sbml2matlab/libsbml2matlab.py in swig_import_helper()
     22         if fp is not None:
     23             try:
---> 24                 _mod = imp.load_module('_libsbml2matlab', fp, pathname, description)
     25             finally:
     26                 fp.close()

ImportError: liblibsbml2matlab.so: cannot open shared object file: No such file or directory

This is identical to the python binding issue for antimony that @luciansmith fixed. It would help a lot if this could also be fixed in sbml2matlab. Currently, the python bindings to sbml2matlab cannot be used under linux.

0u812 commented 8 years ago

I don't know about the Antimony issue but I can now use the python bindings via either PYTHONPATH or setup.py install, so I'm marking this solved.

matthiaskoenig commented 8 years ago

The issue is almost fixed. Some smaller troubles remain: [1] The library is installed under the wrong name: libsbml2matlab instead of sbml2matlab. See below and log attached. Consequently, I cannot do ìmport sbml2matlab

[ 37%] Built target libsbml2matlab
[ 50%] Built target libsbml2matlab-static
...
-- Installing: /usr/local/lib/python2.7/site-packages/sbml2matlab/_libsbml2matlab.so
-- Installing: /usr/local/lib/python2.7/site-packages/libsbml2matlab.pth

sbml2matlab.txt

[2] The package should be installed via pip (analoque to antimony and phrasedml). I.e. not a pip package, but the python bindings have to be installed via pip. This resolves the issues with having to set PYTHONPATH variables manually.

The package itselfs seems to work, i.e. could translate simple sbml to matlab after importing the libsbml2matlab package.

0u812 commented 8 years ago

I renamed all the instances of libsbml2matlab to sbml2matlab, installed in a clean virtual environment (via python setup.py install), and made sure I could run sbml2matlab as follows:

import sbml2matlab

with open('path/to/sbml.xml') as f:
  sbmlstr = f.read()

sbml2matlab.sbml2matlab(sbmlstr)

The above code works and produces the Matlab output, so I think the issue with the module name is fixed. Please let me know if you still run into trouble with this.

matthiaskoenig commented 8 years ago

Perfect. Working now.

One last remark. If one doesn't set the CMAKE_INSTALL_PREFIX the default is set to /usr/local which results in files being written in very general locations. For instance you write README.txt in /usr/local. All files should be written in a sbml2matlab folder.

The following should be written in /usr/local/lib/python2.7/site-packages/sbml2matlab

-- Up-to-date: /usr/local/./README.txt
-- Up-to-date: /usr/local/./LICENSE.txt
-- Up-to-date: /usr/local/./NOTICE.txt
-- Up-to-date: /usr/local/./help/help.zip

Also the following files are written directly in /usr/local/lib/python2.7/site-packages/ instead of a sbml2matlab folder

-- Installing: /usr/local/lib/python2.7/site-packages/setup.py
-- Up-to-date: /usr/local/lib/python2.7/site-packages/MANIFEST.in
-- Installing: /usr/local/lib/python2.7/site-packages/meta.yaml
-- Installing: /usr/local/lib/python2.7/site-packages/build.sh
-- Installing: /usr/local/lib/python2.7/site-packages/bld.bat
0u812 commented 8 years ago

It is clobbering the installation directory a little too much. Let's get some input from other team members to standardize where to put the installation files across our various projects. @hsauro, @luciansmith, @kirichoi can we take a look at our options and pick one?

So, I think that setup.py should go somewhere in the installation directory. Roadrunner puts it in the root of the installation directory, and I'm okay with that, but let's get everyone's input. This does imply that setup.py will get written to /usr/local/setup.py by default.

Whatever we do, we should try to stick to it across all our projects so our users know how to run setup.py for any package.