Skip to content
Snippets Groups Projects
Unverified Commit b1a016d4 authored by Sam Yates's avatar Sam Yates Committed by GitHub
Browse files

Respect CMAKE_INSTALL_PREFIX in python lib path (#1325)

* Respect CMAKE_INSTALL_PREFIX in python lib path

* Set `base` and `platbase` to the CMAKE_INSTALL_PREFIX, if defined,
when asking Python for the default python lib install path.

* Differentiate between explicit and default prefix.

* Test for defaulted CMAKE_INSTALL_PREFIX, in which case, use the system
python site packages path, so that it's overall less excitingly awful in
python virtual environments. If you want /usr/local, set it.
parent 2d6bb96b
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,20 @@ file(COPY "${PROJECT_SOURCE_DIR}/VERSION" DESTINATION "${python_mod_path}")
# Set the installation path
# Ask Python where it keeps its system (platform) packages.
execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'))" OUTPUT_VARIABLE ARB_PYTHON_LIB_PATH_DEFAULT OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
file(WRITE "${CMAKE_BINARY_DIR}/install-prefix" "")
else()
file(WRITE "${CMAKE_BINARY_DIR}/install-prefix" "${CMAKE_INSTALL_PREFIX}")
endif()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c
"import sys,sysconfig;pfx=sys.stdin.read();print(sysconfig.get_path('platlib',vars={} if pfx=='' else {'base':pfx,'platbase':pfx}))"
INPUT_FILE "${CMAKE_BINARY_DIR}/install-prefix"
OUTPUT_VARIABLE ARB_PYTHON_LIB_PATH_DEFAULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Default to installing in that path, override with user specified ARB_PYTHON_LIB_PATH
set(ARB_PYTHON_LIB_PATH ${ARB_PYTHON_LIB_PATH_DEFAULT} CACHE PATH "path for installing Python module for Arbor.")
message(STATUS "Python module installation path: ${ARB_PYTHON_LIB_PATH}")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment