SWI-Prolog Python interface
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Python interface
        • Introduction
        • Data conversion
        • Janus by example - Prolog calling Python
        • library(janus): Call Python from Prolog
        • Calling Prolog from Python
        • Janus and threads
        • Janus and signals
        • Janus versions
        • Janus as a Python package
        • Prolog and Python
        • Janus performance evaluation
        • Python or C/C++ for accessing resources?
        • Janus platforms notes
          • Janus on Windows
          • Janus on Linux
          • Janus on MacOS
        • Compatibility to the XSB Janus implementation
        • Status of Janus

13 Janus platforms notes

Janus relies on the C APIs of Prolog and Python and functions therefore independent from the platform. While the C, Python and Prolog code the builds Janus is platform independent, dynamically loading Prolog into Python or Python into Prolog depends on versions as well as several properties of the dynamic linking performed by the platform. In the sections below we describe some of the issues.

13.1 Janus on Windows

We tested the Windows platform using SWI-Prolog binaries from https://www.swi-prolog.org/Downloads.html and Python downloaded from https://www.python.org/downloads/windows/. The SWI-Prolog binary provides janus.dll which is linked to python3.dll, a “stable API” based wrapper that each Python 3 binary distribution provides in addition to python3xx.dll. Calling Python from Prolog is supported out of the box, provided the folder holding python3.dll is in the search %PATH%.

The Python package can be installed using pip as described in section 9. Once built, this package finds SWI-Prolog on %PATH% or using the registry and should be fairly independent from the Prolog version as long as it is version 9.1.12 or later.

13.2 Janus on Linux

On Linux systems we bind to the currently installed Prolog and Python version. This should work smoothly from source. Janus is included in the PPA distribution for Ubuntu as well as in the Docker images. It is currently not part of the SNAP distribution.

See section 9 for for building the janus_swi Python package.

13.3 Janus on MacOS

Unfortunately MacOS versions of Python do not ship with the equivalent of python3.dll found on Windows. This implies we can only compile our binaries against a specific version of Python. We will use the default Python binary for that, which is installed in /Library/Frameworks/Python.framework/

The Macports version is also linked against an explicit version of Python, in this case provided by Macports.

The Python package janus_swi may be compiled against any version of Python selected by pip. See section 9 for details.