Skip to content
Snippets Groups Projects
Unverified Commit 01a09091 authored by Lars Bilke's avatar Lars Bilke
Browse files

[py] Install python modules into spec. dir. in the build folder.

Allows co-existance with ogstools python package in build dir virtual environment.

Requires to uninstall ogs wheel in venv and to set the PYTHONPATH (both handled by CMake and .envrc-file used by the direnv-tool).
parent cc6ab5e7
No related branches found
No related tags found
No related merge requests found
set(_py_site_packages_dir
"lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages"
)
if(WIN32)
set(_py_site_packages_dir "Lib/site-packages")
endif()
# wheel: Install into Python module root dir (enables 'import ogs.simulator') # wheel: Install into Python module root dir (enables 'import ogs.simulator')
set(_py_install_location ogs) set(_py_install_location ogs)
set(_py_build_location ogs)
if(NOT OGS_BUILD_WHEEL) if(NOT OGS_BUILD_WHEEL)
set(_py_install_location "${_py_site_packages_dir}/ogs") set(_py_install_location
"${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/ogs"
)
set(_py_build_location "${PROJECT_BINARY_DIR}/site-packages/ogs")
endif() endif()
add_subdirectory(ogs) add_subdirectory(ogs)
...@@ -18,13 +15,12 @@ add_subdirectory(ogs.callbacks) ...@@ -18,13 +15,12 @@ add_subdirectory(ogs.callbacks)
if(OGS_USE_PIP) if(OGS_USE_PIP)
set_target_properties( set_target_properties(
simulator mesh callbacks simulator mesh callbacks PROPERTIES LIBRARY_OUTPUT_DIRECTORY
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${_py_build_location}
${LOCAL_VIRTUALENV_DIR}/${_py_site_packages_dir}/ogs
) )
file( file(
COPY ogs/. COPY ogs/.
DESTINATION ${LOCAL_VIRTUALENV_DIR}/${_py_site_packages_dir}/ogs DESTINATION ${_py_build_location}
PATTERN "__pycache__" EXCLUDE PATTERN "__pycache__" EXCLUDE
PATTERN "CMakeLists.txt" EXCLUDE PATTERN "CMakeLists.txt" EXCLUDE
) )
......
...@@ -238,6 +238,7 @@ set(_envrc_content ...@@ -238,6 +238,7 @@ set(_envrc_content
"[ -d \"${PROJECT_BINARY_DIR}/.venv\" ] && source ${PROJECT_BINARY_DIR}/.venv/bin/activate" "[ -d \"${PROJECT_BINARY_DIR}/.venv\" ] && source ${PROJECT_BINARY_DIR}/.venv/bin/activate"
"export PATH=$PATH:${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}" "export PATH=$PATH:${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}"
"export OGS_USE_PATH=1" "export OGS_USE_PATH=1"
"export PYTHONPATH=${PROJECT_BINARY_DIR}/site-packages:$PYTHONPATH"
) )
if(TFEL_WITH_PYTHON) if(TFEL_WITH_PYTHON)
set(_envrc_content "${_envrc_content}" set(_envrc_content "${_envrc_content}"
......
...@@ -175,6 +175,11 @@ function(setup_venv) ...@@ -175,6 +175,11 @@ function(setup_venv)
"To disable pip set OGS_USE_PIP=OFF.\n\n${_out}\n${_err}" "To disable pip set OGS_USE_PIP=OFF.\n\n${_out}\n${_err}"
) )
endif() endif()
# Uninstall ogs wheel
execute_process(
COMMAND ${_apple_env} ${LOCAL_VIRTUALENV_BIN_DIR}/pip uninstall
--yes ogs WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
endif() endif()
endfunction() endfunction()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment