If you check out the latest git source, run
gity submodule update --init and build it, it should add the package
swipy (GitHub) and if Python is installed with the development files, all should configure nicely. After building, you can run Python interactively under Prolog using
You can also call e.g.
?- py_call(print("Hello world\n"), _).
See examples in packages/swipy and the very short docs built in
There are a lot of issues and questions. It is, at least on some platforms, already useful as is though
- Naming and compatibility to the XSB version. Having a shared Python interface would be nice, probably next to the more natural SWI-Prolog interface.
- (How) can we support big integers and rational numbers?
- Code is probably buggy at places. I’m still struggling with the Py_DECREF(), etc.
- Barely any comment in the code yet.
- I wonder whether calling Prolog from Python is what we want. Currently it provides a module
januswith some functions and a class
Prologthat provides an iterator over solutions.
- Currently it binds to the Python discovered by CMake. Probably you want to be able to select a Python.
- Eventually there should also be a
pip install swipy. Little clue what should be in there.
- Surely much more.
So, Python programmers, please comment and, if possible, help.