Ray,
thanks a lot for your documentation. The source code of the Cython interface looks great, and I read some convenient features that were missing in the python interface.
However, I did not manage to install the Cython interface. I tried it both on my Mac (10.8.2, MacPorts Python 2.7, Cython 0.16, Sundials 2.4.0, Cantera r2105) and on SuSe Linux (11.2, Python 2.6.2, Cython 0.18, Sundials 2.4.0, Cantera r2105). Here is what I got:
MACcantera.conf
prefix = '/Applications/calc/cantera'
python_package = 'new'
f90_interface = 'n'
use_sundials = 'y'
sundials_include = '/usr/local/include' # alternatively left blank
sundials_libdir = '/usr/local/lib' # alternatively left blank
boost_inc_dir = '/opt/local/include/'
boost_lib_dir = '/opt/local/lib'
Using scons build, Cantera compiles successfully. There are some warnings like
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I../../include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -I/opt/local/include/ -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cantera/_cantera.cpp -o ../../build/temp-py2/cantera/_cantera.o
cantera/_cantera.cpp:3914:14: warning: explicitly assigning a variable of type 'PyObject *' (aka '_object *') to itself [-Wself-assign]
__pyx_self = __pyx_self;
~~~~~~~~~~ ^ ~~~~~~~~~~
but in general it seems to work fine. However, I then get two errors:
1. When importing the Cython interface in Python (e.g. while running scons test), I get the error:
scriptRunner(["build/test/python/cython2.passed"], ["test/python/runCythonTests.py"])
PYTHONPATH /Users/tf/Documents/td/cantera/build/python2
Traceback (most recent call last):
File "/Users/tf/Documents/td/cantera/test/python/runCythonTests.py", line 19, in <module>
import cantera
File "/Users/tf/Documents/td/cantera/build/python2/cantera/__init__.py", line 1, in <module>
from ._cantera import *
ImportError: dlopen(/Users/tf/Documents/td/cantera/build/python2/cantera/_cantera.so, 2): Symbol not found: _dgbcon_
Referenced from: /Users/tf/Documents/td/cantera/build/python2/cantera/_cantera.so
Expected in: flat namespace
in /Users/tf/Documents/td/cantera/build/python2/cantera/_cantera.so
This is apparently due to some linking error to the Sundials library. So far, I did not find a way to fix it.
2. When running (sudo) scons install, I get this error:
cd interfaces/cython && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python setup2.py build --build-lib=../../build/python2 --build-temp=../../build/temp-py2 install --record ../../build/python2-installed-files.txt --prefix="/Applications/calc/cantera"
running build
running build_py
running build_ext
skipping 'cantera/_cantera.cpp' Cython extension (up-to-date)
running install
Checking .pth file support in /Applications/calc/cantera/lib/python2.7/site-packages/
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -E -c pass
TEST FAILED: /Applications/calc/cantera/lib/python2.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Applications/calc/cantera/lib/python2.7/site-packages/
and your PYTHONPATH environment variable currently contains:
''
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
http://packages.python.org/distribute/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
scons: *** [interfaces/cython/dummy2] Error 1
However, the path
/Applications/calc/cantera/lib/python2.7/site-packages/ actually is in my $PYTHONPATH. Besides, when I just run the command
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python setup2.py build --build-lib=../../build/python2 --build-temp=../../build/temp-py2 install --record ../../build/python2-installed-files.txt --prefix="/Applications/calc/cantera"it executes without problems. So, I assume that running the command from within scons, the actual value of $PYTHONPATH is not passed correctly or somewhere overwritten.
Linuxcantera.conf
prefix = '$USER/bin/cantera/'
python_package = 'new'
python_array_home = '/usr/lib64/python2.6/site-packages/numpy/core/include'
matlab_toolbox = 'n'
f90_interface = 'n'
use_sundials = 'y'
sundials_include = '/nfs/opt/cantera/cantera201/include'
sundials_libdir = '/nfs/opt/cantera/cantera201/lib64'
build_thread_safe = False
Under Linux, I'm not able to compile Cantera with Cython enabled. I instead get the following error:
...
building 'cantera._cantera' extension
creating ../../build/temp-py2
creating ../../build/temp-py2/cantera
gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fwrapv -fPIC -I. -I../../include -I/usr/lib64/python2.6/site-packages/numpy/core/include -I/nfs/opt/cantera/cantera201/include -I/usr/include -I/usr/include/python2.6 -c cantera/_cantera.c -o ../../build/temp-py2/cantera/_cantera.o
gcc: cantera/_cantera.c: No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1
scons: *** [build/python2/cantera/_cantera.so] Error 1
scons: building terminated because of errors.
I expect this has something to do with Cython.Distutils, but I have no experience and no clue how to deal with this.
BOTHWith the legacy Python interface, the installation still worked smooth.
Besides:
The (optional) dependency on 3to2 is not listed on the Cantera Compilation Guide.
Somewhere while installing Cantera, probably while running scons test, the file test_problems/cxx_ex/gri30.xml is created, which then appears as a change in the git repository.
I know this is quite a lot, but I hope you find this feedback useful. It would be great if you find some time to look at the problems and give me a hint on how to get it to run.
Thanks a lot!
Thomas