summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorVolker Schroer <3470424+dl1ksv@users.noreply.github.com>2021-12-20 20:33:01 +0100
committerGitHub <noreply@github.com>2021-12-20 14:33:01 -0500
commit635adb7c4d195a0bca899bc10a8eeeacca6857e9 (patch)
tree15c08d162bc003b20f8e7990d7fe3e9ba8f869b1 /cmake
parentdb626c1b23aa47a6a4c1138b405fbe5809d803b5 (diff)
cmake: replace deprecated distutils
* gnuradio: replace deprecated distutils Check if python packaging is available Signed-off-by: Volker Schroer <3470424+dl1ksv@users.noreply.github.com> * Add packaging requirement Signed-off-by: Volker Schroer <3470424+dl1ksv@users.noreply.github.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/GrPython.cmake13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake
index 776ac55906..3dcd9e73bd 100644
--- a/cmake/Modules/GrPython.cmake
+++ b/cmake/Modules/GrPython.cmake
@@ -127,7 +127,7 @@ macro(GR_PYTHON_CHECK_MODULE desc mod cmd have)
GR_PYTHON_CHECK_MODULE_RAW(
"${desc}" "
#########################################
-from distutils.version import LooseVersion
+from packaging.version import Version as LooseVersion
try:
import ${mod}
assert ${cmd}
@@ -145,20 +145,23 @@ endmacro(GR_PYTHON_CHECK_MODULE)
if(NOT DEFINED GR_PYTHON_DIR)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import os
+import sysconfig
import site
-from distutils.sysconfig import get_python_lib
+install_dir = None
prefix = '${CMAKE_INSTALL_PREFIX}'
-#ask distutils where to install the python module
-install_dir = get_python_lib(plat_specific=True, prefix=prefix)
-
#use sites when the prefix is already recognized
try:
paths = [p for p in site.getsitepackages() if p.startswith(prefix)]
if len(paths) == 1: install_dir = paths[0]
except AttributeError: pass
+if not install_dir:
+ #find where to install the python module
+ install_dir = sysconfig.get_path('platlib')
+ prefix = sysconfig.get_config_var('prefix')
+
#strip the prefix to return a relative path
print(os.path.relpath(install_dir, prefix))"
OUTPUT_STRIP_TRAILING_WHITESPACE