diff --git a/CMakeLists.txt b/CMakeLists.txt index 72fbd2158..1a8b6af40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,6 +384,36 @@ if (${C_COMPILER} MATCHES "Intel") set(HAVE_GCC 1) endif () +# rpath stuff, hopefully it works +# use, i.e. don't skip the full RPATH for the build tree +#SET(CMAKE_SKIP_BUILD_RPATH FALSE) + + +# when building, don't use the install RPATH already +# (but later on when installing) +#SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + +# SET(CMAKE_INSTALL_FULL_RPATH ${CMAKE_TOP_BINARY_DIR}) + +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + +# the RPATH to be used when installing, but only if it's not a system directory +LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir) + IF("${isSystemDir}" STREQUAL "-1") + SET(CMAKE_INSTALL_RPATH ${libdir}) + ENDIF("${isSystemDir}" STREQUAL "-1") + +IF(NOT WIN32 AND NOT APPLE) +LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../lib/Yap) +LIST(APPEND CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) +LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../lib) +LIST(APPEND CMAKE_INSTALL_RPATH \\$ORIGIN/../../../lib) + +ENDIF() + # Model Specific if (HAVE_GCC) set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall) @@ -534,27 +564,6 @@ string(SUBSTRING ${CMAKE_SHARED_LIBRARY_SUFFIX} 1 -1 SO_EXT) set_property(DIRECTORY PROPERTY CXX_STANDARD 11) -# rpath stuff, hopefully it works -# use, i.e. don't skip the full RPATH for the build tree -#SET(CMAKE_SKIP_BUILD_RPATH FALSE) - - -# when building, don't use the install RPATH already -# (but later on when installing) -#SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - -# SET(CMAKE_INSTALL_FULL_RPATH ${CMAKE_TOP_BINARY_DIR}) - -# add the automatically determined parts of the RPATH -# which point to directories outside the build tree to the install RPATH -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - -# the RPATH to be used when installing, but only if it's not a system directory -LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" isSystemDir) - IF("${isSystemDir}" STREQUAL "-1") - SET(CMAKE_INSTALL_RPATH ${libdir}) - ENDIF("${isSystemDir}" STREQUAL "-1") include_directories(H H/generated diff --git a/packages/python/swig/CMakeLists.txt b/packages/python/swig/CMakeLists.txt index 89ed2c122..c14661fea 100644 --- a/packages/python/swig/CMakeLists.txt +++ b/packages/python/swig/CMakeLists.txt @@ -6,7 +6,7 @@ INCLUDE(UseSWIG) include(FindPythonModule) list (APPEND pl_library ${CMAKE_CURRENT_SOURCE_DIR}/prolog/yapi.yap ) -set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__init__.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__main__.py) +set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__main__.py) SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES CPLUSPLUS ON) @@ -22,6 +22,7 @@ set(YAP4PY_PY yap4py/__init__.py yap4py/__main__.py yap4py/yapi.py) configure_file("setup.py.in" setup.py) configure_file("MANIFEST.in" ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.in) configure_file("YAP4PY.md" README.md) +configure_file(yap4py/__init__.py.in yap4py/__init__.py) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/include ) diff --git a/packages/python/swig/__init__.py b/packages/python/swig/__init__.py index 077b47d22..3d74eafde 100644 --- a/packages/python/swig/__init__.py +++ b/packages/python/swig/__init__.py @@ -9,6 +9,8 @@ import platform global yap_lib_path yap_lib_path = os.path.dirname(__file__) +if @CONDA_BUILD@ == "1": + # do not do nothing if platform.system() == 'Windows': def load( dll ): dll = glob.glob(os.path.join(yap_lib_path,dll))[0] @@ -23,3 +25,7 @@ else: if platform.system() == 'Apple': load('libYap.dylib') load('libPy4YAP.dylib' ) + else: + load('libYap.os') + load('libPy4YAP.os' ) + \ No newline at end of file diff --git a/packages/python/swig/yap4py/__init__.py b/packages/python/swig/yap4py/__init__.py index 40fc7ce05..3a6bbafc8 100644 --- a/packages/python/swig/yap4py/__init__.py +++ b/packages/python/swig/yap4py/__init__.py @@ -6,20 +6,26 @@ import os.path import platform import sys -# global yap_lib_path -#yap_lib_path = os.path.dirname(__file__) +global yap_lib_path +yap_lib_path = os.path.dirname(__file__) -# if platform.system() == 'Windows': -# def load( dll ): -# dll = glob.glob(os.path.join(yap_lib_path,dll))[0] -# dll = os.path.abspath(dll) -# ctypes.WinDLL(dll) -# else: -# def load( l0 ): -# for i in ["@libdir@",""]: -# dll = os.path.concat(i,l0) -# dll = glob.glob(os.path.join(yap_lib_path,dll))[0] -# dll = os.path.abspath(dll) -# ctypes.CDLL(dll) -# # load('libYap*') -# # load('libPy4YAP*') +if platform.system() == 'Windows': + def load( dll ): + dll = glob.glob(os.path.join(yap_lib_path,dll))[0] + dll = os.path.abspath(dll) + ctypes.WinDLL(dll) +elseif 
platform.system() == 'Apple': + def load( dll ): + dll = glob.glob(os.path.join(yap_lib_path,dll))[0] + dll = os.path.abspath(dll) + ctypes.CDLL(dll) + load('libYap.dylib') + load('libPy4YAP.dylib') +else: + def load( dll ): + dll = glob.glob(os.path.join(yap_lib_path,dll))[0] + dll = os.path.abspath(dll) + ctypes.CDLL(dll) + load('libYap.so') + load('libPy4YAP.so') + \ No newline at end of file diff --git a/packages/swig/yap.i b/packages/swig/yap.i index ca5af193a..7825edaa0 100644 --- a/packages/swig/yap.i +++ b/packages/swig/yap.i @@ -2,7 +2,11 @@ /* example.i */ +#if PYTHONSWIG +%module(directors = "1", package="yap4py") yap +#else %module(directors = "1") yap +#endif // Language independent exception handler %include exception.i