-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,43 @@ | ||
# PySWIP INSTALL | ||
|
||
PySWIP requires SWI-Prolog as a shared library since it uses ctypes to access | ||
SWI-Prolog/C functions. The shared library is present in the Win32 installer, | ||
but missing by default from the builds made directly from the source. | ||
PySWIP has no dependencies beyond Python's standard library. Some operating systems do not install the full standard library. In that case make sure that your Python setup includes `ctypes`. | ||
|
||
## Installing on Linux | ||
## Linux | ||
|
||
Some distro packages of swi-prolog already include the shared library or offer | ||
a devel version of the package, that way you can skip compiling the package from | ||
source. A quick way to check if you have the library already installed is by running | ||
|
||
``` | ||
$ find /usr/lib* -name lib*pl.so | ||
``` | ||
|
||
If no files are listed with the name `libswipl.so` or `libpl.so` you'll need | ||
to proceed building from source. | ||
|
||
These instructions are tested on a Linux system, but should also work for POSIX | ||
systems. Also, you may want to install development packages for readline, | ||
libncurses, and libgmp. | ||
|
||
You need to do the following to install a shared library enabled version of | ||
SWI-Prolog. We use version 6.0.2 of SWI-Prolog. Please make the necessary | ||
modifications for your environment. | ||
|
||
1) Get the source from http://www.swi-prolog.org/download/stable: | ||
``` | ||
wget http://www.swi-prolog.org/download/stable/src/pl-6.0.2.tar.gz | ||
``` | ||
|
||
2) Extract the archive and cd into it: | ||
``` | ||
tar xzvf pl-6.0.2.tar.gz | ||
cd pl-6.0.2 | ||
``` | ||
|
||
3) Configure the source with shared library enabled: | ||
``` | ||
./configure --enable-shared | ||
``` | ||
*** If using a 64-bit system, you may have to compile with the -ggdb flag in | ||
order to get PySWIP to work with SWI-Prolog without segfaults (But not | ||
necessarily. YMMV.): | ||
|
||
``` | ||
CFLAGS=-ggdb ./configure --enable-shared | ||
``` | ||
|
||
4) Compile the source: | ||
``` | ||
make | ||
``` | ||
|
||
5) Install the source: | ||
``` | ||
sudo make install | ||
1) Install SWI-Prolog using your package manager. On Debian, Ubuntu and similar distributions, you can do that by: | ||
``` | ||
|
||
6) *** This is perhaps no longer relevant, as it appears clp is installed by | ||
default with SWI-Prolog clp library is useful for constraint handling | ||
problems, so let's install that too: | ||
sudo apt install swi-prolog | ||
``` | ||
cd packages/clpqr | ||
./configure --enable-shared | ||
make && make install | ||
``` | ||
|
||
7) If you are not using Python 2.5 or later, you should install ctypes, or get a | ||
new version of Python (apt-get is fine if you're using Ubuntu). | ||
If you don't want the X bindings, just use the `swi-prolog-nox` package. | ||
|
||
8) Unpack PySwIP package and install it with, `python setup.py install`. | ||
2) `pip install pyswip` | ||
|
||
9) After you install it, you can test it with the following at your Python shell: | ||
3) Run a quick test by running following code at your Python console: | ||
```python | ||
from pyswip import Prolog | ||
prolog = Prolog() | ||
prolog.assertz("father(michael,john)") | ||
``` | ||
|
||
If you get an error, such as "libpl (shared) not found." or "FATAL ERROR: | ||
Resource not found" be sure you have installed SWI-Prolog as a shared | ||
library. Check your default library directory (usually `/usr/lib`) for | ||
`libswipl.so`. | ||
|
||
|
||
Installing on Win32 | ||
------------------- | ||
## Windows | ||
|
||
1) Get a recent version of SWI-Prolog for Win32 from: | ||
http://www.swi-prolog.org/dl-stable.html and install it. | ||
1) Get a recent version of SWI-Prolog from http://www.swi-prolog.org/Download.html and install it. | ||
|
||
2) You need to add SWI-Prolog's bin directory ``C:\Program Files\pl\bin`` to | ||
*path*, here are two tutorials for that: | ||
http://www.computerhope.com/issues/ch000549.htm and | ||
http://vlaurie.com/computers2/Articles/environment.htm | ||
2) `pip install pyswip` (*recommended*) or [download](https://pypi.org/project/pyswip/#files) a Windows installer version of PySWIP and install it. | ||
|
||
3) Get a Windows installer version of PySWIP and install it. | ||
|
||
4) After you install it, you can test it with the following at your Python | ||
console: | ||
3) Run a quick test by running following code at your Python console: | ||
```python | ||
from pyswip import Prolog | ||
prolog = Prolog() | ||
prolog.assertz("father(michael,john)") | ||
``` | ||
|
||
|
||
## MacOS | ||
|
||
**TODO** | ||
|
||
## Other UNIX | ||
|
||
**TODO** |