diff --git a/packages/python/pl2py.c b/packages/python/pl2py.c index e21d531c2..bfada613b 100644 --- a/packages/python/pl2py.c +++ b/packages/python/pl2py.c @@ -73,7 +73,7 @@ PyObject *term_to_python(term_t t, bool eval) { return o; } break; case PL_STRING: { - char *s; + char *s = NULL; if (!PL_get_chars(t, &s, REP_UTF8 | CVT_ATOM | CVT_STRING | BUF_DISCARDABLE)) { return NULL; diff --git a/packages/python/pypreds.c b/packages/python/pypreds.c index d73e45547..7a220f93c 100644 --- a/packages/python/pypreds.c +++ b/packages/python/pypreds.c @@ -633,6 +633,7 @@ static int python_import(term_t mname, term_t mod) { return false; s = stpcpy(s, sa); *s++ = '.'; + s[0] = '\0'; } else if (!PL_get_nchars(mname, &len, &s, CVT_ALL | CVT_EXCEPTION | REP_UTF8)) { return false; diff --git a/packages/python/python.pl b/packages/python/python.pl index 2c5fadef4..97e350017 100644 --- a/packages/python/python.pl +++ b/packages/python/python.pl @@ -429,4 +429,4 @@ python_assign_field(C1.E, Obj) :- python_eval_term(C1, O1), python_assign_field(O1, E, Obj ). -:- initialization( use_foreign_library(foreign(libpYAPPython), init_python), now ). +:- initialization( use_foreign_library(foreign(libYAPPython), init_python), now ). diff --git a/packages/swig/python/CMakeLists.txt b/packages/swig/python/CMakeLists.txt index 51ca9dbdf..024828c88 100644 --- a/packages/swig/python/CMakeLists.txt +++ b/packages/swig/python/CMakeLists.txt @@ -24,10 +24,10 @@ if (PYTHONLIBS_FOUND) #SET( CMAKE_SWIG_OUTDIR "yap" ) - SWIG_ADD_MODULE(Py2YAP python ../yap.i ) - SWIG_LINK_LIBRARIES(Py2YAP ${PYTHON_LIBRARIES} Yap++ libYap YAPPython) - set_target_properties ( ${SWIG_MODULE_Py2YAP_REAL_NAME} PROPERTIES - NO_SONAME ON ) +# SWIG_ADD_MODULE(Py2YAP python ../yap.i ) +# SWIG_LINK_LIBRARIES(Py2YAP ${PYTHON_LIBRARIES} Yap++ libYap YAPPython) +# set_target_properties ( ${SWIG_MODULE_Py2YAP_REAL_NAME} PROPERTIES +# NO_SONAME ON ) # execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print( sysconfig.get_python_lib( plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}' ) )" @@ -36,15 +36,15 @@ if (PYTHONLIBS_FOUND) # get_filename_component ( _ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE ) # file ( RELATIVE_PATH _REL_PYTHON_MOULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH} ) - set ( PYTHON_MODULE_PATH - ${_REL_PYTHON_MODULE_PATH} - ) +# set ( PYTHON_MODULE_PATH +# ${_REL_PYTHON_MODULE_PATH} +# ) set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") add_custom_target ( py2yap ALL COMMAND ${PYTHON_EXECUTABLE} setup.py bdist - DEPENDS yap.py ${SWIG_MODULE_Py2YAP_REAL_NAME} ) + DEPENDS ../yap.py YAPPython ) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install diff --git a/packages/swig/python/setup.py.cmake b/packages/swig/python/setup.py.cmake index 4c3f9480b..788f06453 100644 --- a/packages/swig/python/setup.py.cmake +++ b/packages/swig/python/setup.py.cmake @@ -1,25 +1,34 @@ from distutils.core import setup, Extension +import sys +import os +import platform +if platform.system() == 'Darwin': + my_extra_link_args = ['-Wl,-rpath','${dlls}'] +else: + my_extra_link_args = [] + setup( name = "yap", version = "0.1", - ext_modules=[Extension('_yap', ['${CMAKE_SOURCE_DIR}/packages/swig/python/_yap.c'], + ext_modules=[Extension('_yap', ['${CMAKE_SOURCE_DIR}/packages/swig/yap.i'], define_macros = [('MAJOR_VERSION', '1'), ('MINOR_VERSION', '0'), ('_YAP_NOT_INSTALLED_', '1')], - runtime_library_dirs=['${dlls}'], + runtime_library_dirs=['${dlls}'], + swig_opts=['-modern', '-c++', '-py3','-I${CMAKE_SOURCE_DIR}/CXX'], library_dirs=['../../..','../../../CXX', '../../python', '.'], - libraries=['Yap++','Yap','YAPPython'], + extra_link_args=my_extra_link_args, + libraries=['Yap++','Yap','YAPPython'], include_dirs=['../../..', '${CMAKE_SOURCE_DIR}/H', '${CMAKE_SOURCE_DIR}/H/generated', '${CMAKE_SOURCE_DIR}/OPTYap', '${CMAKE_SOURCE_DIR}/os', '${CMAKE_SOURCE_DIR}/include', - '${CMAKE_SOURCE_DIR}/CXX', '.'], - extra_objects = ['${CMAKE_CURRENT_BINARY_DIR}/_Py2YAP${CMAKE_SHARED_MODULE_SUFFIX}' ] + '${CMAKE_SOURCE_DIR}/CXX', '.'] )], py_modules = ['yap'] )