[pypy-issue] [issue1382] SWIG and OpenBabel
Amaury Forgeot d Arc
tracker at bugs.pypy.org
Thu Jan 24 23:36:42 CET 2013
Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:
I managed to hack openbabel to have python bindings compiled for PyPy, and it seems to work.
No wxPython and tkInter integration.
Here is what I did:
1 - Normally start with: mkdir build; cd build; cmake .. -DPYTHON_BINDINGS=ON
2 - I edited some configuration variables (with "ccmake .", or edit the CMakeCache.txt)
to change "PYTHON_EXECUTABLE" and "PYTHON_INCLUDE_DIR", to use my PyPy installation instead.
3 - I set "PYTHON_LIBRARY" to something stupid (/dev/null), and modified Scripts/CMakeLists.txt to remove the reference to
${PYTHON_LIBRARY}. [On Windows, you'd set it instead to the include/python27.lib provided with PyPy]
4 - I modified Scripts/CMakeLists.txt to change the library SUFFIX from .so to .pypy-19.so [modify .pyd into .pypy-19.pyd if you
are on Windows]
5 - Then run "cmake ." again, and "make bindings_python".
6 - Fixed a stupid C++ conversion error: the swig module calls PySlice_Check() with a PySliceObject* pointer!
On CPython it's a macro so nothing happens, but on PyPy it's a function which is supposed to take a PyObject*.
I added casts everywhere.
7 - Link will fail on Linux because of the linker option "-Wl,--no-undefined" (and PyPy does not provide a libpython27.so to link
with). I removed this option from build/scripts/CMakeFiles/bindings_python.dir/link.txt. [This step is not relevant on windows]
8 - run "make bindings_python" again, works this time.
I guess one could install it at this point. I didn't, so I run (directly from the build directory)
BABEL_DATADIR=../data BABEL_LIBDIR=lib PYTHONPATH=lib:../scripts/python ~/pypy/pypy-1.9/bin/pypy
../doc/examples/obconversion_readstring.py
...which worked like a charm! I even added some commands ("print mol.GetExactMass()") to be sure that the object looks correct
(58.07825032; I don't even know what it means :-)
In short, most of the issues come from CMake, which (as usual) has a very fixed view of the world.
SWIG is correctly supported. Of course more tests are needed...
----------
nosy: +amaury
status: unread -> chatting
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1382>
________________________________________
More information about the pypy-issue
mailing list