From 396ed0c8afeb948afe7dfa4b413a865b15a8b18a Mon Sep 17 00:00:00 2001 From: Steven Koo Date: Tue, 18 Jan 2022 21:40:39 -0600 Subject: fixup! cmake: Replace distutils.sysconfig with sysconfig The original commit incorrectly fails the build uhd in the meta-ettus context. This uses prefix instead to get the base path. Signed-off-by: Steven Koo --- host/python/CMakeLists.txt | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'host/python/CMakeLists.txt') diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index 14db8bc00..eacdb8fbf 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -162,31 +162,17 @@ else() # Otherwise, use sysconfig to determine the correct relative path for Python # packages, and install to our prefix if(NOT DEFINED UHD_PYTHON_DIR) - if(WIN32) - # CPack with NSIS generates an error when using install() - # with a DESTINATION that is an absolute path. Thus, specify - # a blank prefix, which returns only the Python library relative - # path, and use that in the install step below. - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "import sysconfig;\ - platlib = sysconfig.get_path(name='platlib');\ - base = sysconfig.get_config_var('base');\ - print(platlib.replace(base, '').lstrip('\\\\'));" - OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE - ) - else() - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c - "import sysconfig; import os.path; \ - platlib = sysconfig.get_path(name='platlib');\ - base = sysconfig.get_config_var('base');\ - print(os.path.join('${CMAKE_INSTALL_PREFIX}', platlib.replace(base, '').lstrip('/')));" - OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif(WIN32) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c + "import os,sysconfig;\ + platlib = sysconfig.get_path(name='platlib');\ + prefix = sysconfig.get_config_var('prefix');\ + print(os.path.relpath(platlib, prefix));" + OUTPUT_VARIABLE UHD_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE + ) endif(NOT DEFINED UHD_PYTHON_DIR) file(TO_CMAKE_PATH ${UHD_PYTHON_DIR} UHD_PYTHON_DIR) - message(STATUS "Utilizing the python install directory: ${UHD_PYTHON_DIR}") + message(STATUS "Utilizing the python install directory: ${CMAKE_INSTALL_PREFIX}/${UHD_PYTHON_DIR}") # CMake will create an up-to-date copy of the entire Python module within # the build directory. Use sysconfig (above) to figure out the destination # path, and then we simply copy this module recursively into its final -- cgit v1.2.3