win python support

This commit is contained in:
Vitor Santoss Costa 2017-06-14 12:34:12 +01:00
parent e68630cd8a
commit 3a06d4fecb
8 changed files with 36 additions and 38 deletions

View File

@ -34,15 +34,8 @@ add_to_group( pl_library PYTHON_PL )
#set_target_properties (YAPPython PROPERTIES PREFIX "")
IF(WIN32)
install(TARGETS YAPPython
LIBRARY DESTINATION ${libdir}
RUNTIME DESTINATION ${bindir}
ARCHIVE DESTINATION ${libdir} )
else()
install(TARGETS YAPPython
LIBRARY DESTINATION ${dlls}
RUNTIME DESTINATION ${dlls}
ARCHIVE DESTINATION ${dlls} )
endif()

View File

@ -188,6 +188,7 @@ extern install_t install_pypreds(void);
extern install_t install_pl2pl(void);
X_API extern bool init_python(void);
X_API extern bool loadt_python(void);
X_API extern bool do_init_python(void);
extern PyObject PyInit_yap(void);

View File

@ -1,10 +1,16 @@
#include "py4yap.h"
X_API bool init_python(void) {
return true;
}
X_API bool init_python_dll(void);
X_API bool init_python_dll(void)
{
do_init_python();
return 1;
}
#ifdef _WIN32
#include <windows.h>

View File

@ -151,4 +151,4 @@ add_cwd_to_python :-
python_command("sys.argv = [\"yap\"]").
% done
:- initialization( load_foreign_files([libYAPPython], [], init_python), now ).
:- initialization( load_foreign_files([libYAPPython], [], init_python_dll), now ).

View File

@ -25,12 +25,10 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_MODULE_NAME yap)
if (WIN32)
set (SYS_DLLS ${GMP_LIBRARIES})
find_library( stdc+++ tmp $ENV{PATH})
list (APPEND SYS_DLLS ${tmp})
find_library( winpthread tmp $ENV{PATH})
list (APPEND SYS_DLLS ${tmp})
find_library( gcc_s_seh tmp $ENV{PATH})
list (APPEND SYS_DLLS ${tmp})
message(STATUS "SYS_ = ${tmp}")
set (SYS_DLLS c:/msys64/mingw64/bin/libgmp-10.dll)
endif()
@ -42,7 +40,7 @@ endif()
# RUNTIME DESTINATION ${PYTHON_MODULE_PATH}
# ARCHIVE DESTINATION ${PYTHON_MODULE_PATH}
# LIBRARY DESTINATION ${PYTHON_MODULE_PATH}
# )x
# )
set (python_dlls $<TARGET_FILE:matrix>
@ -52,10 +50,12 @@ endif()
$<TARGET_FILE:itries>
$<TARGET_FILE:sys>
$<TARGET_FILE:yap_random>
$<TARGET_FILE:YAPPython>
)
if (TARGET real)
list( python_dlls $<TARGET_FILE:real>
list(APPEND python_dlls $<TARGET_FILE:real>
)
message(STATUS "${python_dlls}")
endif()
set (PL ${pl_library} ${PROLOG_SOURCES} )
@ -70,7 +70,6 @@ add_custom_target( YAP4PY_SETUP
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 make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
@ -79,6 +78,7 @@ add_custom_target( YAP4PY_SETUP_DIRS
add_custom_target( YAP4PY ALL
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS YAP4PY_SETUP)

View File

@ -20,7 +20,5 @@ else:
dll = os.path.abspath(dll)
ctypes.CDLL(dll, mode=ctypes.RTLD_GLOBAL)
load('libgcc*')
load('libstdc*')
load('libsinpt*')
load('libgmp*')
load('libYap*')

View File

@ -57,7 +57,7 @@ if platform.system() == 'Darwin':
# or dll in glob('yap/dlls/*'):
# move( dll ,'lib' )
elif platform.system() == 'Windows':
my_extra_link_args = ['-Wl,-export-all-symbols','-Wl,-enable-auto-import','-Wl,-enable-runtime-pseudo-relocs']
my_extra_link_args = ['-Wl,-export-all-symbols']
cplus = ['']
bpy2yap = \
@ -70,8 +70,7 @@ extensions = [Extension('_yap', native_sources,
define_macros=[('MAJOR_VERSION', '1'),
('MINOR_VERSION', '0'),
('_YAP_NOT_INSTALLED_', '1'),
('_GNU_SOURCE', '1'),
('YAP_PYTHON', '1')],
('_GNU_SOURCE', '1')],
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}'],
swig_opts=['-modern', '-c++', '-py3',
'-DX_API', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
@ -79,7 +78,7 @@ extensions = [Extension('_yap', native_sources,
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
library_dirs=['../../..', '../../../CXX', '../../packages/python', "${dlls}", "${bindir}", '.'],
extra_link_args=my_extra_link_args,
libraries=['Yap', '${GMP_LIBRARIES}'],
libraries=['Yap','${PYTHON_LIBRARIES}','${GMP_LIBRARIES}','wsock32','ws2_32'],
include_dirs=['../../..',
'${GMP_INCLUDE_DIRS}',
'${CMAKE_SOURCE_DIR}/H',

View File

@ -1,5 +1,6 @@
%{
#include <cmath>