Skip to content

Commit

Permalink
BUILD: Honour environment variable SWIPL for pip install .
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Nov 25, 2024
1 parent 8b0b8bf commit cd6377a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ using

pip install janus-swi

SWI-Prolog is selected by finding `swipl` on the executable search
path. If `swipl.exe` is not in ``%PATH%`` on Windows the Windows
registry is examined to find SWI-Prolog.
SWI-Prolog is selected from the environment variable `SWIPL` or by
finding `swipl` on the executable search path. On Windows, if neither
of the above work, the Windows registry is examined to find the
installed SWI-Prolog system (by default `C:\Program
Files\swipl\bin\swipl.exe`).

If you installed SWI-Prolog from source, it is advised to install
Janus from the `packages/swipy` directory in the Prolog source. The
Expand Down
6 changes: 3 additions & 3 deletions janus/_find_swipl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import subprocess
import re

def swipl_properties():
def swipl_properties(exe="swipl"):
try:
return swipl_exe_properties()
return swipl_exe_properties(exe)
except:
exe = find_swipl()
if ( exe ):
return swipl_exe_properties(find_swipl())
return swipl_exe_properties(exe)
return None

def swipl_exe_properties(exe="swipl"):
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Build janus as a Python package

SWIPL="swipl"
import os

SWIPL=os.getenv("SWIPL") or "swipl"
PLLIB="swipl"

from setuptools import setup, Extension
import sys
sys.path.append("janus")
from _find_swipl import swipl_properties

props=swipl_properties()
props=swipl_properties(SWIPL)

if ( not props ):
raise RuntimeError("Failed to find SWI-Prolog components")
Expand Down

0 comments on commit cd6377a

Please sign in to comment.