diff --git a/.ci_environment_docs.yaml b/.ci_environment_docs.yaml deleted file mode 100644 index 920a823..0000000 --- a/.ci_environment_docs.yaml +++ /dev/null @@ -1,8 +0,0 @@ -channels: -- conda-forge -dependencies: -- cmake -- doxygen -- eigen -- setuptools_scm -- xtensor diff --git a/.ci_environment_py.yaml b/.ci_environment_py.yaml deleted file mode 100644 index dc7d7ae..0000000 --- a/.ci_environment_py.yaml +++ /dev/null @@ -1,15 +0,0 @@ -channels: -- conda-forge -dependencies: -- cmake -- eigen -- ninja -- nomkl -- numpy -- pybind11 -- python -- pyxtensor -- scikit-build -- setuptools_scm -- xtensor -- xtensor-python diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 286d5d9..09992ad 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -1,51 +1,51 @@ name: gh-pages on: push: branches: - main release: types: [released] jobs: publish: runs-on: ubuntu-latest defaults: run: shell: bash -l {0} steps: - name: Basic GitHub action setup uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set conda environment (using micromamba for speed) + - name: Set conda environment uses: mamba-org/provision-with-micromamba@main with: - environment-file: .ci_environment_docs.yaml + environment-file: environment.yaml environment-name: myenv - name: Configure using CMake run: cmake -Bbuild -DBUILD_DOCS=1 - name: Build the docs working-directory: build run: make html - name: Deploy to GitHub Pages if: success() uses: crazy-max/ghaction-github-pages@v2 with: target_branch: gh-pages build_dir: build/html jekyll: false keep_history: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.readthedocs.yml b/.readthedocs.yml index 0bfc74d..2ca4cd2 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,11 +1,7 @@ -# .readthedocs.yml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - sphinx: configuration: docs/conf.py version: 2 conda: - environment: .readthedocsenv.yml + environment: environment.yaml diff --git a/.readthedocsenv.yml b/.readthedocsenv.yml deleted file mode 100644 index 1dc108b..0000000 --- a/.readthedocsenv.yml +++ /dev/null @@ -1,13 +0,0 @@ -channels: -- conda-forge -dependencies: -- breathe -- cmake -- doxygen -- eigen -- python-goosefem -- setuptools_scm -- sphinx -- sphinx_rtd_theme -- sphinx-tabs -- furo diff --git a/CMakeLists.txt b/CMakeLists.txt index d305182..30f7ad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,210 +1,211 @@ cmake_minimum_required(VERSION 3.18..3.21) project(GooseFEM) string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER) # Command-line options # ==================== option(BUILD_ALL "${PROJECT_NAME}: Build tests, Python API & docs" OFF) option(BUILD_TESTS "${PROJECT_NAME}: Build tests" OFF) option(BUILD_PYTHON "${PROJECT_NAME}: Build Python API" OFF) -option(BUILD_DOCS "${PROJECT_NAME}: Build docs" OFF) +option(BUILD_DOCS "${PROJECT_NAME}: Build docs (use `make html`)" OFF) option(USE_WARNINGS "${PROJECT_NAME}: Build with runtime warnings" ON) option(USE_ASSERT "${PROJECT_NAME}: Build with assertions" ON) option(USE_DEBUG "${PROJECT_NAME}: Build in debug mode" OFF) option(USE_SIMD "${PROJECT_NAME}: Build with hardware optimization" OFF) if(SKBUILD) set(BUILD_ALL 0) set(BUILD_TESTS 0) set(BUILD_PYTHON 1) set(BUILD_DOCS 0) endif() # Read version # ============ if (DEFINED ENV{SETUPTOOLS_SCM_PRETEND_VERSION}) set(PROJECT_VERSION $ENV{SETUPTOOLS_SCM_PRETEND_VERSION}) message(STATUS "Building ${PROJECT_NAME} ${PROJECT_VERSION} (read from SETUPTOOLS_SCM_PRETEND_VERSION)") else() execute_process( COMMAND python -c "from setuptools_scm import get_version; print(get_version())" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Building ${PROJECT_NAME} ${PROJECT_VERSION}") endif() # Set target # ========== find_package(xtensor REQUIRED) add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE $ $) target_link_libraries(${PROJECT_NAME} INTERFACE xtensor) target_compile_definitions(${PROJECT_NAME} INTERFACE ${PROJECT_NAME_UPPER}_VERSION="${PROJECT_VERSION}") # Libraries # ========= include(CMakePackageConfigHelpers) include(GNUInstallDirs) include(CTest) include("${PROJECT_NAME}Config.cmake") # Installation headers / CMake / pkg-config # ========================================= if(NOT SKBUILD) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include) configure_file("include/${PROJECT_NAME}/version.h" "${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/version.h" DESTINATION "include/${PROJECT_NAME}/") install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets) install( EXPORT ${PROJECT_NAME}-targets FILE "${PROJECT_NAME}Targets.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(${PROJECT_NAME}_TMP ${CMAKE_SIZEOF_VOID_P}) unset(CMAKE_SIZEOF_VOID_P) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" VERSION "${PROJECT_VERSION}" COMPATIBILITY AnyNewerVersion) set(CMAKE_SIZEOF_VOID_P ${${PROJECT_NAME}_TMP}) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") endif() # Build tests # =========== if(BUILD_TESTS OR BUILD_ALL) enable_testing() add_subdirectory(tests/basic) endif() # Build Python API # ================ if(BUILD_PYTHON OR BUILD_ALL) # The C++ functions are build to a library with name "_${PROJECT_NAME}" # The Python library simply loads all functions set(PYPROJECT_NAME "_${PROJECT_NAME}") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() find_package(pybind11 REQUIRED CONFIG) find_package(xtensor-python REQUIRED) if (SKBUILD) find_package(NumPy REQUIRED) else() find_package(Python REQUIRED COMPONENTS Interpreter Development NumPy) endif() pybind11_add_module(${PYPROJECT_NAME} python/main.cpp) target_compile_definitions(${PYPROJECT_NAME} PUBLIC VERSION_INFO=${PROJECT_VERSION}) target_link_libraries(${PYPROJECT_NAME} PUBLIC ${PROJECT_NAME} xtensor-python) if (SKBUILD) target_include_directories(${PYPROJECT_NAME} PUBLIC ${NumPy_INCLUDE_DIRS}) else() target_link_libraries(${PYPROJECT_NAME} PUBLIC ${PROJECT_NAME} pybind11::module Python::NumPy) endif() if (USE_WARNINGS) target_link_libraries(${PYPROJECT_NAME} PUBLIC ${PROJECT_NAME}::warnings) message(STATUS "Compiling ${PROJECT_NAME}-Python with run-time warnings") endif() if (USE_ASSERT) target_link_libraries(${PYPROJECT_NAME} PUBLIC ${PROJECT_NAME}::assert) message(STATUS "Compiling ${PROJECT_NAME}-Python with assertions") endif() if (USE_DEBUG) target_link_libraries(${PYPROJECT_NAME} PUBLIC ${PROJECT_NAME}::debug) message(STATUS "Compiling ${PROJECT_NAME}-Python in debug mode") endif() if (USE_SIMD) find_package(xtensor REQUIRED) find_package(xsimd REQUIRED) target_link_libraries(${PYPROJECT_NAME} PUBLIC xtensor::optimize xtensor::use_xsimd) message(STATUS "Compiling ${PROJECT_NAME}-Python with hardware optimization") endif() if (SKBUILD) if(APPLE) set_target_properties(${PYPROJECT_NAME} PROPERTIES INSTALL_RPATH "@loader_path/${CMAKE_INSTALL_LIBDIR}") else() set_target_properties(${PYPROJECT_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/${CMAKE_INSTALL_LIBDIR}") endif() install(TARGETS ${PYPROJECT_NAME} DESTINATION .) endif() endif() # Build documentation # =================== if(BUILD_DOCS OR BUILD_ALL) find_package(Doxygen REQUIRED) set(DOXYGEN_EXCLUDE_SYMBOLS detail) set(DOXYGEN_CASE_SENSE_NAMES YES) set(DOXYGEN_USE_MATHJAX YES) set(DOXYGEN_GENERATE_TREEVIEW YES) set(DOXYGEN_JAVADOC_AUTOBRIEF YES) set(DOXYGEN_MACRO_EXPANSION YES) set(DOXYGEN_SOURCE_BROWSER YES) set(DOXYGEN_GENERATE_XML YES) set(DOXYGEN_QUIET YES) set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) set(DOXYGEN_WARN_AS_ERROR NO) + set(DOXYGEN_HTML_COLORSTYLE TOGGLE) set(DOXYGEN_WARN_LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/doxygen_warnings.log") set(DOXYGEN_ALIASES "license=@par License:") set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "README.md") set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") set(DOXYGEN_STRIP_FROM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include") doxygen_add_docs(html "${CMAKE_CURRENT_SOURCE_DIR}/include" "README.md") endif() diff --git a/docs/conf.py b/docs/conf.py index e7fe315..1022328 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,74 +1,34 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html -# -- Path setup -------------------------------------------------------------- -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# import os import subprocess - -# sys.path.insert(0, os.path.abspath('.')) -# -- Run Doxygen ------------------------------------------------------------- - -doxydir = "_doxygen" - -if not os.path.isdir(doxydir): - os.mkdir(doxydir) - -subprocess.call(f"cmake .. -B{doxydir:s} -DBUILD_DOCS=1", shell=True) -subprocess.call(f"cd {doxydir:s}; make html", shell=True) -subprocess.call(f"python -m breathe.apidoc -m -f -p GooseFEM -o api {doxydir:s}/xml", shell=True) - -# -- Project information ----------------------------------------------------- +import sys project = "GooseFEM" copyright = "2017-2021, Tom de Geus" author = "Tom de Geus" +subprocess.call("cd ..; python setup.py build --build-type Release -vv", shell=True) +mybuild = os.listdir("../_skbuild")[0] +sys.path.insert(0, os.path.abspath(f"../_skbuild/{mybuild}/cmake-install/python")) -# -- General configuration --------------------------------------------------- +doxydir = "_doxygen" +os.makedirs(doxydir, exist_ok=True) +subprocess.call(f"cmake .. -B{doxydir} -DBUILD_DOCS=1", shell=True) +subprocess.call(f"cd {doxydir}; make html", shell=True) +subprocess.call(f"python -m breathe.apidoc -m -f -p GooseFEM -o api {doxydir}/xml", shell=True) -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. extensions = [ "breathe", "sphinx.ext.mathjax", "sphinx.ext.todo", "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx_tabs.tabs", ] -# Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -# html_theme = "sphinx_rtd_theme" html_theme = "furo" -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -# html_static_path = ["_static"] - - -# -- Breathe configuration --------------------------------------------------- - breathe_projects = { "GooseFEM": f"{doxydir:s}/xml/", } diff --git a/environment.yaml b/environment.yaml index 3551cbd..4a7d360 100644 --- a/environment.yaml +++ b/environment.yaml @@ -1,27 +1,26 @@ channels: - conda-forge dependencies: - breathe - catch2 >=3.0.0 - cmake - doxygen >=1.9.5 - eigen - furo - mathjax - ninja - numpy - pybind11 - python - python-gmatelastic >=0.5.1 - python-gmatelastoplastic >=0.3.1 - python-gmatelastoplasticfinitestrainsimo >=0.3.0 - python-gmattensor - scikit-build - scipy - setuptools_scm - sphinx -- sphinx_rtd_theme - sphinx-tabs - xsimd - xtensor - xtensor-python