diff --git a/.github/workflows/macos-homebrew-build.yml b/.github/workflows/macos-homebrew-build.yml index 5e2c2580b7..47f429d603 100644 --- a/.github/workflows/macos-homebrew-build.yml +++ b/.github/workflows/macos-homebrew-build.yml @@ -62,7 +62,7 @@ jobs: -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -DCMAKE_RANLIB=/usr/bin/ranlib - -DPYTHON_EXECUTABLE=/usr/local/opt/python@3.11/bin/python3.11 + -DPython3_EXECUTABLE=/usr/local/opt/python@3.11/bin/python3.11 -DTALIPOT_BUILD_CORE_ONLY=ON -DTALIPOT_BUILD_TESTS=ON -DTALIPOT_BUILD_DOC=OFF diff --git a/.github/workflows/macos-macports-build.yml b/.github/workflows/macos-macports-build.yml index 27e0e95572..ec3b9a25d8 100644 --- a/.github/workflows/macos-macports-build.yml +++ b/.github/workflows/macos-macports-build.yml @@ -83,7 +83,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_C_COMPILER=/opt/local/bin/clang-mp-${{ env.CLANG_VERSION }} -DCMAKE_CXX_COMPILER=/opt/local/bin/clang++-mp-${{ env.CLANG_VERSION }} - -DPYTHON_EXECUTABLE=/opt/local/bin/python${{ env.PYTHON_VERSION }} + -DPython3_EXECUTABLE=/opt/local/bin/python${{ env.PYTHON_VERSION }} -DTALIPOT_BUILD_TESTS=ON -DTALIPOT_USE_CCACHE=ON -DTALIPOT_BUILD_DOC=OFF diff --git a/.github/workflows/macos-macports-wheels-build.yml b/.github/workflows/macos-macports-wheels-build.yml index 82aae06b7b..cdf8557c14 100644 --- a/.github/workflows/macos-macports-wheels-build.yml +++ b/.github/workflows/macos-macports-wheels-build.yml @@ -76,9 +76,6 @@ jobs: graphviz - name: Install Python versions to build wheels against run: | - curl -LO https://www.python.org/ftp/python/3.7.6/python-3.7.6-macosx10.9.pkg - sudo installer -pkg python-3.7.6-macosx10.9.pkg -target / - sudo /Library/Frameworks/Python.framework/Versions/3.7/bin/pip3 install wheel curl -LO https://www.python.org/ftp/python/3.8.1/python-3.8.1-macosx10.9.pkg sudo installer -pkg python-3.8.1-macosx10.9.pkg -target / sudo /Library/Frameworks/Python.framework/Versions/3.8/bin/pip3 install wheel @@ -106,7 +103,9 @@ jobs: -DCMAKE_CXX_COMPILER=/opt/local/bin/clang++-mp-${{ env.CLANG_VERSION }} \ -DTALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET=ON \ -DTALIPOT_PYTHON_TEST_WHEEL_SUFFIX=a2.dev${{ env.DEV_VERSION }}\ - -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/$py3Version/bin/python3 \ + -DPython3_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/$py3Version/bin/python3 \ + -DPython3_INCLUDE_DIRS=/Library/Frameworks/Python.framework/Versions/$py3Version/include/python$py3Version \ + -DPython3_LIBRARIES=/Library/Frameworks/Python.framework/Versions/$py3Version/lib/libpython$py3Version.dylib \ -DTALIPOT_USE_CCACHE=ON \ -DTALIPOT_BUILD_CORE_ONLY=ON \ -DTALIPOT_BUILD_DOC=OFF diff --git a/.github/workflows/windows-mingw64-build.yml b/.github/workflows/windows-mingw64-build.yml index a60c1b5aba..738d7221d1 100644 --- a/.github/workflows/windows-mingw64-build.yml +++ b/.github/workflows/windows-mingw64-build.yml @@ -64,6 +64,7 @@ jobs: -DCMAKE_BUILD_TYPE=Release -DCMAKE_NEED_RESPONSE=ON -DCMAKE_INSTALL_PREFIX=$PWD/install + -DPython3_EXECUTABLE=/mingw64/bin/python3 -DTALIPOT_BUILD_TESTS=ON -DTALIPOT_USE_CCACHE=ON .. - name: Talipot build diff --git a/.github/workflows/windows-wheels-build.yml b/.github/workflows/windows-wheels-build.yml index fd575f2ea0..476b294873 100644 --- a/.github/workflows/windows-wheels-build.yml +++ b/.github/workflows/windows-wheels-build.yml @@ -100,7 +100,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=$PWD/install -DTALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET=ON -DTALIPOT_PYTHON_TEST_WHEEL_SUFFIX=a2.dev${{ env.DEV_VERSION }} - -DPYTHON_EXECUTABLE=$(cygpath -u "${{ steps.python-install.outputs.python-path }}") + -DPython3_EXECUTABLE=$(cygpath -u "${{ steps.python-install.outputs.python-path }}") -DTALIPOT_USE_CCACHE=ON -DTALIPOT_BUILD_CORE_ONLY=ON -DTALIPOT_BUILD_DOC=OFF diff --git a/CMakeLists.txt b/CMakeLists.txt index b9e247cb36..7a639cb6d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.10) +CMAKE_MINIMUM_REQUIRED(VERSION 3.16) # Remove CMake warnings related to Qt5 IF(POLICY CMP0020) diff --git a/appveyor/appveyor_macos.sh b/appveyor/appveyor_macos.sh index af1064add2..426ca980db 100644 --- a/appveyor/appveyor_macos.sh +++ b/appveyor/appveyor_macos.sh @@ -60,7 +60,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$PWD/install \ -DCMAKE_C_COMPILER=/opt/local/bin/clang-mp-${CLANG_VERSION} \ -DCMAKE_CXX_COMPILER=/opt/local/bin/clang++-mp-${CLANG_VERSION} \ - -DPYTHON_EXECUTABLE=/opt/local/bin/python${PYTHON_VERSION} \ + -DPython3_EXECUTABLE=/opt/local/bin/python${PYTHON_VERSION} \ -DTALIPOT_BUILD_TESTS=ON \ -DTALIPOT_USE_CCACHE=ON \ -DTALIPOT_BUILD_DOC=$TALIPOT_BUILD_DOC \ diff --git a/appveyor/appveyor_msvc.bat b/appveyor/appveyor_msvc.bat index 4794d78197..d92113a95b 100644 --- a/appveyor/appveyor_msvc.bat +++ b/appveyor/appveyor_msvc.bat @@ -104,7 +104,7 @@ cmake -G "%CMAKE_VS_GENERATOR%"^ -DCMAKE_INCLUDE_PATH="%INCLUDE_PATH%"^ -DCMAKE_LIBRARY_PATH="%LIBRARY_PATH%"^ -DCMAKE_PREFIX_PATH="%QT_DIR%"^ - -DPYTHON_EXECUTABLE="%PYTHON_HOME%/python.exe"^ + -DPython3_EXECUTABLE="%PYTHON_HOME%/python.exe"^ -DTALIPOT_BUILD_CORE_ONLY=%TALIPOT_BUILD_CORE_ONLY%^ -DTALIPOT_USE_QT6=ON^ -DTALIPOT_BUILD_DOC=OFF^ diff --git a/bundlers/linux/talipot_appimage_centos_build.sh b/bundlers/linux/talipot_appimage_centos_build.sh index fd1bbe6978..191d50de83 100644 --- a/bundlers/linux/talipot_appimage_centos_build.sh +++ b/bundlers/linux/talipot_appimage_centos_build.sh @@ -73,7 +73,7 @@ cd /talipot/build cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$PWD/install \ - -DPYTHON_EXECUTABLE=/usr/local/bin/python$PYTHON_VERSION \ + -DPython3_EXECUTABLE=/usr/local/bin/python$PYTHON_VERSION \ -DTALIPOT_USE_CCACHE=ON \ -DTALIPOT_BUILD_FOR_APPIMAGE=ON \ -DTALIPOT_BUILD_TESTS=ON \ diff --git a/bundlers/linux/talipot_python_wheels_manylinux_build.sh b/bundlers/linux/talipot_python_wheels_manylinux_build.sh index 32822201e2..2fcfc0f002 100644 --- a/bundlers/linux/talipot_python_wheels_manylinux_build.sh +++ b/bundlers/linux/talipot_python_wheels_manylinux_build.sh @@ -11,9 +11,6 @@ yum -y install zlib-devel libzstd-devel yajl-devel qhull-devel graphviz-devel li # required to build upstream python cffi from pip yum -y install libffi-devel -# ensure python library from based system is present, even if we do -# not link to it, as cmake will fail to find PythonLibs otherwise -yum -y install python36-devel JSON=$(curl -s 'https://test.pypi.org/pypi/talipot/json') LAST_VERSION=$(echo $JSON | python3 -c " @@ -81,7 +78,7 @@ do cmake ${TALIPOT_SRC} \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/tmp/talipot_install \ - -DPYTHON_EXECUTABLE=${CPYBIN}/python \ + -DPython3_EXECUTABLE=${CPYBIN}/python \ -DTALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET=ON \ -DTALIPOT_PYTHON_TEST_WHEEL_SUFFIX=a2.dev$DEV_VERSION \ -DTALIPOT_BUILD_DOC=OFF \ diff --git a/bundlers/mac/talipot_python_wheels_macos_build.sh b/bundlers/mac/talipot_python_wheels_macos_build.sh index 472afdb18b..8bcdecb950 100644 --- a/bundlers/mac/talipot_python_wheels_macos_build.sh +++ b/bundlers/mac/talipot_python_wheels_macos_build.sh @@ -78,7 +78,7 @@ do -DCMAKE_CXX_COMPILER=/opt/local/bin/clang++-mp-${CLANG_VERSION} \ -DTALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET=ON \ -DTALIPOT_PYTHON_TEST_WHEEL_SUFFIX=a2.dev$DEV_VERSION \ - -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/$py3Version/bin/python3 \ + -DPython3_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/$py3Version/bin/python3 \ -DTALIPOT_USE_CCACHE=ON \ -DTALIPOT_BUILD_CORE_ONLY=ON \ -DTALIPOT_BUILD_DOC=OFF diff --git a/bundlers/win/talipot_python_wheels_win_amd64.sh b/bundlers/win/talipot_python_wheels_win_amd64.sh index 83c44b4554..9dfced61b8 100644 --- a/bundlers/win/talipot_python_wheels_win_amd64.sh +++ b/bundlers/win/talipot_python_wheels_win_amd64.sh @@ -55,7 +55,7 @@ do -DTALIPOT_BUILD_DOC=OFF \ -DTALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET=ON \ -DTALIPOT_PYTHON_TEST_WHEEL_SUFFIX=a2.dev${DEV_VERSION} \ - -DPYTHON_EXECUTABLE=/c/Python$pyVersion-x64/python.exe \ + -DPython3_EXECUTABLE=/c/Python$pyVersion-x64/python.exe \ -DTALIPOT_USE_CCACHE=ON .. make -j4 test-wheel diff --git a/cmake/FindSIP.cmake b/cmake/FindSIP.cmake index 6a733b8259..80192e30cc 100644 --- a/cmake/FindSIP.cmake +++ b/cmake/FindSIP.cmake @@ -1,3 +1,7 @@ +FIND_PACKAGE(Python3 REQUIRED) + +SET(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + FIND_FILE( find_sip_py FindSIP.py PATHS ${CMAKE_MODULE_PATH} diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake index 9cd218ccbe..7a4f68c8f8 100644 --- a/cmake/FindSphinx.cmake +++ b/cmake/FindSphinx.cmake @@ -1,8 +1,6 @@ # Find the Sphinx documentation generator # -# This modules defines -# SPHINX_EXECUTABLE -# SPHINX_FOUND +# This modules defines SPHINX_EXECUTABLE SPHINX_FOUND # ============================================================================= # Copyright 2002-2009 Kitware, Inc. Copyright 2009-2011 Peter Colberg @@ -17,45 +15,43 @@ # (To distribute this file outside of CMake, substitute the full License text # for the above reference.) -FIND_PACKAGE(PythonInterp) - -IF(PYTHON_EXECUTABLE) - - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} --version - OUTPUT_VARIABLE PYTHON_VERSION_RAW - ERROR_VARIABLE PYTHON_VERSION_RAW) - STRING(REPLACE "\n" "" PYTHON_VERSION_RAW "${PYTHON_VERSION_RAW}") - STRING(REGEX MATCH "[0-9]" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_RAW}") - - IF(WIN32) - STRING(REPLACE "python.exe" "Scripts/" SPHINX_PATH "${PYTHON_EXECUTABLE}") - ELSEIF(LINUX) - GET_FILENAME_COMPONENT(PYTHON_EXECUTABLE_PATH "${PYTHON_EXECUTABLE}" - DIRECTORY) - # remove final /bin component - GET_FILENAME_COMPONENT(PYTHON_EXECUTABLE_PATH "${PYTHON_EXECUTABLE_PATH}" - DIRECTORY) - SET(SPHINX_PATH "/usr/share/sphinx/scripts/python${PYTHON_VERSION_MAJOR}/" - "${PYTHON_EXECUTABLE_PATH}") - ELSE() - STRING(REGEX MATCH "[0-9].[0-9]" PYTHON_VERSION_MAJOR_MINOR - "${PYTHON_VERSION_RAW}") - SET(SPHINX_PATH "$ENV{HOME}/Library/Python/${PYTHON_VERSION_MAJOR_MINOR}") - ENDIF() - - FIND_PROGRAM( - SPHINX_EXECUTABLE - NAMES sphinx-build${PYTHON_VERSION_MAJOR} sphinx-build - HINTS ${SPHINX_PATH} - PATHS /usr /usr/local /opt/local - PATH_SUFFIXES bin - DOC "Sphinx documentation generator") - - INCLUDE(FindPackageHandleStandardArgs) - - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) - - MARK_AS_ADVANCED(SPHINX_EXECUTABLE) - -ENDIF(PYTHON_EXECUTABLE) +FIND_PACKAGE(Python3 REQUIRED) + +SET(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + +EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} --version + OUTPUT_VARIABLE PYTHON_VERSION_RAW + ERROR_VARIABLE PYTHON_VERSION_RAW) +STRING(REPLACE "\n" "" PYTHON_VERSION_RAW "${PYTHON_VERSION_RAW}") +STRING(REGEX MATCH "[0-9]" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_RAW}") + +IF(WIN32) + STRING(REPLACE "python.exe" "Scripts/" SPHINX_PATH "${PYTHON_EXECUTABLE}") +ELSEIF(LINUX) + GET_FILENAME_COMPONENT(PYTHON_EXECUTABLE_PATH "${PYTHON_EXECUTABLE}" + DIRECTORY) + # remove final /bin component + GET_FILENAME_COMPONENT(PYTHON_EXECUTABLE_PATH "${PYTHON_EXECUTABLE_PATH}" + DIRECTORY) + SET(SPHINX_PATH "/usr/share/sphinx/scripts/python${PYTHON_VERSION_MAJOR}/" + "${PYTHON_EXECUTABLE_PATH}") +ELSE() + STRING(REGEX MATCH "[0-9].[0-9]" PYTHON_VERSION_MAJOR_MINOR + "${PYTHON_VERSION_RAW}") + SET(SPHINX_PATH "$ENV{HOME}/Library/Python/${PYTHON_VERSION_MAJOR_MINOR}") +ENDIF() + +FIND_PROGRAM( + SPHINX_EXECUTABLE + NAMES sphinx-build${PYTHON_VERSION_MAJOR} sphinx-build + HINTS ${SPHINX_PATH} + PATHS /usr /usr/local /opt/local + PATH_SUFFIXES bin + DOC "Sphinx documentation generator") + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) + +MARK_AS_ADVANCED(SPHINX_EXECUTABLE) diff --git a/cmake/TalipotPython.cmake b/cmake/TalipotPython.cmake index 08d8f00862..f8d71fc0e8 100644 --- a/cmake/TalipotPython.cmake +++ b/cmake/TalipotPython.cmake @@ -1,7 +1,21 @@ # After finding the Python interpreter, try to find if SIP and its dev tools are # installed on the host system. If not, compile the SIP version located in # thirdparty. -FIND_PACKAGE(PythonInterp 3 REQUIRED) + +IF(LINUX AND TALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET) + SET(PYTHON_COMPONENTS Interpreter) +ELSE(LINUX AND TALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET) + SET(PYTHON_COMPONENTS Interpreter Development) +ENDIF(LINUX AND TALIPOT_ACTIVATE_PYTHON_WHEEL_TARGET) + +FIND_PACKAGE( + Python3 + COMPONENTS ${PYTHON_COMPONENTS} + REQUIRED) + +SET(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) +SET(PYTHON_LIBRARY ${Python3_LIBRARIES}) +SET(PYTHON_INCLUDE_DIR ${Python3_INCLUDE_DIRS}) EXECUTE_PROCESS( COMMAND ${PYTHON_EXECUTABLE} --version @@ -55,11 +69,9 @@ ELSEIF(LINUX) SET(CMAKE_LIBRARY_PATH ${PYTHON_HOME_PATH}/../lib ${CMAKE_LIBRARY_PATH}) ENDIF(WIN32) -FIND_PACKAGE(PythonLibs REQUIRED) - -IF(NOT WIN32) +IF(NOT WIN32 AND PYTHON_LIBRARY) GET_FILENAME_COMPONENT(PYTHON_LIB_PATH ${PYTHON_LIBRARY} PATH) -ENDIF(NOT WIN32) +ENDIF(NOT WIN32 AND PYTHON_LIBRARY) IF(MINGW) # Check if Python is provided by MSYS2 (it is compiled with GCC in that case