This commit is contained in:
Vítor Santos Costa 2019-04-03 10:30:12 +01:00
parent 10307c27fe
commit 03232f53ce
7 changed files with 60 additions and 43 deletions

View File

@ -731,6 +731,12 @@ MY_set_target_properties(libYap
# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py)
if (WITH_PYTHON AND PYTHONLIBS_FOUND AND SWIG_FOUND)
if (CONDA)
set(bdist bdist_conda)
else()
set(bdist bdist_wheel)
endif()
set( ENV{PYTHONPATH} ${CMAKE_BINARY_DIR}/packages/python/swig:${CMAKE_BINARY_DIR}/packages/python/yap_kernel:. )
add_subdirectory(packages/python/swig)

View File

@ -11,7 +11,6 @@ ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/os ${CMAKE_SOURCE_DIR}/H ${CMAKE
#talk to python.pl
add_library(YAPPython pyload.c ${PYTHON_HEADERS} )
if (WIN32)
add_library (Py4YAP OBJECT ${PYTHON_SOURCES} ${PYTHON_HEADERS})
else()

View File

@ -29,9 +29,6 @@ configure_file(yap4py/__init__.py.in yap4py/__init__.py)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/include
)
SET(SWIG_SOURCES
${CMAKE_SOURCE_DIR}/packages/swig/yap.i
)
@ -46,36 +43,37 @@ INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/i
# LIBRARY DESTINATION ${PYTHON_MODULE_PATH}
# )
if (CONDA)
set(bdist bdist_conda)
else()
set(bdist bdist_wheel)
endif()
add_custom_target( YAP4PY ALL
COMMAND ${SWIG_EXECUTABLE} -c++ -python -O -py3 -module "yap" -addextern -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/H/generated -I${CMAKE_SOURCE_DIR}/include
-I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/utf8proc -I.././.. -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/packages/python
-outdir ${CMAKE_CURRENT_BINARY_DIR}/yap4py -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx -oh ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh ${SWIG_SOURCES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${SWIG_SOURCES} Py4YAP YAP++ yap4py/yapi.cpp YAP4PY_PY
)
add_custom_command( OUTPUT yap4py/yapi.cpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/CXX/yapi.cpp ${CMAKE_CURRENT_BINARY_DIR}/yap4py
DEPENDS ${CMAKE_SOURCE_DIR}/CXX/yapi.cpp
)
add_custom_command( OUTPUT YAP4PY_PY
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
DEPENDS ${PYTHON_SOURCES}
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh
COMMAND ${SWIG_EXECUTABLE} -c++ -python -O -py3 -module "yap" -addextern -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/H/generated -I${CMAKE_SOURCE_DIR}/include
-I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/utf8proc -I.././.. -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/packages/python
-outdir ${CMAKE_CURRENT_BINARY_DIR}/yap4py -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx -oh ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh ${SWIG_SOURCES}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${SWIG_SOURCES} yap4py/yapi.cpp
)
install(CODE "execute_process(
add_custom_target( YAP4PY ALL
DEPENDS ${CMAKE_SOURCE_DIR}/CXX/yapi.cpp Py4YAP YAP++ yap4py/yapi.cpp ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh
)
add_custom_command( TARGET YAP4PY
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist ${bdist}
DEPENDS ${CMAKE_SOURCE_DIR}/CXX/yapi.cpp Py4YAP YAP++ yap4py/yapi.cpp YAP4PY_PY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh ${PYTHON_SOURCES} Py4YAP STARTUP libYap
)
install(CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${YAP_INSTALL_LIBDIR} )
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
install(FILES ${YAP4PY_PL} DESTINATION ${YAP_INSTALL_DATADIR} )

View File

@ -1,6 +1,10 @@
import readline
import copy
try:
from yap4py.yap import *
except Exception as e:
print(e)
exit(0)
from yap4py.systuples import python_query, show_answer, library, prolog_library, v0, compile, namedtuple
from os.path import join, dirname

View File

@ -1,7 +1,7 @@
set (PYTHON_SOURCES
core/yap_kernel/__init__.py
core/yap_kernel/getipython.py
core/__init__.py
#core/yap_kernel/__init__.py
#core/yap_kernel/getipython.py
#core/__init__.py
_version.py
yap_kernel/datapub.py
yap_kernel/serialize.py
@ -62,7 +62,7 @@ yap_kernel/pylab/__init__.py
yap_kernel/__main__.py
yap_kernel.py
kernelspec.py
__init__.py
#__init__.py
yap_kernel_launcher.py
docs/conf.py
setup.py
@ -431,17 +431,15 @@ endforeach()
add_custom_target(YAP_KERNEL ALL
add_custom_target(YAP_KERNEL
ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build sdist bdist
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${OUTS} YAP4PY
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} sdist ${bdist}
)
set(REAL_SOURCES real.c)
install(CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed --no-deps .
COMMAND ${PYTHON_EXECUTABLE} -m pip install ${PYTHON_USER_INSTALL} --ignore-installed .
COMMAND ${PYTHON_EXECUTABLE} -m yap_kernel.kernelspec
ERROR_VARIABLE setupErr
OUTPUT_VARIABLE setupOut

View File

@ -34,12 +34,20 @@ import os
import shutil
from distutils.core import setup
from glob import glob
from shutil import copy
pjoin = os.path.join
here = os.path.abspath(os.path.dirname(__file__))
packages = ['yap_kernel','yap_ipython']
# pkg_root = pjoin(here, name)
try:
copy(glob(pjoin(here,"../swig/build/lib*/_yap*"))[0],here)
copy(glob(pjoin(here,"../../../libYap*"))[-1],here)
except:
pass
for d, _, _ in os.walk(pjoin(here, 'yap_kernel')):
if os.path.exists(pjoin(d, '__init__.py')):
packages.append(d[len(here)+1:].replace(os.path.sep, '.'))

View File

@ -14,6 +14,7 @@ name = 'yap_kernel'
#-----------------------------------------------------------------------------
import sys
import os
v = sys.version_info
if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
@ -28,10 +29,13 @@ PY3 = (sys.version_info[0] >= 3)
#-----------------------------------------------------------------------------
import os
from glob import glob
from glob import globx
from shutil import copy
from distutils.core import setup
copy(glob("../swig/build/lib/_yap*")[0],"../swig/yap4py")
copy(glob("../../libYap*")[-1],"../swig/yap4py")
packages = ["${CMAKE_CURRENT_SOURCE_DIR}"]
version_ns = {}