From bcf1ba0ba97e1bf9278d6c2718c80d6467827a60 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 21 Mar 2022 21:43:34 +0100 Subject: [PATCH] [python] Use dist-packages if is used for Python's sitepackages Instead of checking whether this is Debian system we query the sitepackages path from Python. If it matches dist-packages then we use dist-packages if we install below /usr, otherwise site-packages is used. --- CMakeLists.txt | 6 +++++- jenkins/build-opm-module.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f201bf8e0..e33c5c52c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,9 +334,13 @@ install(FILES cmake/OPM-CMake.md install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc) if (OPM_ENABLE_PYTHON) + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import site, sys; sys.stdout.write(site.getsitepackages()[-1]);" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_PATH) # ------------------------------------------------------------------------- # 1: Wrap C++ functionality in Python - if (EXISTS "/etc/debian_version") + if (PYTHON_SITE_PACKAGES_PATH MATCHES ".*/dist-packages/?" AND + CMAKE_INSTALL_PREFIX MATCHES "^/usr.*") + # dist-packages is only used if we install below /usr and python's site packages + # path matches dist-packages set(PYTHON_PACKAGE_PATH "dist-packages") else() set(PYTHON_PACKAGE_PATH "site-packages") diff --git a/jenkins/build-opm-module.sh b/jenkins/build-opm-module.sh index cde6e6245..1d7d88f73 100755 --- a/jenkins/build-opm-module.sh +++ b/jenkins/build-opm-module.sh @@ -226,7 +226,7 @@ function build_module_full { PY_MINOR=`python3 --version | awk -F ' ' '{print $2}' | awk -F '.' '{print $2}'` for configuration in ${!configurations[@]} do - export PYTHONPATH="$WORKSPACE/$configuration/install/lib/python$PY_MAJOR.$PY_MINOR/dist-packages" + export PYTHONPATH="$WORKSPACE/$configuration/install/lib/python$PY_MAJOR.$PY_MINOR/site-packages" # Build upstream modules build_upstreams