Added USERSPACE_PYTHON_PREFIX cmake variable to allow install IfcPython in userspace instead of system-wide.

This commit is contained in:
Yorik van Havre
2020-06-22 12:24:34 +02:00
committed by Thomas Krijnen
parent 3e9fff6c19
commit c76c72c017
2 changed files with 12 additions and 4 deletions
+1
View File
@@ -49,6 +49,7 @@ endif()
if (${BUILD_CONVERT})
OPTION(GLTF_SUPPORT "Build IfcConvert with glTF support (requires json.hpp)." OFF)
endif()
OPTION(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only instead of system-wide." OFF)
# TODO QtViewer is deprecated ATM as it uses the 0.4 API
# OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF)
+11 -4
View File
@@ -68,10 +68,17 @@ endif()
# directory in which the wrapper can be installed.
FIND_PACKAGE(PythonInterp)
IF(PYTHONINTERP_FOUND AND NOT "${PYTHON_EXECUTABLE}" STREQUAL "")
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib(1))"
OUTPUT_VARIABLE python_package_dir
)
IF (USERSPACE_PYTHON_PREFIX)
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; import site; sys.stdout.write(site.USER_SITE)"
OUTPUT_VARIABLE python_package_dir
)
ELSE ()
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib(1))"
OUTPUT_VARIABLE python_package_dir
)
ENDIF()
IF("${python_package_dir}" STREQUAL "")
MESSAGE(WARNING "Unable to locate Python site-package directory, unable to install the Python wrapper")