Commit fba5c47d authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

cmake: build and move all notebooks in Examples folder

parent aaa7118f
......@@ -95,7 +95,7 @@ add_subdirectory(Source)
add_subdirectory(Documentation)
if(BUILD_EXAMPLES)
add_subdirectory(Examples/Cxx)
add_subdirectory(Examples)
endif(BUILD_EXAMPLES)
# Show feature summary
......
add_subdirectory(Notebooks)
if(WITH_PYTHON)
find_package(Sphinx)
......
if(WITH_PYTHON)
add_custom_target(jupyter
COMMAND
${CMAKE_COMMAND} -E env PYTHONPATH=$<TARGET_FILE_DIR:dpsim_python>:${CMAKE_CURRENT_SOURCE_DIR}/../../Source/Python/:$ENV{PYTHONPATH}
jupyter notebook
DEPENDS
dpsim_python
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT Open Jupyter Notebooks
)
endif()
\ No newline at end of file
add_subdirectory(Cxx)
add_subdirectory(Notebooks)
\ No newline at end of file
find_program(JUPYTER jupyter)
if(WITH_PYTHON AND JUPYTER)
set(PYTHONPATH $<TARGET_FILE_DIR:dpsim_python>:${CMAKE_CURRENT_SOURCE_DIR}/../../Source/Python/:$ENV{PYTHONPATH})
file(GLOB_RECURSE IPYNBS
LIST_DIRECTORIES OFF
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"*.ipynb"
)
set(HTMLS "")
foreach(IPYNB ${IPYNBS})
if (IPYNB MATCHES .ipynb_checkpoints)
continue()
endif()
get_filename_component(DIR ${IPYNB} DIRECTORY)
get_filename_component(NAME ${IPYNB} NAME_WE)
if (NOT DIR STREQUAL "")
set(DIR "${DIR}/")
endif()
set(HTML ${CMAKE_CURRENT_BINARY_DIR}/${DIR}/${NAME}.html)
add_custom_command(
COMMAND
${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH}
jupyter nbconvert
--to html_embed
--output-dir ${CMAKE_CURRENT_BINARY_DIR}/${DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${IPYNB}
OUTPUT ${HTML}
WORKING_DIRECTORY ${DIR}
DEPENDS
${IPYNB}
dpsim_python
COMMENT "Creating HTML from IPython notebook"
)
list(APPEND HTMLS ${HTML})
endforeach()
# Convert Jupyter Notebooks to HTML
add_custom_target(notebooks
DEPENDS ${HTMLS}
)
# Run Jupyter Lab
add_custom_target(jupyter
COMMAND
${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHONPATH}
jupyter lab
DEPENDS
dpsim_python
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT Run Jupyter Lab
)
endif()
\ No newline at end of file
......@@ -13,4 +13,5 @@ villas-dataprocessing>=0.2
progressbar2
ipywidgets
jupyter
jupyter_contrib_nbextensions
jupyterlab_widgets
\ No newline at end of file
Supports Markdown
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