This commit is contained in:
Vitor Santos Costa 2016-08-23 01:00:14 -05:00
parent 9ed1546ee6
commit 23c1c2d4d7
5 changed files with 25 additions and 15 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 ).

View File

@ -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

View File

@ -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']
)