wwaites / swipy

SWI Prolog Python Bindings and RDFLib Store
http://github.com/wwaites/swipy
GNU General Public License v3.0
7 stars 2 forks source link

Setup.py error 'bool' is not a constant, variable or function identifier when building 'swi' extension #2

Open tduval-unifylogic opened 2 years ago

tduval-unifylogic commented 2 years ago

@wwaites

Trying to build this to have a prolog rdf store for rdflib...very interested in making this work! After tweaking the get_config() function with a hard-coded dictionary with values from eval swipl --dump-runtime-variables I am getting two errors:

seems the first one is solved with adding from libcpp cimport bool to swi.px Stuck on getting past the second. Any thoughts?

I've tried from cpython import bool as bool_t but that leads to an unknown type name 'bool' error in the swi.c file

Using Python 3.9.12

image image
wwaites commented 2 years ago

Wow! I had all but forgotten about this. Great that you are trying to get it running. I do not know the answer. You probably already found this:

https://github.com/cython/cython/wiki/FAQ#how-do-i-declare-an-object-of-type-bool

which suggests just doing from cpython cimport bool (i.e. not as bool_t). That should result in the name being defined.

I'm not sure if it's right to do from libcpp cimport bool because I think what we want here is the python type not the C++ type. But I could be wrong.

tduval-unifylogic commented 2 years ago

I was able to get past THAT hurdle thanks to your suggestion and moving to an Intel based Mac!

I have now built (it appears somewhat) successfully that I'm getting to the tests. I'm running into an issue that could be an issue with newer version of Prolog? CLI args? Hope I can get through this one too with your help.

I am currently using a Postgres (context and N3 formula aware) Store with the SQLAlchemy plugin but would rather have an rdflib Prolog store with N3 (and formulae). image image

tduval-unifylogic commented 2 years ago

FYI...if this helps Here is how I hard-coded get_config() function in setup.py. Something that could be brought up to date once the rest of things are working.

def get_config(prog):
    return {
        "PLBASE":"/usr/local/Cellar/swi-prolog/8.4.2/libexec/lib/swipl",
        "PLARCH":"x86_64-darwin",
        "PLLIB": "-lswipl",
        "PLLIBDIR": "/usr/local/Cellar/swi-prolog/8.4.2/libexec/lib/swipl/lib/x86_64-darwin"
    }

Had to update a few of the respective keys as well in subsequent lines...