From 93577a7481534c9a2d6ee48c40a165d692b69ab2 Mon Sep 17 00:00:00 2001 From: vscosta Date: Sat, 2 Sep 2017 23:47:14 +0100 Subject: [PATCH] trying to make sense of setuptools --- .gitignore | 3 + packages/python/swig/CMakeLists.txt | 110 ++++++++++++++++------------ packages/python/swig/MANIFEST.in | 5 +- packages/python/swig/distutils.cfg | 6 ++ packages/python/swig/setup.py.in | 12 ++- 5 files changed, 86 insertions(+), 50 deletions(-) create mode 100644 packages/python/swig/distutils.cfg diff --git a/.gitignore b/.gitignore index 418298781..fcab32bfd 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,6 @@ cmake/compile_commands.json cmake/cudd_config.h cmake/docs/Doxyfile + +*.stackdump +*.gz \ No newline at end of file diff --git a/packages/python/swig/CMakeLists.txt b/packages/python/swig/CMakeLists.txt index 6bc4ae91b..96661d8c1 100644 --- a/packages/python/swig/CMakeLists.txt +++ b/packages/python/swig/CMakeLists.txt @@ -5,8 +5,39 @@ include(FindPythonModule) -set (PROLOG_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yapi.yap ${CMAKE_CURRENT_SOURCE_DIR}/jupyter.yap) -set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_SOURCE_DIR}/__main__.py) +set (PROLOG_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yapi.yap + ${CMAKE_CURRENT_SOURCE_DIR}/jupyter.yap) +set (PYTHON_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/yapi.py + ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__init__.py + ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__main__.py + ) + + +set (PL ${pl_library} ${PROLOG_SOURCES} ) + + +set (python_dlls + $ + $ + $ + $ + $ + $ + $ + $ + $ + ) +if (TARGET real) + list(APPEND python_dlls $ + ) +endif() +if (NOT WIN32) + list(APPEND python_dlls $ + ) +endif() + + file(RELATIVE_PATH RELATIVE_SOURCE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) @@ -24,7 +55,7 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_MODULE_NAME yap) if (WIN32) -set (SYS_DLLS ${GMP_LIBRARIES} c:/msys64/mingw64/bin/libgmp-10.dll) +#set (SYS_DLLS ${GMP_LIBRARIES} c:/msys64/mingw64/bin/libgmp-10.dll) endif() @@ -39,61 +70,50 @@ endif() # ) - set (python_dlls $ - $ - $ - $ - $ - $ - $ - ) - if (TARGET real) - list(APPEND python_dlls $ - ) - endif() - if (NOT WIN32) - list(APPEND python_dlls $ $ - ) - 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 ${CMAKE_BINARY_DIR}/config.h ${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 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 - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os + 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 + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os ) + +add_custom_COMMAND( OUTPUT yap4py/prolog/lists,yap + COMMAND ${CMAKE_COMMAND} -E copy ${PL} yap4py/prolog + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS YAP4PY_SETUP_DIRS ${PL} ) + +add_custom_COMMAND( OUTPUT yap4py/prolog/pl/boot.yap + COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} yap4py/prolog/pl + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS YAP4PY_SETUP_DIRS ${pl_boot_library} ) + +add_custom_COMMAND( OUTPUT yap4py/prolog/os/yio.yap + COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} yap4py/prolog/os + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS YAP4PY_SETUP_DIRS ${pl_os_library} ) + +add_custom_COMMAND( OUTPUT yap4py/startup.yss + COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${python_dlls} ${CMAKE_BINARY_DIR}/startup.yss yap4py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS YAP4PY_SETUP_DIRS STARTUP ) + add_custom_target( YAP4PY ALL - COMMAND ${PYTHON_EXECUTABLE} -m pip uninstall -y YAP4PY COMMAND ${SWIG_EXECUTABLE} -python -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}/OPTYap -I../../.. -o yap_wrap.cpp yap.i - COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel + COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_conda WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -DEPENDS YAP4PY_SETUP) +DEPENDS yap4py/yapi.py yap4py/prolog/lists,yap yap4py/prolog/pl/boot.yap yap4py/startup.yss yap4py/prolog/os/yio.yap ) - -install(CODE "execute_process( - COMMAND ${PYTHON_EXECUTABLE} -m pip install --force --no-index -f packages/python/swig/dist YAP4PY - WORKING_DIRECTORY ${CMAKE_BINARY_DIR})" - DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${dlls} ) +install(CODE "execute_process" + COMMAND ${PYTHON_EXECUTABLE} -m pip install --force --no-index -f packages/python/swig/dist YAP4PY + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} +DEPENDS YAP4PY ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${dlls} ) install(FILES ${PROLOG_SOURCES} DESTINATION ${libpl}) - - if (WITH_DOCS AND DOXYGEN_FOUND) +if (WITH_DOCS AND DOXYGEN_FOUND) set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND}) diff --git a/packages/python/swig/MANIFEST.in b/packages/python/swig/MANIFEST.in index f7f1f5258..93cc597b6 100644 --- a/packages/python/swig/MANIFEST.in +++ b/packages/python/swig/MANIFEST.in @@ -1,8 +1,9 @@ -# include COPYING.md # include CONTRIBUTING.md include README.md -recursive-include * *.* +recursive-include yap4py/prolog *.* +recursive-include html *.* +recursive-include docs *.* # Documentation graft docs diff --git a/packages/python/swig/distutils.cfg b/packages/python/swig/distutils.cfg new file mode 100644 index 000000000..2e2c8fd39 --- /dev/null +++ b/packages/python/swig/distutils.cfg @@ -0,0 +1,6 @@ +[build] +compiler=mingw32 + +[build_ext] +compiler=mingw32 + diff --git a/packages/python/swig/setup.py.in b/packages/python/swig/setup.py.in index 5f1722c28..e7db1110c 100644 --- a/packages/python/swig/setup.py.in +++ b/packages/python/swig/setup.py.in @@ -84,9 +84,9 @@ extensions = [Extension('_yap', native_sources, '-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', '..', "${dlls}", "${bindir}", '.'], + library_dirs=['../../..', '../../../CXX', '..', "${dlls}", "${bindir}", 'c:/Anaconda3'], extra_link_args=my_extra_link_args, - libraries=['Yap','${PYTHON_LIBRARIES}','${GMP_LIBRARIES}']+win_libs+local_libs, + libraries=['Yap','YAPPython','python3','yap']+win_libs+local_libs, include_dirs=['../../..', '${GMP_INCLUDE_DIRS}', '${CMAKE_SOURCE_DIR}/H', @@ -112,7 +112,7 @@ def visit(d0, pls): package_data = { - '': visit('.', []) + 'yap4py.prolog': """${PL}""".split(sep=";") } version_ns = {'__version__': '6.3.5', 'minor-version': '6', 'minor-version': '3', 'patch': '5'} @@ -125,6 +125,12 @@ setup_args = dict( py_modules=['yap'], package_data=package_data, include_package_data=True, + requirements=[ + 'm2w64-gmp', + 'm2-msys2-keyring', + 'm2-msys2-launcher-git', + 'm2-msys2-runtime', + ], description="YAP in Python", author='YAP Development Team', author_email='ipython-dev@scipy.org',