it shows about how to package :
- using Swi Prolog
- with
pyswip - with
pyinstallerIt was build and tested on windows.
- check that you have the required environment variable described in
pyswipdocumentation. Here is the usual values for the 64 bit version installed the standard way:- SWI_HOME_DIR=c:\program files\swipl
- LIBSWIPL_PATH=C:\Program Files\swipl\bin\libswipl.dll
- Create a virtual environment as usual
- install the requirements with
install_requirements.bat - build the packaged application with
build.bat
Note that SWI-Prolog by PortableApps is a Win32 version, requiring a Win32 Python.
python src\main.py
it should produce:
[{'X': 'dan'}, {'X': 'lucy'}, {'X': 'john'}]dist\python-prolog-demo.exe
it should produce same result:
[{'X': 'dan'}, {'X': 'lucy'}, {'X': 'john'}]I've found a bug with prolog.consult() on Windose. The backslash of windows paths are considered as escape by prolog. no way to change that as the path is built by pyswip using Path.
The PyswipUtil.consult() does nearly the same, but escaping the backslash... I've posted a message on pyswip googlegroup...
Also it does all relative to the prolog folder, and the folder
ther is a problem to initialize SWI Prolog when using pyinstaller... you need to package the installation folder of SWI Prolog, and adjuste some environment variables with pyinstaller informations...
now it is done in prolog/init_pyswip.py module . you have to import it before importing pyswip.
- Find things to do
- I'm an old programmer (Java, C/C++, and many scripting languages), but a rookie in Python and Prolog
- I'm lazy
- Tell me if something can be improved (easily)
- Don't hesitate to share use case.
Thanks to Grok, Claude, Deepseek, and Le Chat Mistral, for the teaching.