From f1917e661e8bc9802ac10b42c3080ffa0cf8892f Mon Sep 17 00:00:00 2001 From: mattprost Date: Wed, 15 Jun 2022 12:47:35 -0500 Subject: python: cmake: Detect python virtual environments This allows a UHD build to link to python modules installed in a virtual environment such a venv or pyenv. Signed-off-by: mattprost --- host/python/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/host/python/CMakeLists.txt b/host/python/CMakeLists.txt index eacdb8fbf..8db002238 100644 --- a/host/python/CMakeLists.txt +++ b/host/python/CMakeLists.txt @@ -9,9 +9,9 @@ ######################################################################## PYTHON_CHECK_MODULE( - "virtualenv" + "virtual environment" "sys" - "hasattr(sys, 'real_prefix')" + "sys.prefix != sys.base_prefix" HAVE_PYTHON_VIRTUALENV ) @@ -156,6 +156,7 @@ add_custom_command(OUTPUT ${TIMESTAMP_FILE} add_custom_target(pyuhd_library ALL DEPENDS ${TIMESTAMP_FILE} pyuhd) if(HAVE_PYTHON_VIRTUALENV) + message(STATUS "python virtual environment detected.") # In virtualenvs, let setuptools do its thing install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} -q install --force)") else() -- cgit v1.2.3