python fixes for win32
This commit is contained in:
parent
bba62ea6eb
commit
d06dd49dd0
@ -1,4 +1,5 @@
|
||||
# value of 3.4.0 or lower.
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
@ -61,36 +62,57 @@ include(Sources NO_POLICY_SCOPE)
|
||||
|
||||
include(Model NO_POLICY_SCOPE)
|
||||
|
||||
|
||||
include_directories ( utf8proc packages/myddas packages/myddas/sqlite3/src)
|
||||
|
||||
if (ANDROID)
|
||||
include_directories (
|
||||
packages/myddas/sqlite3/src/Android/jni/sqlite
|
||||
packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper
|
||||
)
|
||||
endif (ANDROID)
|
||||
packages/myddas/sqlite3/src/Android/jni/sqlite
|
||||
packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper
|
||||
)
|
||||
endif (ANDROID)
|
||||
|
||||
set_property( SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||
set_property( SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||
|
||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||
|
||||
if (MYSQL_FOUND)
|
||||
add_definitions(= -DMYDDAS_MYSQL=1)
|
||||
endif()
|
||||
add_definitions(= -DMYDDAS_MYSQL=1)
|
||||
endif()
|
||||
|
||||
if (ODBC_FOUND)
|
||||
add_definitions(= -DMYDDAS_ODBC=1)
|
||||
endif()
|
||||
add_definitions(= -DMYDDAS_ODBC=1)
|
||||
endif()
|
||||
|
||||
if (MYSQL_POSTGRES)
|
||||
add_definitions(= -DMYDDAS_POSTGRES=1)
|
||||
endif()
|
||||
if (MYSQL_POSTGRES)
|
||||
set(SWIG_SOURCES packages/swig/python/yap_PYTHONwrapper.cxx )
|
||||
endif()
|
||||
add_definitions(= -DMYDDAS_POSTGRES=1)
|
||||
endif()
|
||||
|
||||
|
||||
if (ANDROID)
|
||||
OPTION (WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||
|
||||
IF (WITH_SWIG)
|
||||
find_host_package (SWIG)
|
||||
macro_log_feature (SWIG_FOUND "Swig"
|
||||
"Use SWIG Interface Generator "
|
||||
"http://www.swig.org" ON)
|
||||
ENDIF (WITH_SWIG)
|
||||
|
||||
option (WITH_PYTHON
|
||||
"Allow Python->YAP and YAP->Python" ON)
|
||||
|
||||
IF (WITH_PYTHON)
|
||||
include(python NO_POLICY_SCOPE)
|
||||
ENDIF (WITH_PYTHON)
|
||||
|
||||
|
||||
IF (SWIG_FOUND)
|
||||
add_subDIRECTORY (packages/swig NO_POLICY_SCOPE)
|
||||
ENDIF(SWIG_FOUND)
|
||||
|
||||
|
||||
|
||||
if (ANDROID)
|
||||
|
||||
ADD_SUBDIRECTORY(os)
|
||||
ADD_SUBDIRECTORY(OPTYap)
|
||||
@ -101,18 +123,21 @@ if (MYSQL_POSTGRES)
|
||||
|
||||
else()
|
||||
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:libOPTYap> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:libYAPOs> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:utf8proc> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:myddas> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
|
||||
if (WIN32)
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
||||
if (PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAPPython0> )
|
||||
endif()
|
||||
endif()
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:libOPTYap> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:libYAPOs> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:utf8proc> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:myddas> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
|
||||
if (WIN32)
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
||||
if (WITH_PYTHON )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:Obj4Py> )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
@ -137,8 +162,6 @@ endif (WIN32)
|
||||
|
||||
include(libYap NO_POLICY_SCOPE)
|
||||
|
||||
endif()
|
||||
|
||||
if (USE_READLINE)
|
||||
target_link_libraries(libYap ${READLINE_LIBRARIES})
|
||||
endif (USE_READLINE)
|
||||
@ -155,4 +178,18 @@ set_target_properties(libYap
|
||||
)
|
||||
|
||||
MY_include(Packages NO_POLICY_SCOPE)
|
||||
|
||||
|
||||
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
||||
add_subdirectory(packages/python/swig)
|
||||
|
||||
include(FindPythonModule)
|
||||
|
||||
find_python_module( jupyter )
|
||||
|
||||
if (PY_JUPYTER)
|
||||
add_subdirectory(packages/python/yap_kernel)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
include(Config NO_POLICY_SCOPE)
|
||||
|
@ -20,13 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifndef YAPT_HH
|
||||
#define YAPT_HH 1
|
||||
|
||||
extern "C" {
|
||||
Term YAP_ReadBuffer(const char *s, Term *tp);
|
||||
|
||||
X_API Term YAP_ReadBuffer(const char *s, Term *tp);
|
||||
}
|
||||
|
||||
class YAPError;
|
||||
|
@ -18,27 +18,6 @@ if (WITH_JIT)
|
||||
add_subDIRECTORY(JIT)
|
||||
endif (WITH_JIT)
|
||||
|
||||
OPTION (WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||
|
||||
IF (WITH_SWIG)
|
||||
find_host_package (SWIG)
|
||||
macro_log_feature (SWIG_FOUND "Swig"
|
||||
"Use SWIG Interface Generator "
|
||||
"http://www.swig.org" ON)
|
||||
ENDIF (WITH_SWIG)
|
||||
|
||||
option (WITH_PYTHON
|
||||
"Allow Python->YAP and YAP->Python" ON)
|
||||
|
||||
IF (WITH_PYTHON)
|
||||
include(python)
|
||||
ENDIF (WITH_PYTHON)
|
||||
|
||||
|
||||
IF (SWIG_FOUND)
|
||||
add_subDIRECTORY (packages/swig)
|
||||
ENDIF(SWIG_FOUND)
|
||||
|
||||
add_subDIRECTORY (packages/raptor)
|
||||
|
||||
add_subDIRECTORY (packages/xml)
|
||||
|
@ -1,17 +1,4 @@
|
||||
set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 )
|
||||
set (PythonInterp_FIND_VERSION 3)
|
||||
find_package(PythonInterp)
|
||||
|
||||
get_filename_component( d ${PYTHON_EXECUTABLE} DIRECTORY )
|
||||
get_filename_component( s ${PYTHON_EXECUTABLE} EXT )
|
||||
get_filename_component( n ${PYTHON_EXECUTABLE} NAME_WE )
|
||||
|
||||
set( o ${d}/${n}3${s} )
|
||||
if (EXISTS o)
|
||||
set (PYTHON_EXECUTABLE ${o})
|
||||
endif()
|
||||
|
||||
find_package(PythonLibs)
|
||||
|
||||
|
||||
# PYTHONLIBS_FOUND - have the Python libs been found
|
||||
@ -22,8 +9,22 @@ find_package(PythonLibs)
|
||||
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
|
||||
##
|
||||
#
|
||||
if (WIN32)
|
||||
set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE )
|
||||
set (PYTHON_LIBRARY C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
||||
set (PYTHON_LIBRARIES C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
||||
set (PYTHON_INCLUDE_PATH C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
|
||||
set (PYTHON_INCLUDE_DIRS C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
|
||||
set (PYTHON_EXECUTABLE C:/msys64/mingw64/bin/python3.exe CACHE FILEPATH "MINGW/MSYS2" FORCE )
|
||||
set (PYTHONLIBS_VERSION_STRING 3.5 CACHE STRING "MINGW/MSYS2" FORCE )
|
||||
|
||||
else()
|
||||
|
||||
find_package(PythonInterp)
|
||||
|
||||
find_package(PythonLibs)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
include_directories( BEFORE ${PYTHON_INCLUDE_DIRS} )
|
||||
@ -36,15 +37,3 @@ check_include_file(Python.h HAVE_PYTHON_H)
|
||||
IF (PYTHONLIBS_FOUND)
|
||||
add_subDIRECTORY (packages/python)
|
||||
ENDIF()
|
||||
|
||||
if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
||||
add_subdirectory(packages/python/swig)
|
||||
|
||||
include(FindPythonModule)
|
||||
|
||||
find_python_module( jupyter )
|
||||
|
||||
if (PY_JUPYTER)
|
||||
add_subdirectory(packages/python/yap_kernel)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
@ -25,8 +25,7 @@ $(PROTOTYPES): % : xml/namespaceGecode.xml extract-prototypes.xsl
|
||||
| sed 's/GECODE_BOOL_EXPORT //g' \
|
||||
| grep -v '*' | sort >> $@ || { rm -f $@; exit 1; }
|
||||
|
||||
$(ENUMS): % : xml/namespaceGecode.xml extract-enums.xsl
|
||||
cat notice.py > $@ || { rm -f $@; exit 1; }
|
||||
b cat notice.py > $@ || { rm -f $@; exit 1; }
|
||||
xsltproc extract-enums.xsl $< >> $@ || { rm -f $@; exit 1; }
|
||||
|
||||
xml/namespaceGecode.xml: Doxyfile
|
||||
|
@ -3,20 +3,22 @@
|
||||
|
||||
set (PYTHON_SOURCES python.c pl2py.c pybips.c py2pl.c pl2pl.c pypreds.c)
|
||||
|
||||
set (PYTHON_HEADERS python.h)
|
||||
set (PYTHON_HEADERS py4yap.h)
|
||||
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
add_library (YAPPython0 OBJECT ${PYTHON_SOURCES})
|
||||
include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include )
|
||||
|
||||
add_library (Obj4Py OBJECT ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
||||
if (WIN32)
|
||||
add_library (YAPPython SHARED pyload.c )
|
||||
add_library (YAPPython SHARED pyload.c ${PYTHON_HEADERS} )
|
||||
endif()
|
||||
|
||||
# arithmetic hassle.
|
||||
set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET YAPPython PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARY})
|
||||
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARIES})
|
||||
|
||||
set_property( SOURCE ${PYTHON_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 _GNU-SOURCE=1)
|
||||
|
||||
|
@ -23,6 +23,12 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_FLAGS "-O;-py3")
|
||||
SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap)
|
||||
#SET_SOURCE_FILES_PROPERTIES(../../swi/yap.i PROPERTIES OUTPUT_NAME yap)
|
||||
|
||||
set(SYS_DLLS /mingw64/bin/libgcc_s_seh-1.dll
|
||||
/mingw64/bin/libgmp-10.dll
|
||||
/mingw64/bin/libstdc++-6.dll
|
||||
/mingw64/bin/libwinpthread-1.dll
|
||||
|
||||
)
|
||||
|
||||
# inform we are compiling YAP
|
||||
# s used in MSYS
|
||||
@ -35,37 +41,41 @@ SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap)
|
||||
# )x
|
||||
|
||||
|
||||
set (dlls $<TARGET_FILE:matrix>
|
||||
set (python_dlls $<TARGET_FILE:matrix>
|
||||
$<TARGET_FILE:regexp>
|
||||
$<TARGET_FILE:yap_rl>
|
||||
$<TARGET_FILE:tries>
|
||||
$<TARGET_FILE:itries>
|
||||
$<TARGET_FILE:sys>
|
||||
$<TARGET_FILE:yap_random>)
|
||||
$<TARGET_FILE:yap_random>
|
||||
)
|
||||
if (TARGET real)
|
||||
list( APPEND dlls $<TARGET_FILE:real>
|
||||
list( APPEND python_dlls $<TARGET_FILE:real>
|
||||
)
|
||||
endif()
|
||||
|
||||
set (PL ${pl_library} ${PROLOG_SOURCES} )
|
||||
|
||||
add_custom_target( YAP4PY_SETUP
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${python_dlls} ${SYS_DLLS} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os
|
||||
DEPENDS YAP4PY_SETUP_DIRS STARTUP ${python_dlls} ${PYTHON_SOURCES} ${PROLOG_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/setup.py ${SWIG_MODULE_Py2YAP_REAL_NAME} )
|
||||
|
||||
add_custom_target( YAP4PY_SETUP_DIRS
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/yap.py
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i ${CMAKE_CURRENT_BINARY_DIR}/yap.i
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${dlls} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os
|
||||
DEPENDS STARTUP ${dlls} ${PYTHON_SOURCES} ${PROLOG_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/setup.py ${SWIG_MODULE_Py2YAP_REAL_NAME} )
|
||||
)
|
||||
|
||||
add_custom_target( YAP4PY ALL
|
||||
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS YAP4PY_SETUP)
|
||||
|
||||
|
||||
|
@ -4,14 +4,23 @@ import ctypes
|
||||
import glob
|
||||
import os.path
|
||||
import sys
|
||||
import platform
|
||||
|
||||
global yap_lib_path
|
||||
yap_lib_path = os.path.dirname(__file__)
|
||||
|
||||
|
||||
def load( dll ):
|
||||
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
|
||||
dll = os.path.abspath(dll)
|
||||
ctypes.CDLL(dll, mode=ctypes.RTLD_GLOBAL)
|
||||
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( dll ):
|
||||
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
|
||||
dll = os.path.abspath(dll)
|
||||
ctypes.CDLL(dll, mode=ctypes.RTLD_GLOBAL)
|
||||
|
||||
load('libYap*')
|
||||
load('libgcc*')
|
||||
load('libstdc*')
|
||||
load('libsinpt*')
|
||||
load('libgmp*')
|
||||
|
@ -60,14 +60,7 @@ elif platform.system() == 'Windows':
|
||||
my_extra_link_args = ['-Wl,-export-all-symbols','-Wl,-enable-auto-import','-Wl,-enable-runtime-pseudo-relocs']
|
||||
|
||||
cplus = ['']
|
||||
bpy2yap = ['${CMAKE_SOURCE_DIR}/packages/python/python.c',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python/pl2py.c',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python/pybips.c',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python/py2pl.c',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python/pl2pl.c',
|
||||
'${CMAKE_SOURCE_DIR}/packages/python/pypreds.c'
|
||||
]
|
||||
|
||||
bpy2yap = \
|
||||
native_sources = ['yap.i']
|
||||
here = path.abspath(path.dirname(__file__))
|
||||
|
||||
@ -80,7 +73,8 @@ extensions = [Extension('_yap', native_sources,
|
||||
('_GNU_SOURCE', '1'),
|
||||
('YAP_PYTHON', '1')],
|
||||
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}'],
|
||||
swig_opts=['-modern', '-c++', '-py3', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
|
||||
swig_opts=['-modern', '-c++', '-py3',
|
||||
'-DX_API', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
|
||||
'-I${CMAKE_SOURCE_DIR}/H', '-I${CMAKE_SOURCE_DIR}/H/generated',
|
||||
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
|
||||
library_dirs=['../../..', '../../../CXX', '../../packages/python', "${dlls}", "${bindir}", '.'],
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
|
||||
%{
|
||||
|
||||
#include <cmath>
|
||||
#include <gmpxx.h>
|
||||
extern "C"{
|
||||
|
Reference in New Issue
Block a user