Skip to content

Commit

Permalink
cmake: Remove use of deprecated PythonInterp and PythonLibs modules
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert committed Sep 6, 2023
1 parent a46e7ce commit 74fa520
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos-homebrew-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/bin/python3.11
-DPython3_EXECUTABLE=/usr/local/opt/[email protected]/bin/python3.11
-DTALIPOT_BUILD_CORE_ONLY=ON
-DTALIPOT_BUILD_TESTS=ON
-DTALIPOT_BUILD_DOC=OFF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos-macports-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/macos-macports-wheels-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ jobs:
run: |
for py3Version in 3.7 3.8 3.9 3.10 3.11
do
rm -f CMakeCache.txt || true
sudo /Library/Frameworks/Python.framework/Versions/$py3Version/bin/pip3 install sip
cmake .. -DCMAKE_BUILD_TYPE=Release \
-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 }} \
-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 \
-DTALIPOT_USE_CCACHE=ON \
-DTALIPOT_BUILD_CORE_ONLY=ON \
-DTALIPOT_BUILD_DOC=OFF
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-mingw64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-wheels-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion appveyor/appveyor_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion appveyor/appveyor_msvc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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^
Expand Down
2 changes: 1 addition & 1 deletion bundlers/linux/talipot_appimage_centos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 1 addition & 4 deletions bundlers/linux/talipot_python_wheels_manylinux_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion bundlers/mac/talipot_python_wheels_macos_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bundlers/win/talipot_python_wheels_win_amd64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions cmake/FindSIP.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FIND_PACKAGE(Python3 REQUIRED)

SET(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})

FIND_FILE(
find_sip_py FindSIP.py
PATHS ${CMAKE_MODULE_PATH}
Expand Down
86 changes: 41 additions & 45 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
22 changes: 17 additions & 5 deletions cmake/TalipotPython.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/external_plugins_build/plugins_src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
CMAKE_MINIMUM_REQUIRED(VERSION 3.16)

PROJECT(TestPlugins)

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/OGDF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.16)
project(OGDF-PROJECT CXX)

set(module_dir "${PROJECT_SOURCE_DIR}/cmake")
Expand Down

0 comments on commit 74fa520

Please sign in to comment.