Skip to content

Commit

Permalink
Support SWI-Prolog versions > 8.5.2 (#133)
Browse files Browse the repository at this point in the history
Support SWI-Prolog versions > 8.5.2

After SWI-Prolog 8.5.2, PL_version was renamed to PL_version_info,
causing pyswip to crash when used with SWI-Prolog versions > 8.5.2.
  • Loading branch information
david-r-cox committed Jan 3, 2023
1 parent ab3a36d commit 841d08f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -26,3 +26,4 @@ Guglielmo Gemignani
Vince Jankovics
Tobias Grubenmann
Arvid Norlander
David Cox
14 changes: 11 additions & 3 deletions pyswip/core.py
Expand Up @@ -587,16 +587,24 @@ def check_and_call(*args):
PL_VERSION_VM =6 # VM signature
PL_VERSION_BUILT_IN =7 # Built-in predicate signature


# After SWI-Prolog 8.5.2, PL_version was renamed to PL_version_info
# to avoid a conflict with Perl. For more details, see the following:
# https://github.com/SWI-Prolog/swipl-devel/issues/900
# https://github.com/SWI-Prolog/swipl-devel/issues/910
try:
PL_version = _lib.PL_version
if _lib.PL_version_info != None:
PL_version = _lib.PL_version_info # swi-prolog > 8.5.2
else:
PL_version = _lib.PL_version # swi-prolog <= 8.5.2
PL_version.argtypes = [c_int]
PL_version.restype = c_uint

PL_VERSION = PL_version(PL_VERSION_SYSTEM)
if PL_VERSION<80200:
raise Exception("swi-prolog>= 8.2.0 is required")
raise Exception("swi-prolog >= 8.2.0 is required")
except AttributeError:
PL_VERSION=70000 # Best guess. When was PL_version introduced?
raise Exception("swi-prolog version number could not be determined")


# PySwip constants
Expand Down

0 comments on commit 841d08f

Please sign in to comment.