From 1d9e211b9edd2f65459c7abea70dc04375fc2b1f Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Fri, 19 Apr 2024 15:01:48 +0200 Subject: [PATCH] Revert "Remove python code using distutils. Bump required to 3.22.1" This reverts commit aebfe555633073420104c9fa8653c61bea7cf17f. --- CMakeLists.txt | 2 +- python/CMakeLists.txt | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cb3fdbda6e..503f447c1b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 2847cc8ba62..3069e98752a 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -7,7 +7,18 @@ endif() if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION) - find_package(Python3 COMPONENTS Interpreter) + if(${CMAKE_VERSION} VERSION_LESS "3.12.0") + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c "if True: + from distutils import sysconfig as sc + print(sc.get_python_lib(plat_specific=True))" + OUTPUT_VARIABLE Python3_SITEARCH + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + # Get install variable from Python3 module + # Python3_SITEARCH is available from 3.12 on, workaround if needed: + find_package(Python3 COMPONENTS Interpreter) + endif() if(USE_DIST_PACKAGES_FOR_PYTHON) string(REPLACE "site-packages" "dist-packages" GZ_PYTHON_INSTALL_PATH ${Python3_SITEARCH})