This commit is contained in:
Vitor Santos Costa 2016-08-22 19:18:33 -05:00
parent f78ddb6724
commit c4544f042d
5 changed files with 29 additions and 23 deletions

View File

@ -16,6 +16,8 @@ foreach (i 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
break()
endif()
endforeach()
else()
set (Python_ADDITIONAL_VERSIONS 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.8 2.6 2.5)
endif()
find_package(PythonInterp)

View File

@ -8,14 +8,12 @@ include(FindPythonModule)
set (PYTHON_SOURCES
python.c pl2py.c pybips.c py2pl.c pl2pl.c pypreds.c )
add_library (libpython SHARED ${PYTHON_SOURCES})
add_library (YAPPython SHARED ${PYTHON_SOURCES})
set (PYTHON_HEADERS
python.h)
configure_file ("setup.py.cmake" "setup.py" )
target_link_libraries(libpython libYap ${PYTHON_LIBRARIES})
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARIES})
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
@ -23,11 +21,11 @@ add_custom_target ( YAPex ALL
COMMAND ${PYTHON_EXECUTABLE} setup.py build -f
DEPENDS yapex.py )
set_target_properties (libpython PROPERTIES PREFIX "")
# set_target_properties (YAPPython PROPERTIES PREFIX "")
include_directories (${PYTHON_INCLUDE_DIRS})
install(TARGETS libpython
install(TARGETS YAPPython
LIBRARY DESTINATION ${dlls}
ARCHIVE DESTINATION ${dlls}
)
@ -36,6 +34,8 @@ add_custom_target ( YAPex ALL
DESTINATION ${libpl}
)
configure_file ("setup.py.cmake" "setup.py" )
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install -f
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")

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(libpython), init_python), now ).
:- initialization( use_foreign_library(foreign(libpYAPPython), init_python), now ).

View File

@ -16,6 +16,7 @@ if (PYTHONLIBS_FOUND)
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES SWIG_FLAGS "-includeall")
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTY SWIG_MODULE_NAME libPy2YAP )
configure_file ("setup.py.cmake" "setup.py" )
@ -23,9 +24,11 @@ if (PYTHONLIBS_FOUND)
#SET( CMAKE_SWIG_OUTDIR "yap" )
SWIG_ADD_MODULE(yap python ../yap.i)
SWIG_LINK_LIBRARIES(yap ${PYTHON_LIBRARIES} Yap++ libYap libpython)
set_target_properties ( ${SWIG_MODULE_yap_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}' ) )"
# OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
@ -41,7 +44,7 @@ if (PYTHONLIBS_FOUND)
add_custom_target ( py2yap ALL
COMMAND ${PYTHON_EXECUTABLE} setup.py bdist
DEPENDS yap.py )
DEPENDS yap.py ${SWIG_MODULE_Py2YAP_REAL_NAME} )
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install
@ -77,6 +80,11 @@ if (PYTHONLIBS_FOUND)
endif ()
install(TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
LIBRARY DESTINATION ${dlls}
ARCHIVE DESTINATION ${dlls}
)
# add_subdirectory ( examples )
else ()
message(STATUS "Not building python bindings")

View File

@ -3,27 +3,23 @@ from distutils.core import setup, Extension
setup(
name = "yap",
version = "0.1",
ext_modules=[Extension('_yap', [ 'yapPYTHON_wrap.cxx',
'${CMAKE_SOURCE_DIR}/packages/python/pl2py.c',
'${CMAKE_SOURCE_DIR}/packages/python/python.c',
'${CMAKE_SOURCE_DIR}/packages/python/py2pl.c',
'${CMAKE_SOURCE_DIR}/packages/python/pl2pl.c',
'${CMAKE_SOURCE_DIR}/packages/python/pypreds.c',
'${CMAKE_SOURCE_DIR}/packages/python/pybips.c'],
ext_modules=[Extension('_yap', ['${CMAKE_SOURCE_DIR}/packages/swig/python/_yap.c'],
define_macros = [('MAJOR_VERSION', '1'),
('MINOR_VERSION', '0'),
('_YAP_NOT_INSTALLED_', '1')],
swig_opts=['-py3', '-c++','-I${CMAKE_SOURCE_DIR}/CXX'],
runtime_library_dirs=['/usr/local/lib'],
library_dirs=['../../..','../../../CXX'],
libraries=['Yap++','Yap'],
runtime_library_dirs=['${dlls}'],
library_dirs=['../../..','../../../CXX',
'../../python',
'.'],
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', '.']
'${CMAKE_SOURCE_DIR}/CXX', '.'],
extra_objects = ['${CMAKE_CURRENT_BINARY_DIR}/_Py2YAP${CMAKE_SHARED_MODULE_SUFFIX}' ]
)],
py_modules = ['yap']
)