Fast-track to installing/implementing a SWIP module?

Gerhard Häring gerhard.haering at
Sun Sep 29 04:27:27 CEST 2002

Robert Oschler wrote in comp.lang.python:
> I am a Python newbie so bear with me here.  I just downloaded the PyProlog
> package, which allows Python to access SWI-Prolog through a C-code SWIP
> module.  I just need the basics such as, proper directory to install files
> and instructions for making sure the SWIP module can find SWI-Prolog, and
> for making sure the package will run properly in Python. Is there a URL or
> doc that can get me started?  I would assume that I have to compile the 'C'
> source for the SWIP module, and the resultant object file (.so?) in a proper
> directory?  These the kinds of questions I need to get answered.  I read the
> 3 README's in the PyProlog package but nothing seemed to suffice.

If I understand correcly, you only have to have SWI-Prolog in your PATH, then
the following:

    python build

will build everything and

    python install

will install your modules.

Explanation: This function:

    def get_atom(atom):
        query = "pl -f none -g 'current_prolog_flag(%s, V), write(V), nl.' -t 'halt'"
        f = os.popen(query % atom)

in should do the magic of finding the include and library paths to
link against SWI Prolog.

-- Gerhard

More information about the Python-list mailing list