Picstus: Python to Prolog, Prolog to Python Interface

Picstus is a two-way interface between Python and Sicstus Prolog. It allows using Sicstus from Python and vice versa, where one language is seen as a module of another. Programs in the two languages can even mutually call one another to an arbitrary depth. The learn more, read the online documentation.

The module hasn't been rigorously tested; precise and easily replicable bug reports are welcome.

Picstus is a free software which you may redistribute and/or modify under the GPL licence.

Requirements

Picstus requires Python and Sicstus (or at least their crucial parts). I run it on Windows, but it shouldn't be difficult to port it to Linux. It is not picky about the version of Python. Regarding Sicstus, version 3.8 won't work and 3.12 does; I have no idea about the versions in between.

The Windows binary file provided on this page is compiled and linked against Python 2.3 and Sicstus 3.12. To work with another version of Python, the module needs to be rebuild. I used Visual C++ 6.0, but other compilers should work as well (possibly with minor adjustments). I have no idea about the constancy of Sicstus API, so I'd appreciate information whether rebuilding is needed for different versions Sicstus, too.

Download

Windows + Python 2.3 + Sisctus 3.12
Binary installation
This is the preferred installation - run it and it should do the job. It hasn't been tested on any other machine than mine, so positive and negative feedbacks are welcome.
Binary files
Use this if the installation file above didn't work. The archive contains the same stuff as the installation, except that you have to copy the files manually: picstus.py goes to the Python's subdirectory lib/site-packages, python.pl and python.dll go to the Sicstus' subdirectory library and the documentation goes in the center of your desktop. You will also need to check whether the Sicstus installer has set environment variable SP_PATH to contain the Sicstus' base directory; set it yourself if needed. If Picstus complains that it cannot find sprt312.dll, add its directory to PATH.
Everybody else
Source distribution
Download this if you cannot use the provided binaries due to mismatching versions. Compile picstus.cpp and python_glue.c, link it with pythonXX.lib (say python23.lib) and sprtYYY.lib (say sprt312.lib) and name the resulting file python.dll (or python.so on Linux). Then copy the files as described above. Project files for VS 6.0 are provided, but need to be modified to link with the right versions.
One more nasty detail: for the time of compilation, replace the spaux.c in Sictus' directory include with the replacement provided in the archive. There should be a way around this, but the corresponding #defines are not described in the Sicstus API documentation.

Janez Demsar (janez.demsar 0x40 fri.uni-lj.si)
Laboratory of Artificial Intelligence
Faculty of Computer and Information Science
University of Ljubljana, Slovenia