Skip to content
Snippets Groups Projects
Verified Commit 274bd2ab authored by Lars Bilke's avatar Lars Bilke
Browse files

[cmake] Create Jupyter Lab config in venv.

Sets markdown files to be opened as Jupyter Notebooks in JLab.
parent 69c96cca
No related branches found
No related tags found
No related merge requests found
...@@ -9,9 +9,10 @@ if(OGS_USE_PYTHON) ...@@ -9,9 +9,10 @@ if(OGS_USE_PYTHON)
endif() endif()
if(OGS_USE_PIP) if(OGS_USE_PIP)
set(Python_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) set(LOCAL_VIRTUALENV_DIR ${PROJECT_BINARY_DIR}/.venv CACHE INTERNAL "")
set(Python_ROOT_DIR ${LOCAL_VIRTUALENV_DIR})
set(CMAKE_REQUIRE_FIND_PACKAGE_Python TRUE) set(CMAKE_REQUIRE_FIND_PACKAGE_Python TRUE)
if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv) if(NOT EXISTS ${LOCAL_VIRTUALENV_DIR})
execute_process( execute_process(
COMMAND COMMAND
${CMAKE_COMMAND} -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} ${CMAKE_COMMAND} -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
...@@ -35,7 +36,7 @@ if(OGS_USE_PIP) ...@@ -35,7 +36,7 @@ if(OGS_USE_PIP)
if(MSVC) if(MSVC)
set(_venv_bin_dir "Scripts") set(_venv_bin_dir "Scripts")
endif() endif()
set(LOCAL_VIRTUALENV_BIN_DIR ${PROJECT_BINARY_DIR}/.venv/${_venv_bin_dir} set(LOCAL_VIRTUALENV_BIN_DIR ${LOCAL_VIRTUALENV_DIR}/${_venv_bin_dir}
CACHE INTERNAL "" CACHE INTERNAL ""
) )
# Fixes macOS install issues # Fixes macOS install issues
...@@ -43,6 +44,21 @@ if(OGS_USE_PIP) ...@@ -43,6 +44,21 @@ if(OGS_USE_PIP)
COMMAND ${LOCAL_VIRTUALENV_BIN_DIR}/pip install wheel COMMAND ${LOCAL_VIRTUALENV_BIN_DIR}/pip install wheel
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
) )
# Create jupytext config
file(
WRITE
${LOCAL_VIRTUALENV_DIR}/etc/jupyter/labconfig/default_setting_overrides.json
[=[
{
"@jupyterlab/docmanager-extension:plugin": {
"defaultViewers": {
"markdown": "Jupytext Notebook",
"myst": "Jupytext Notebook"
}
}
}
]=]
)
else() else()
# Prefer unix location over frameworks (Apple-only) # Prefer unix location over frameworks (Apple-only)
set(Python_FIND_FRAMEWORK LAST) set(Python_FIND_FRAMEWORK LAST)
...@@ -77,7 +93,7 @@ if(OGS_USE_PIP) ...@@ -77,7 +93,7 @@ if(OGS_USE_PIP)
set(OGS_PYTHON_PACKAGES "" set(OGS_PYTHON_PACKAGES ""
CACHE INTERNAL "List of Python packages to be installed via pip." CACHE INTERNAL "List of Python packages to be installed via pip."
) )
set(Python_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) set(Python_ROOT_DIR ${LOCAL_VIRTUALENV_DIR})
if(MSVC) if(MSVC)
set(Python_EXECUTABLE ${Python_ROOT_DIR}/Scripts/python.exe) set(Python_EXECUTABLE ${Python_ROOT_DIR}/Scripts/python.exe)
else() else()
......
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