diff --git a/INSTALL.md b/INSTALL.md index 2a30c47..2861f16 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,159 +1,151 @@ # Installing PySwip -Requirements: +## Requirements +* Python 3.8 or later +* SWI-Prolog 9.0.4 or later +* 64bit Intel or ARM processor -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 the `ctypes` module. +> [!IMPORTANT] +> Make sure the SWI-Prolog architecture is the same as the Python architecture. +> If you are using a 64bit build of Python, use a 64bit build of SWI-Prolog, etc. -We recommend installing PySwip into a virtual environment. -Python3 already has built-in support for that. -You can create a virtual environment in `pyswip_env` directory using: +## Installing on All Platforms + +PySwip is available to install from [Python Package Index](https://pypi.org/project/pyswip/). + +> [!NOTE] +> We recommend installing PySwip into a Python virtual environment. +> See: [Creation of virtual environments](https://docs.python.orgs/3/library/venv.html) + +You can install PySwip using: ``` -python3 -m venv pyswip_env +pip install pyswip ``` -After that, you have to activate the virtual environment. On UNIX-like platorms (Linux, MacOS, FreeBSD, etc.) with BASH/csh/tcsh shell: +You will need to have SWI-Prolog installed on your system. +Some operating systems have packages for SWI-Prolog. +Otherwise, you can download it from [SWI-Prolog's website](https://www.swi-prolog.org/Download.html) or build from source. + +PySwip requires the location of the `libswpl` shared library and also the SWI-Prolog home directory. +In many cases, PySwip can find the shared library and the home directory automatically. +Otherwise, you can use the following environment variables: +* `SWI_HOME_DIR` - The SWI-Prolog home directory. +* `LIBSWIPL_PATH` - The location of the `libswipl` shared library. + +You can get the locations mentioned above using the following commands: ``` -source pyswip_env/bin/activate +swipl --dump-runtime-variables ``` -On Windows: +That will output something like: ``` -pyswip_env\Scripts\activate +PLBASE="/home/yuce/swipl-9.3.8/lib/swipl"; +... +PLLIBDIR="/home/yuce/swipl-9.3.8/lib/swipl/lib/x86_64-linux"; ``` +Use the value in the `PLBASE` variable as the value for the `SWI_HOME_DIR` environment variable. +Use the value in the `PLLIBDIR` variable as the value for the `LIBSWIPL_PATH` environment variable. -See the [Python documentation](https://docs.python.org/3/library/venv.html) for more information. +## Installing on Linux -**IMPORTANT: Make sure the SWI-Prolog architecture is the same as the Python architecture. If you are using a 64bit build of Python, use a 64bit build of SWI-Prolog, etc.*** +### Arch Linux -## Linux +Installing SWI-Prolog: +``` +pacman -S swi-prolog +``` -### Arch Linux +Installing PySwip: +(Alternative to the `pip install` way explained above) +``` +pacman -S python-pyswip +``` -[Alexander Rødseth](https://roboticoverlords.org) maintains the [Arch Linux package](https://archlinux.org/packages/extra/any/python-pyswip/). +### Fedora Workstation + +Installing SWI-Prolog: +``` +dnf install pl +``` -Install PySwip with dependencies using: +Installing PySwip: +(Alternative to the `pip install` way explained above) ``` -sudo pacman -S python-pyswip +dnf install python3-pyswip ``` ### Manjaro Linux -Same as the Arch Linux instructions. See: https://manjaristas.org/branch_compare?q=pyswip +Same as the Arch Linux instructions. +See: https://manjaristas.org/branch_compare?q=pyswip ### Parabola GNU/Linux-libre -Same as the Arch Linux instructions. See: https://www.parabola.nu/packages/?q=python-pyswip +Same as the Arch Linux instructions. +See: https://www.parabola.nu/packages/?q=python-pyswip ### Debian, Ubuntu, Raspbian -There are no native packages for Debian-based distros. Follow these steps to install PySwip: - -1) Install SWI-Prolog: - ``` - sudo apt install swi-prolog - ``` - If you don't want the X bindings, just use the `swi-prolog-nox` package. +Debian Bookworm, Ubuntu 24.04 and Raspberry Pi OS Bookworm have SWI-Prolog 9.0.4 in their repositories. -2) Install and activate a virtual environment as described before. +To install PySwip, use the `pip install` way explained above. -3) Install pyswip from Python package index using: - ``` - pip install pyswip - ``` +## Windows -4) Run a quick test by running following code at your Python console: - ```python - from pyswip import Prolog - prolog = Prolog() - prolog.assertz("father(michael,john)") - ``` +Download a recent version of SWI-Prolog from https://www.swi-prolog.org/Download.html and install it. -## Windows +To install PySwip, use the `pip install` way explained above. -1) Get a recent version of SWI-Prolog from http://www.swi-prolog.org/Download.html and install it. +## MacOS -2) Make sure `swipl` executable is on the `PATH`. +The preferred way of installing SWI-Prolog on MacOS is using [Homebrew](https://brew.sh). -2) `pip install pyswip` +### Homebrew -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)") - ``` +Installing SWI-Prolog: +``` +brew install swi-prolog +``` -## MacOS Intel +To install PySwip, use the `pip install` way explained above. -1) Get a recent version of SWI-Prolog from http://www.swi-prolog.org/Download.html and install it. +### Official SWI-Prolog App -2) `pip install pyswip` +Install SWI-Prolog from https://www.swi-prolog.org/Download.html. -3) Make sure `swipl` executable is on the `PATH` and the directory that contains `libswipl.dylib` is in the `DYLD_FALLBACK_LIBRARY_PATH` environment variable. For example, if SWI-Prolog is in `/Applications/SWI-Prolog.app` directory, the following may work: - ``` - export PATH=$PATH:/Applications/SWI-Prolog.app/Contents/swipl/bin/x86_64-darwin15.6.0 - export DYLD_FALLBACK_LIBRARY_PATH=/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.6.0 - ``` +If you get an error like `libgmp.X not found`, you have to set the `DYLD_FALLBACK_LIBRARY_PATH` environment variable before running Python: +``` +export DYLD_FALLBACK_LIBRARY_PATH=/Applications/SWI-Prolog.app/Contents/Frameworks +``` -4) 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 M1 -1) Get a recent version of SWI-Prolog from http://www.swi-prolog.org/Download.html and install it. +To install PySwip, use the `pip install` way explained above. -2) `pip install pyswip` +## Other UNIX -3) Make sure `swipl` executable is on the `PATH` and the directory that contains `libswipl.dylib` is in the `DYLD_FALLBACK_LIBRARY_PATH` environment variable. For example, if SWI-Prolog is in `/Applications/SWI-Prolog.app` directory, the following may work: - ``` - export DYLD_FALLBACK_LIBRARY_PATH=/Applications/SWI-Prolog.app/Contents/Frameworks - export PATH=$PATH:/Applications/SWI-Prolog.app/Contents/MacOS - ``` +### OpenBSD -4) Run a quick test by running following code at your Python console: - ```python - from pyswip import Prolog - prolog = Prolog() - prolog.assertz("father(michael,john)") - ``` +Install SWI-Prolog using the following on OpenBSD 7.6 and later: +``` +pkg_add swi-prolog +``` -## Other UNIX +To install PySwip, use the `pip install` way explained above. ### FreeBSD -1) SWI-Prolog can be installed using `pkg`: - ``` - pkg install swi-pl - ``` +SWI-Prolog can be installed using `pkg`: +``` +pkg install swi-pl +``` + +To install PySwip, use the `pip install` way explained above. -2) `pip install pyswip` +## Test Drive -3) Run a quick test by running following code at your Python console: +Run a quick test by running following code at your Python console: ```python from pyswip import Prolog prolog = Prolog() prolog.assertz("father(michael,john)") ``` - -## Retired Distributions - -The following ports don't seem to be maintained anymore. - -### Fedora - -[Till Hofmann](https://kbsg.rwth-aachen.de/~hofmann/) maintains the [Fedora package](https://src.fedoraproject.org/rpms/python-pyswip). - -Install PySwip for Python 3 with dependencies using: -``` -sudo dnf install python3-pyswip -``` - -Install PySwip for Python 2 with dependencies using: -``` -sudo dnf install python3-pyswip -```