Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake find_package pythoninterp is deprecated #1112

Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
179dcd4
cmake 3.15 is now required for the feature
VincentRouvreau Jul 30, 2024
03ec06c
Python_ADDITIONAL_VERSIONS is no more used
VincentRouvreau Jul 30, 2024
38798b6
PYTHON_EXECUTABLE renamed Python_EXECUTABLE
VincentRouvreau Jul 30, 2024
ad2c38c
Remove complicated if for python and its documentation management wit…
VincentRouvreau Jul 31, 2024
5cb23a8
Force python interpreter for CMake as it does not use the correct one
VincentRouvreau Aug 5, 2024
ac7b08a
Detect python exe and force it
VincentRouvreau Aug 6, 2024
d3d3d57
Merge master and resolve conflicts
VincentRouvreau Aug 6, 2024
68ff7d8
Forgotten test in trunk merge
VincentRouvreau Aug 6, 2024
db48fe3
Merge master and resolve conflicts in azure-pipeline
VincentRouvreau Aug 27, 2024
90a9743
bad identation
VincentRouvreau Aug 27, 2024
23a393b
code review: add components numpy and dev for cmake to pick up the mo…
VincentRouvreau Aug 27, 2024
c87f437
code review: typo
VincentRouvreau Aug 27, 2024
d4b925e
Bad identation, CI was not launching
VincentRouvreau Aug 27, 2024
6b08d67
Merge branch 'find_package_pythoninterp_deprecated' of github.com:Vin…
VincentRouvreau Aug 27, 2024
d190e7d
code review: Use Python_FIND_REGISTRY and Python_FIND_FRAMEWORK inste…
VincentRouvreau Aug 29, 2024
630094b
code review: find_package( Python COMPONENTS Development ..) and its …
VincentRouvreau Aug 29, 2024
1b4b4fa
code review: rewrite comment to be more consistent to set CMake polic…
VincentRouvreau Aug 29, 2024
78cb0fc
fix comment
VincentRouvreau Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
cmake -DWITH_GUDHI_THIRD_PARTY=OFF -DUSER_VERSION_DIR=version ..
make user_version
cd version
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 -DWITH_GUDHI_REMOTE_TEST=ON .
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DWITH_GUDHI_REMOTE_TEST=ON .
cd python
python3 setup.py build_ext --inplace
ctest --output-on-failure
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
command: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON ..
cd src/python
python3 setup.py build_ext --inplace
ctest --output-on-failure
Expand Down Expand Up @@ -323,7 +323,7 @@ jobs:
command: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DEIGEN3_INCLUDE_DIR=/eigen-3.3.9 -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release -DEIGEN3_INCLUDE_DIR=/eigen-3.3.9 -DWITH_GUDHI_EXAMPLE=OFF -DWITH_GUDHI_UTILITIES=OFF -DWITH_GUDHI_PYTHON=ON ..
cd src/python
python3 setup.py build_ext --inplace
ctest --output-on-failure
Expand Down
4 changes: 2 additions & 2 deletions .github/for_maintainers/new_gudhi_version_creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Checkin the modifications, build and test the version:
```bash
git submodule update --init
rm -rf build; mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_REMOTE_TEST=ON -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_BENCHMARK=ON -DUSER_VERSION_DIR=gudhi.@GUDHI_VERSION@ -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_REMOTE_TEST=ON -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_BENCHMARK=ON -DUSER_VERSION_DIR=gudhi.@GUDHI_VERSION@ ..
make user_version
date +"%d-%m-%Y-%T" > gudhi.@GUDHI_VERSION@/timestamp.txt
tar -czvf gudhi.@GUDHI_VERSION@.tar.gz gudhi.@GUDHI_VERSION@
Expand All @@ -54,7 +54,7 @@ mkdir gudhi.doc.@GUDHI_VERSION@
```bash
cd gudhi.@GUDHI_VERSION@
rm -rf build; mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_EXAMPLE=ON -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DWITH_GUDHI_EXAMPLE=ON ..
make doxygen && grep warning doxygen.log
```

Expand Down
3 changes: 3 additions & 0 deletions .github/next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Below is a list of changes:
- [Module](link)
- **...**

- Installation
- CMake ≥ 3.15 is now required (was ≥ 3.8).

- Miscellaneous
- The [list of bugs that were solved](https://github.com/GUDHI/gudhi-devel/issues?q=label%3A3.11.0+is%3Aclosed) is available on GitHub.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pip-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: |
mkdir build_39
cd build_39
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON39/bin/python ..
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON39/bin/python ..
cd src/python
$PYTHON39/bin/python -m build -n -w
auditwheel repair dist/*.whl
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pip-build-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
python --version
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release ..
cd src/python
python -m build -n -w
export PATH="$PATH:`python -m site --user-base`/bin"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pip-packaging-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
rm -rf src/python/gudhi/*.cpp
mkdir build_38
cd build_38
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON38/bin/python ..
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON38/bin/python ..
cd src/python
$PYTHON38/bin/python -m build -n -w
auditwheel repair dist/*.whl
Expand All @@ -41,7 +41,7 @@ jobs:
rm -rf src/python/gudhi/*.cpp
mkdir build_39
cd build_39
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON39/bin/python ..
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON39/bin/python ..
cd src/python
$PYTHON39/bin/python -m build -n -w
auditwheel repair dist/*.whl
Expand All @@ -64,7 +64,7 @@ jobs:
rm -rf src/python/gudhi/*.cpp
mkdir build_310
cd build_310
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON310/bin/python ..
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON310/bin/python ..
cd src/python
$PYTHON310/bin/python -m build -n -w
auditwheel repair dist/*.whl
Expand All @@ -83,7 +83,7 @@ jobs:
rm -rf src/python/gudhi/*.cpp
mkdir build_311
cd build_311
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON311/bin/python ..
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON311/bin/python ..
cd src/python
$PYTHON311/bin/python -m build -n -w
auditwheel repair dist/*.whl
Expand All @@ -102,7 +102,7 @@ jobs:
rm -rf src/python/gudhi/*.cpp
mkdir build_312
cd build_312
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON312/bin/python ..
cmake -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=$PYTHON312/bin/python ..
cd src/python
$PYTHON312/bin/python -m build -n -w
auditwheel repair dist/*.whl
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pip-packaging-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
python --version
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release ..
cd src/python
python -m build -n -w
- name: Install and test python wheel
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
python --version
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPython_ADDITIONAL_VERSIONS=3 ..
cmake -DCMAKE_BUILD_TYPE=Release ..
cd src/python
python -m build -n -w
# Test ABI compatibility with numpy 1.X
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.8)
cmake_minimum_required(VERSION 3.15)

project(GUDHIdev)

Expand Down
19 changes: 14 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ jobs:
variables:
pythonVersion: "3.9"
cmakeBuildType: Release
gudhiCmakeOptions: -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=ON -DWITH_GUDHI_REMOTE_TEST=ON
# On this VM, 2 versions of python are installed. Default Python_FIND_FRAMEWORK is FIRST, which means asks frameworks first
# LAST means consult frameworks in last resort, use the standard libraries or headers first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect it uses PATH, not "standard libraries or headers", since it is looking for a python exe?

extraCmakeOptions: -DPython_FIND_FRAMEWORK=LAST

steps:
# Use a specific Python version
Expand All @@ -29,7 +33,8 @@ jobs:
- bash: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE:STRING=$(cmakeBuildType) -GNinja -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=ON -DWITH_GUDHI_REMOTE_TEST=ON ..
which python
cmake -DCMAKE_BUILD_TYPE:STRING=$(cmakeBuildType) $(extraCmakeOptions) -GNinja $(gudhiCmakeOptions) ..
ninja
ninja doxygen
ctest --output-on-failure
Expand All @@ -44,7 +49,11 @@ jobs:
variables:
pythonVersion: "3.9"
cmakeVcpkgFlags: -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake
cmakeFlags: -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=OFF
# WITH_GUDHI_PYTHON=OFF on purpose. It is set to ON on a second cmake call
gudhiCmakeOptions: -DWITH_GUDHI_EXAMPLE=ON -DWITH_GUDHI_TEST=ON -DWITH_GUDHI_UTILITIES=ON -DWITH_GUDHI_PYTHON=OFF
# On this VM, 2 versions of python are installed. Default Python_FIND_REGISTRY is FIRST, which means asks registry first
# LAST means consult registry in last resort, use the standard libraries or headers first
extraCmakeOptions: -DPython_FIND_REGISTRY=LAST

steps:
# Use a specific Python version
Expand All @@ -69,16 +78,16 @@ jobs:
IF %ERRORLEVEL% NEQ 0 EXIT 1
displayName: "Install build dependencies"
- script: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -G "Ninja" -DFORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT=ON $(cmakeVcpkgFlags) $(cmakeFlags) ..
cmake -DCMAKE_BUILD_TYPE=Release -G "Ninja" -DFORCE_EIGEN_DEFAULT_DENSE_INDEX_TYPE_TO_INT=ON $(cmakeVcpkgFlags) $(gudhiCmakeOptions) ..
IF %ERRORLEVEL% NEQ 0 EXIT 1
ninja
IF %ERRORLEVEL% NEQ 0 EXIT 1
ctest --output-on-failure -C Release -E diff_files
IF %ERRORLEVEL% NEQ 0 EXIT 1
cmake -DWITH_GUDHI_PYTHON=ON -DWITH_GUDHI_REMOTE_TEST=ON .
cmake $(extraCmakeOptions) -DWITH_GUDHI_PYTHON=ON -DWITH_GUDHI_REMOTE_TEST=ON .
IF %ERRORLEVEL% NEQ 0 EXIT 1
cd src\python
copy "C:\vcpkg\installed\x64-windows\bin\mpfr*.dll" ".\gudhi\"
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.15)

project(GUDHI)

Expand Down
34 changes: 15 additions & 19 deletions src/cmake/modules/GUDHI_third_party_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,27 @@ add_definitions( -DBOOST_SYSTEM_NO_DEPRECATED )

if (WITH_GUDHI_PYTHON)
# Find the correct Python interpreter.
# Can be set with -DPYTHON_EXECUTABLE=/usr/bin/python3 or -DPython_ADDITIONAL_VERSIONS=3 for instance.
find_package( PythonInterp )

# Can be set with -DPython_EXECUTABLE=/usr/bin/python3 for instance.
# Default Python_FIND_STRATEGY to LOCATION: Stops lookup as soon as a version satisfying version constraints is founded
# (as opposed to VERSION: Try to find the most recent version in all specified locations.)
cmake_policy(SET CMP0094 NEW)
mglisse marked this conversation as resolved.
Show resolved Hide resolved
# Should be Development.Module (Development also includes Development.Embed) but it would require cmake 3.18. TODO in a later version
find_package( Python COMPONENTS Interpreter Development NumPy)

# find_python_module tries to import module in Python interpreter and to retrieve its version number
# returns ${PYTHON_MODULE_NAME_UP}_VERSION and ${PYTHON_MODULE_NAME_UP}_FOUND
function( find_python_module PYTHON_MODULE_NAME )
string(TOUPPER ${PYTHON_MODULE_NAME} PYTHON_MODULE_NAME_UP)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import ${PYTHON_MODULE_NAME}; print(${PYTHON_MODULE_NAME}.__version__)"
COMMAND ${Python_EXECUTABLE} -c "import ${PYTHON_MODULE_NAME}; print(${PYTHON_MODULE_NAME}.__version__)"
RESULT_VARIABLE PYTHON_MODULE_RESULT
OUTPUT_VARIABLE PYTHON_MODULE_VERSION
ERROR_VARIABLE PYTHON_MODULE_ERROR)
if(PYTHON_MODULE_RESULT EQUAL 0)
# Remove all carriage returns as it can be multiline
string(REGEX REPLACE "\n" " " PYTHON_MODULE_VERSION "${PYTHON_MODULE_VERSION}")
message ("++ Python module ${PYTHON_MODULE_NAME} - Version ${PYTHON_MODULE_VERSION} found")

set(${PYTHON_MODULE_NAME_UP}_VERSION ${PYTHON_MODULE_VERSION} PARENT_SCOPE)
set(${PYTHON_MODULE_NAME_UP}_FOUND TRUE PARENT_SCOPE)
else()
Expand All @@ -167,7 +171,7 @@ if (WITH_GUDHI_PYTHON)
function( find_python_module_no_version PYTHON_MODULE_NAME )
string(TOUPPER ${PYTHON_MODULE_NAME} PYTHON_MODULE_NAME_UP)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import ${PYTHON_MODULE_NAME}"
COMMAND ${Python_EXECUTABLE} -c "import ${PYTHON_MODULE_NAME}"
RESULT_VARIABLE PYTHON_MODULE_RESULT
ERROR_VARIABLE PYTHON_MODULE_ERROR)
if(PYTHON_MODULE_RESULT EQUAL 0)
Expand All @@ -181,8 +185,8 @@ if (WITH_GUDHI_PYTHON)
set(${PYTHON_MODULE_NAME_UP}_FOUND FALSE PARENT_SCOPE)
endif()
endfunction( find_python_module_no_version )
if( PYTHONINTERP_FOUND )

if( TARGET Python::Interpreter )
find_python_module("cython")
find_python_module("pytest")
find_python_module("matplotlib")
Expand All @@ -202,19 +206,11 @@ if (WITH_GUDHI_PYTHON)
find_python_module_no_version("sphinxcontrib.bibtex")
find_python_module("networkx")
endif()

if(NOT GUDHI_PYTHON_PATH)
message(FATAL_ERROR "ERROR: GUDHI_PYTHON_PATH is not valid.")
endif(NOT GUDHI_PYTHON_PATH)

option(WITH_GUDHI_PYTHON_RUNTIME_LIBRARY_DIRS "Build with setting runtime_library_dirs. Useful when setting rpath is not allowed" ON)

if(PYTHONINTERP_FOUND AND CYTHON_FOUND)
if(SPHINX_FOUND)
# Documentation generation is available through sphinx
#find_program( SPHINX_PATH sphinx-build )
# Calling sphinx-build may use a different version of python and fail
set(SPHINX_PATH "${PYTHON_EXECUTABLE}" "-m" "sphinx.cmd.build")
endif(SPHINX_FOUND)
endif(PYTHONINTERP_FOUND AND CYTHON_FOUND)

endif (WITH_GUDHI_PYTHON)
2 changes: 1 addition & 1 deletion src/common/doc/installation.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* \section compiling Compiling
* The library uses c++17 and requires <a target="_blank" href="https://www.boost.org/">Boost</a> &ge; 1.71.0
* and <a target="_blank" href="https://cmake.org/">CMake</a> &ge; 3.8.
* and <a target="_blank" href="https://cmake.org/">CMake</a> &ge; 3.15.
* It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2017.
*
* \subsection utilities Utilities and examples
Expand Down
Loading
Loading