commit 79789512bffecd0b9b1f3a8ec30c65da029ed394 Author: Nils Wentzell Date: Thu Feb 17 16:58:35 2022 -0500 Squash app4triqs/3.3.x to reduce skeleton history when tracking Co-authored-by: Dylan Simon Co-authored-by: Alexander Hampel diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..10b38401 --- /dev/null +++ b/.clang-format @@ -0,0 +1,45 @@ +BasedOnStyle: LLVM + +AccessModifierOffset: 0 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakStringLiterals: false +ColumnLimit: 150 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 3 +ContinuationIndentWidth: 3 +Cpp11BracedListStyle: true +DerivePointerBinding : false +IndentCaseLabels: true +IndentWidth: 2 +Language: Cpp +MaxEmptyLinesToKeep: 1 +NamespaceIndentation : All +PointerAlignment: Right +ReflowComments: false +SortIncludes: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceInEmptyParentheses: false +SpacesInParentheses: false +Standard: Cpp11 +TabWidth: 2 +UseTab: Never diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..1c458b78 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,2 @@ +Checks: '-*,modernize-*,cppcoreguidelines-*,bugprone-*,-modernize-use-trailing-return-type,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-macro-usage,-cppcoreguidelines-no-malloc,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-non-private-member-variables-in-classes, -bugprone-easily-swappable-parameters' +HeaderFilterRegex: 'app4triqs' diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..ab7e50dc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.travis.yml +Dockerfile +Jenkinsfile +.git/objects/pack +build* diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 00000000..79dfa304 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,45 @@ +--- +name: Bug report +about: Create a report to help us improve +title: Bug report +labels: bug + +--- + +### Prerequisites + +* Please check that a similar issue isn't already filed: https://github.com/issues?q=is%3Aissue+user%3Atriqs + +### Description + +[Description of the issue] + +### Steps to Reproduce + +1. [First Step] +2. [Second Step] +3. [and so on...] + +or paste a minimal code example to reproduce the issue. + +**Expected behavior:** [What you expect to happen] + +**Actual behavior:** [What actually happens] + +### Versions + +Please provide the application version that you used. + +You can get this information from copy and pasting the output of +```bash +python -c "from app4triqs.version import *; show_version(); show_git_hash();" +``` +from the command line. Also, please include the OS you are running and its version. + +### Formatting + +Please use markdown in your issue message. A useful summary of commands can be found [here](https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf). + +### Additional Information + +Any additional information, configuration or data that might be necessary to reproduce the issue. diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 00000000..0ca4d25b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: Feature request +labels: feature + +--- + +### Summary + +One paragraph explanation of the feature. + +### Motivation + +Why is this feature of general interest? + +### Implementation + +What user interface do you suggest? + +### Formatting + +Please use markdown in your issue message. A useful summary of commands can be found [here](https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf). diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..890c702d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,140 @@ +name: build + +on: + push: + branches: [ unstable, '[0-9]+.[0-9]+.x' ] + pull_request: + branches: [ unstable, '[0-9]+.[0-9]+.x' ] + workflow_call: + workflow_dispatch: + +env: + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache + CCACHE_COMPILERCHECK: content + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_DIR: ${{ github.workspace }}/.ccache + CCACHE_MAXSIZE: 500M + CCACHE_SLOPPINESS: pch_defines,time_macros,include_file_mtime,include_file_ctime + CCACHE_COMPRESS: "1" + CCACHE_COMPRESSLEVEL: "1" + +jobs: + build: + + strategy: + fail-fast: false + matrix: + include: + - {os: ubuntu-22.04, cc: gcc-12, cxx: g++-12} + - {os: ubuntu-22.04, cc: clang-15, cxx: clang++-15} + - {os: macos-12, cc: gcc-12, cxx: g++-12} + - {os: macos-12, cc: clang, cxx: clang++} + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache/restore@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ matrix.os }}-${{ matrix.cc }}-${{ github.run_id }} + restore-keys: + ccache-${{ matrix.os }}-${{ matrix.cc }}- + + - name: Install ubuntu dependencies + if: matrix.os == 'ubuntu-22.04' + run: > + sudo apt-get update && + sudo apt-get install lsb-release wget software-properties-common && + wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && sudo chmod +x /tmp/llvm.sh && sudo /tmp/llvm.sh 15 && + sudo apt-get install + ccache + clang-15 + g++-12 + gfortran + hdf5-tools + libblas-dev + libboost-dev + libclang-15-dev + libc++-15-dev + libc++abi-15-dev + libomp-15-dev + libfftw3-dev + libgfortran5 + libgmp-dev + libhdf5-dev + liblapack-dev + libopenmpi-dev + openmpi-bin + openmpi-common + openmpi-doc + python3-clang-15 + python3-dev + python3-mako + python3-matplotlib + python3-mpi4py + python3-numpy + python3-pip + python3-scipy + python3-sphinx + python3-nbsphinx + + - name: Install homebrew dependencies + if: matrix.os == 'macos-12' + run: | + brew install ccache gcc@12 llvm boost fftw hdf5 open-mpi openblas + mkdir $HOME/.venv + python3 -m venv $HOME/.venv/my_python + source $HOME/.venv/my_python/bin/activate + pip install mako numpy scipy mpi4py + pip install -r requirements.txt + echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV + echo "PATH=$PATH" >> $GITHUB_ENV + + - name: add clang cxxflags + if: ${{ contains(matrix.cxx, 'clang') }} + run: | + echo "PATH=/usr/local/opt/llvm/bin:$PATH" >> $GITHUB_ENV + echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV + + - name: Build & Install TRIQS + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + run: | + git clone https://github.com/TRIQS/triqs --branch unstable + mkdir triqs/build && cd triqs/build + cmake .. -DBuild_Tests=OFF -DCMAKE_INSTALL_PREFIX=$HOME/install + make -j1 install VERBOSE=1 + cd ../ + + - name: Build app4triqs + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + LIBRARY_PATH: /usr/local/opt/llvm/lib + run: | + source $HOME/install/share/triqs/triqsvars.sh + mkdir build && cd build && cmake .. + make -j2 || make -j1 VERBOSE=1 + + - name: Test app4triqs + env: + DYLD_FALLBACK_LIBRARY_PATH: /usr/local/opt/llvm/lib + OPENBLAS_NUM_THREADS: "1" + run: | + source $HOME/install/share/triqs/triqsvars.sh + cd build + ctest -j2 --output-on-failure + + - name: ccache statistics + if: always() + run: ccache -sv + + - uses: actions/cache/save@v4 + if: always() + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ matrix.os }}-${{ matrix.cc }}-${{ github.run_id }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d38f325c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +compile_commands.json +doc/_autosummary +doc/cpp2rst_generated diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..dca0f459 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,178 @@ +# ############################################################################## +# +# app4triqs - An example application using triqs and cpp2py +# +# Copyright (C) ... +# +# app4triqs is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# app4triqs is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# app4triqs (in the file COPYING.txt in this directory). If not, see +# . +# +# ############################################################################## + +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) +cmake_policy(VERSION 3.20) +if(POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) +endif() + +# ############ +# Define Project +project(app4triqs VERSION 3.3.0 LANGUAGES CXX) +get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY) + +# ############ +# Load TRIQS and CPP2PY +find_package(TRIQS 3.3 REQUIRED) + +# Get the git hash & print status +triqs_get_git_hash_of_source_dir(PROJECT_GIT_HASH) +message(STATUS "${PROJECT_NAME} version : ${PROJECT_VERSION}") +message(STATUS "${PROJECT_NAME} Git hash: ${PROJECT_GIT_HASH}") + +# Enforce Consistent Versioning +if(NOT ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} VERSION_EQUAL ${TRIQS_VERSION_MAJOR}.${TRIQS_VERSION_MINOR}) + message(FATAL_ERROR "The ${PROJECT_NAME} version ${PROJECT_VERSION} is not compatible with TRIQS version ${TRIQS_VERSION}.") +endif() + +# Default Install directory to TRIQS_ROOT if not given or when provided as relative path. +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX})) + message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT") + set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE) + set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE) +endif() +if(NOT IS_SUBPROJECT) + message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------") +endif() +set(${PROJECT_NAME}_BINARY_DIR ${PROJECT_BINARY_DIR} CACHE STRING "Binary directory of the ${PROJECT_NAME} Project") + +# Make additional Find Modules available +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/share/cmake/Modules) + +# ############ +# CMake Options + +# Default to Release build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE) +endif() +if(NOT IS_SUBPROJECT) + message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------") +endif() + +# Python Support +option(PythonSupport "Build with Python support" ON) +if(PythonSupport AND NOT TRIQS_WITH_PYTHON_SUPPORT) + message(FATAL_ERROR "TRIQS was installed without Python support. Cannot build the Python Interface. Disable the build with -DPythonSupport=OFF") +endif() + +# Documentation +option(Build_Documentation "Build documentation" OFF) +if(NOT IS_SUBPROJECT AND (Build_Documentation AND NOT PythonSupport)) + message(FATAL_ERROR "Build_Documentation=ON requires PythonSupport to be enabled") +endif() + +# Testing +option(Build_Tests "Build tests" ON) +if(Build_Tests) + enable_testing() +endif() + +# ############ +# Global Compilation Settings + +# Build static libraries by default +option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) + +# Export the list of compile-commands into compile_commands.json +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Disable compiler extensions +set(CMAKE_CXX_EXTENSIONS OFF) + +# Provide additional debugging information for Debug builds +add_compile_options($<$:-ggdb3>) + +# Create an Interface target for compiler warnings +add_library(${PROJECT_NAME}_warnings INTERFACE) +target_compile_options(${PROJECT_NAME}_warnings + INTERFACE + -Wall + -Wextra + -Wfloat-conversion + -Wpedantic + -Wno-sign-compare + $<$:-Wno-comma-subscript> + $<$:-Wno-psabi> # Disable notes about ABI changes + $<$:-Wshadow=local> + $<$:-Wno-attributes> + $<$:-Wno-deprecated-declarations> + $<$:-Wno-deprecated-comma-subscript> + $<$:-Wno-unknown-warning-option> + $<$:-Wshadow> + $<$:-Wno-gcc-compat> + $<$:-Wno-c++20-extensions> + $<$:-Wno-c++20-compat> + $<$:-Wno-tautological-constant-compare> +) + +# Provide GNU Installation directories +include(GNUInstallDirs) + +# ############# +# Build Project + +# Find / Build dependencies +add_subdirectory(deps) + +# Build and install the library +add_subdirectory(c++/${PROJECT_NAME}) + +# Tests +if(Build_Tests) + add_subdirectory(test) +endif() + +# Python +if(PythonSupport) + add_subdirectory(python/${PROJECT_NAME}) +endif() + +# Docs +if(NOT IS_SUBPROJECT AND Build_Documentation) + add_subdirectory(doc) +endif() + +# Additional configuration files +add_subdirectory(share) + +# add packaging for automatic Versioning +add_subdirectory(packaging) + +# ############# +# Debian Package + +option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF) +if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT) + if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr") + message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging") + endif() + set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) + set(CPACK_GENERATOR "DEB") + set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + set(CPACK_PACKAGE_CONTACT "https://github.com/TRIQS/${PROJECT_NAME}") + execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CMAKE_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "triqs (>= 3.3)") + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) + include(CPack) +endif() diff --git a/COPYING.txt b/COPYING.txt new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/COPYING.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/ChangeLog.md b/ChangeLog.md new file mode 120000 index 00000000..9e080e26 --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1 @@ +doc/ChangeLog.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1ae17114 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# See ../triqs/packaging for other options +FROM flatironinstitute/triqs:unstable-ubuntu-clang +ARG APPNAME=app4triqs + +# Install here missing dependencies, e.g. +# RUN apt-get install -y python3-skimage + +COPY --chown=build . $SRC/$APPNAME +WORKDIR $BUILD/$APPNAME +RUN chown build . +USER build +ARG BUILD_ID +ARG CMAKE_ARGS +RUN cmake $SRC/$APPNAME -DTRIQS_ROOT=${INSTALL} $CMAKE_ARGS && make -j4 || make -j1 VERBOSE=1 +USER root +RUN make install diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..ff81d637 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,186 @@ +def projectName = "app4triqs" /* set to app/repo name */ + +def dockerName = projectName.toLowerCase(); +/* which platform to build documentation on */ +def documentationPlatform = "ubuntu-clang" +/* depend on triqs upstream branch/project */ +def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME +def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F') +/* whether to keep and publish the results */ +def keepInstall = !env.BRANCH_NAME.startsWith("PR-") + +properties([ + disableConcurrentBuilds(), + buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')), + pipelineTriggers(keepInstall ? [ + upstream( + threshold: 'SUCCESS', + upstreamProjects: triqsProject + ) + ] : []) +]) + +/* map of all builds to run, populated below */ +def platforms = [:] + +/****************** linux builds (in docker) */ +/* Each platform must have a corresponding Dockerfile.PLATFORM in triqs/packaging */ +def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "ubuntu-intel", "sanitize"] +/* .each is currently broken in jenkins */ +for (int i = 0; i < dockerPlatforms.size(); i++) { + def platform = dockerPlatforms[i] + platforms[platform] = { -> node('linux && docker && triqs') { + stage(platform) { timeout(time: 1, unit: 'HOURS') { ansiColor('xterm') { + checkout scm + /* construct a Dockerfile for this base */ + sh """ + ( echo "FROM flatironinstitute/triqs:${triqsBranch}-${env.STAGE_NAME}" ; sed '0,/^FROM /d' Dockerfile ) > Dockerfile.jenkins + mv -f Dockerfile.jenkins Dockerfile + """ + /* build and tag */ + def args = '' + if (platform == documentationPlatform) + args = '-DBuild_Documentation=1' + else if (platform == "sanitize") + args = '-DASAN=ON -DUBSAN=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo' + def img = docker.build("flatironinstitute/${dockerName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg APPNAME=${projectName} --build-arg BUILD_ID=${env.BUILD_TAG} --build-arg CMAKE_ARGS='${args}' .") + catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { + img.inside("--shm-size=4gb") { + sh "make -C \$BUILD/${projectName} test CTEST_OUTPUT_ON_FAILURE=1" + } + } + if (!keepInstall) { + sh "docker rmi --no-prune ${img.imageName()}" + } + } } } + } } +} + +/****************** osx builds (on host) */ +def osxPlatforms = [ + ["gcc", ['CC=gcc-13', 'CXX=g++-13', 'FC=gfortran-13']], + ["clang", ['CC=$BREW/opt/llvm/bin/clang', 'CXX=$BREW/opt/llvm/bin/clang++', 'FC=gfortran-13', 'CXXFLAGS=-I$BREW/opt/llvm/include', 'LDFLAGS=-L$BREW/opt/llvm/lib']] +] +for (int i = 0; i < osxPlatforms.size(); i++) { + def platformEnv = osxPlatforms[i] + def platform = platformEnv[0] + platforms["osx-$platform"] = { -> node('osx && triqs') { + stage("osx-$platform") { timeout(time: 1, unit: 'HOURS') { ansiColor('xterm') { + def srcDir = pwd() + def tmpDir = pwd(tmp:true) + def buildDir = "$tmpDir/build" + /* install real branches in a fixed predictable place so apps can find them */ + def installDir = keepInstall ? "${env.HOME}/install/${projectName}/${env.BRANCH_NAME}/${platform}" : "$tmpDir/install" + def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}" + def venv = triqsDir + dir(installDir) { + deleteDir() + } + + checkout scm + + def hdf5 = "${env.BREW}/opt/hdf5@1.10" + dir(buildDir) { withEnv(platformEnv[1].collect { it.replace('\$BREW', env.BREW) } + [ + "PATH=$venv/bin:${env.BREW}/bin:/usr/bin:/bin:/usr/sbin", + "HDF5_ROOT=$hdf5", + "C_INCLUDE_PATH=$hdf5/include:${env.BREW}/include", + "CPLUS_INCLUDE_PATH=$venv/include:$hdf5/include:${env.BREW}/include", + "LIBRARY_PATH=$venv/lib:$hdf5/lib:${env.BREW}/lib", + "LD_LIBRARY_PATH=$hdf5/lib", + "PYTHONPATH=$installDir/lib/python3.9/site-packages", + "CMAKE_PREFIX_PATH=$venv/lib/cmake/triqs", + "VIRTUAL_ENV=$venv", + "OMP_NUM_THREADS=2"]) { + deleteDir() + /* note: this is installing into the parent (triqs) venv (install dir), which is thus shared among apps and so not be completely safe */ + sh "pip3 install -U -r $srcDir/requirements.txt" + sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir" + sh "make -j2 || make -j1 VERBOSE=1" + catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { try { + sh "make test CTEST_OUTPUT_ON_FAILURE=1" + } catch (exc) { + archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log') + throw exc + } } + sh "make install" + } } + } } } + } } +} + +/****************** wrap-up */ +def error = null +try { + parallel platforms + if (keepInstall) { node('linux && docker && triqs') { + /* Publish results */ + stage("publish") { timeout(time: 5, unit: 'MINUTES') { + def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim() + def release = env.BRANCH_NAME == "master" || env.BRANCH_NAME == "unstable" || sh(returnStdout: true, script: "git describe --exact-match HEAD || true").trim() + def workDir = pwd(tmp:true) + lock('triqs_publish') { + /* Update documention on gh-pages branch */ + dir("$workDir/gh-pages") { + def subdir = "${projectName}/${env.BRANCH_NAME}" + git(url: "ssh://git@github.com/TRIQS/TRIQS.github.io.git", branch: "master", credentialsId: "ssh", changelog: false) + sh "rm -rf ${subdir}" + docker.image("flatironinstitute/${dockerName}:${env.BRANCH_NAME}-${documentationPlatform}").inside() { + sh """#!/bin/bash -ex + base=\$INSTALL/share/doc + dir="${projectName}" + [[ -d \$base/triqs_\$dir ]] && dir=triqs_\$dir || [[ -d \$base/\$dir ]] + cp -rp \$base/\$dir ${subdir} + """ + } + sh "git add -A ${subdir}" + sh """ + git commit --author='Flatiron Jenkins ' --allow-empty -m 'Generated documentation for ${subdir}' -m '${env.BUILD_TAG} ${commit}' + """ + // note: credentials used above don't work (need JENKINS-28335) + sh "git push origin master" + } + /* Update packaging repo submodule */ + if (release) { dir("$workDir/packaging") { try { + git(url: "ssh://git@github.com/TRIQS/packaging.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false) + // note: credentials used above don't work (need JENKINS-28335) + sh """#!/bin/bash -ex + dir="${projectName}" + [[ -d triqs_\$dir ]] && dir=triqs_\$dir || [[ -d \$dir ]] + echo "160000 commit ${commit}\t\$dir" | git update-index --index-info + git commit --author='Flatiron Jenkins ' -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}' + git push origin ${env.BRANCH_NAME} + """ + } catch (err) { + /* Ignore, non-critical -- might not exist on this branch */ + echo "Failed to update packaging repo" + } } } + } + } } + } } +} catch (err) { + error = err +} finally { + /* send email on build failure (declarative pipeline's post section would work better) */ + if ((error != null || currentBuild.currentResult != 'SUCCESS') && env.BRANCH_NAME != "jenkins") emailext( + subject: "\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED", + body: """\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED + +Check console output at \$BUILD_URL to view full results. + +Building \$BRANCH_NAME for \$CAUSE +\$JOB_DESCRIPTION + +Changes: +\$CHANGES + +End of build log: +\${BUILD_LOG,maxLines=60} + """, + to: 'nwentzell@flatironinstitute.org', + recipientProviders: [ + [$class: 'DevelopersRecipientProvider'], + ], + replyTo: '$DEFAULT_REPLYTO' + ) + if (error != null) throw error +} diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..4b35411e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,18 @@ +app4triqs - An example application using triqs and cpp2py + +Copyright (C) 2017-2018, N. Wentzell, O. Parcollet +Copyright (C) 2018-2019, The Simons Foundation + authors: N. Wentzell, D. Simons, H. Strand, O. Parcollet + +app4triqs is free software: you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +app4triqs is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +app4triqs (in the file COPYING.txt in this directory). If not, see +. diff --git a/README.md b/README.md new file mode 100644 index 00000000..1657290f --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +[![build](https://github.com/TRIQS/app4triqs/workflows/build/badge.svg)](https://github.com/TRIQS/app4triqs/actions?query=workflow%3Abuild) + +# app4triqs - A skeleton for a TRIQS application + +Initial Setup +------------- + +To adapt this skeleton for a new TRIQS application, the following steps are necessary: + +* Create a repository, e.g. https://github.com/username/appname + +* Run the following commands in order after replacing **appname** accordingly + +```bash +git clone https://github.com/triqs/app4triqs --branch unstable appname +cd appname +./share/squash_history.sh +./share/replace_and_rename.py appname +git add -A && git commit -m "Adjust app4triqs skeleton for appname" +``` + +You can now add your github repository and push to it + +```bash +git remote add origin https://github.com/username/appname +git remote update +git push origin unstable +``` + +If you prefer to use the [SSH interface](https://help.github.com/en/articles/connecting-to-github-with-ssh) +to the remote repository, replace the http link with e.g. `git@github.com:username/appname`. + +### Merging app4triqs skeleton updates ### + +You can merge future changes to the app4triqs skeleton into your project with the following commands + +```bash +git remote update +git merge app4triqs_remote/unstable -X ours -m "Merge latest app4triqs skeleton changes" +``` + +If you should encounter any conflicts resolve them and `git commit`. +Finally we repeat the replace and rename command from the initial setup. + +```bash +./share/replace_and_rename.py appname +git commit --amend +``` + +Now you can compare against the previous commit with: +```bash +git diff prev_git_hash +```` + +Getting Started +--------------- + +After setting up your application as described above you should customize the following files and directories +according to your needs (replace app4triqs in the following by the name of your application) + +* Adjust or remove the `README.md` and `doc/ChangeLog.md` file +* In the `c++/app4triqs` subdirectory adjust the example files `app4triqs.hpp` and `app4triqs.cpp` or add your own source files. +* In the `test/c++` subdirectory adjust the example test `basic.cpp` or add your own tests. +* In the `python/app4triqs` subdirectory add your Python source files. + Be sure to remove the `app4triqs_module_desc.py` file unless you want to generate a Python module from your C++ source code. +* In the `test/python` subdirectory adjust the example test `Basic.py` or add your own tests. +* Adjust any documentation examples given as `*.rst` files in the doc directory. +* Adjust the sphinx configuration in `doc/conf.py.in` as necessary. +* The build and install process is identical to the one outline [here](https://triqs.github.io/app4triqs/unstable/install.html). + +### Optional ### +---------------- + +* If you want to wrap C++ classes and/or functions provided in the `c++/app4triqs/app4triqs.hpp` rerun the `c++2py` tool with +```bash +c++2py -r app4triqs_module_desc.py +``` +* Add your email address to the bottom section of `Jenkinsfile` for Jenkins CI notification emails +``` +End of build log: +\${BUILD_LOG,maxLines=60} + """, + to: 'user@domain.org', +``` diff --git a/c++/app4triqs/CMakeLists.txt b/c++/app4triqs/CMakeLists.txt new file mode 100644 index 00000000..5f51a380 --- /dev/null +++ b/c++/app4triqs/CMakeLists.txt @@ -0,0 +1,99 @@ +file(GLOB_RECURSE sources *.cpp) +add_library(${PROJECT_NAME}_c ${sources}) +add_library(${PROJECT_NAME}::${PROJECT_NAME}_c ALIAS ${PROJECT_NAME}_c) + +# Link against triqs and enable warnings +target_link_libraries(${PROJECT_NAME}_c PUBLIC triqs PRIVATE $) + +# Configure target and compilation +set_target_properties(${PROJECT_NAME}_c PROPERTIES + POSITION_INDEPENDENT_CODE ON + VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} +) +target_include_directories(${PROJECT_NAME}_c PUBLIC $) +target_include_directories(${PROJECT_NAME}_c SYSTEM INTERFACE $) +target_compile_definitions(${PROJECT_NAME}_c PUBLIC + APP4TRIQS_GIT_HASH=${PROJECT_GIT_HASH} + TRIQS_GIT_HASH=${TRIQS_GIT_HASH} + $<$:APP4TRIQS_DEBUG> + $<$:TRIQS_DEBUG> + $<$:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK> + ) + +# Install library and headers +install(TARGETS ${PROJECT_NAME}_c EXPORT ${PROJECT_NAME}-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") + + +# ========= Static Analyzer Checks ========== + +option(ANALYZE_SOURCES OFF "Run static analyzer checks if found (clang-tidy, cppcheck)") +if(ANALYZE_SOURCES) + + # Locate static analyzer tools + find_program(CPPCHECK_EXECUTABLE NAMES "cppcheck" PATHS ENV PATH) + find_program(CLANG_TIDY_EXECUTABLE NAMES "clang-tidy" PATHS ENV PATH) + + # Run clang-tidy if found + if(CLANG_TIDY_EXECUTABLE) + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXECUTABLE}") + set_target_properties(${PROJECT_NAME}_c PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}") + else() + message(STATUS "clang-tidy not found in $PATH. Please consider installing clang-tidy for additional checks!") + endif() + + # Run cppcheck if found + if(CPPCHECK_EXECUTABLE) + message(STATUS "cppcheck found: ${CPPCHECK_EXECUTABLE}") + add_custom_command( + TARGET ${PROJECT_NAME}_c + COMMAND ${CPPCHECK_EXECUTABLE} + --enable=warning,style,performance,portability + --std=c++23 + --template=gcc + --verbose + --force + --quiet + ${sources} + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR} + ) + else() + message(STATUS "cppcheck not found in $PATH. Please consider installing cppcheck for additional checks!") + endif() + +endif() + +# ========= Dynamic Analyzer Checks ========== + +option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer") +if(ASAN) + if(NOT TARGET asan) + find_package(sanitizer REQUIRED COMPONENTS asan) + endif() + target_link_libraries(${PROJECT_NAME}_c PUBLIC $) +endif() + +option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer") +if(UBSAN) + if(NOT TARGET ubsan) + find_package(sanitizer REQUIRED COMPONENTS ubsan) + endif() + target_link_libraries(${PROJECT_NAME}_c PUBLIC $) +endif() + +option(MSAN OFF "Compile library and executables with LLVM Memory Sanitizer") +if(MSAN) + if(NOT TARGET msan) + find_package(sanitizer REQUIRED COMPONENTS msan) + endif() + target_link_libraries(${PROJECT_NAME}_c PUBLIC $) +endif() + +option(TSAN OFF "Compile library and executables with LLVM Thread Sanitizer") +if(TSAN) + if(NOT TARGET tsan) + find_package(sanitizer REQUIRED COMPONENTS tsan) + endif() + target_link_libraries(${PROJECT_NAME}_c PUBLIC $) +endif() diff --git a/c++/app4triqs/app4triqs.cpp b/c++/app4triqs/app4triqs.cpp new file mode 100644 index 00000000..a16840c1 --- /dev/null +++ b/c++/app4triqs/app4triqs.cpp @@ -0,0 +1,37 @@ +#include +#include "./app4triqs.hpp" + +namespace app4triqs { + + toto &toto::operator+=(toto const &b) { + this->i += b.i; + return *this; + } + + toto toto::operator+(toto const &b) const { + auto res = *this; + res += b; + return res; + } + + bool toto::operator==(toto const &b) const { return (this->i == b.i); } + + void h5_write(h5::group grp, std::string subgroup_name, toto const &m) { + grp = subgroup_name.empty() ? grp : grp.create_group(subgroup_name); + h5_write(grp, "i", m.i); + h5_write_attribute(grp, "Format", toto::hdf5_format()); + } + + void h5_read(h5::group grp, std::string subgroup_name, toto &m) { + grp = subgroup_name.empty() ? grp : grp.open_group(subgroup_name); + int i; + h5_read(grp, "i", i); + m = toto(i); + } + + int chain(int i, int j) { + int n_digits_j = j > 0 ? (int)log10(j) + 1 : 1; + return i * int(pow(10, n_digits_j)) + j; + } + +} // namespace app4triqs diff --git a/c++/app4triqs/app4triqs.hpp b/c++/app4triqs/app4triqs.hpp new file mode 100644 index 00000000..b92d513b --- /dev/null +++ b/c++/app4triqs/app4triqs.hpp @@ -0,0 +1,79 @@ +#pragma once +#include +#include +#include
+ +namespace app4triqs { + + /** + * A very useful and important class + * + * @note A Useful note + * @include app4triqs/app4triqs.hpp + */ + class toto { + + int i = 0; + + public: + toto() = default; + + /** + * Construct from integer + * + * @param i_ a scalar :math:`G(\tau)` + */ + explicit toto(int i_) : i(i_) {} + + ~toto() = default; + + // Copy/Move construction + toto(toto const &) = default; + toto(toto &&) = default; + + /// Copy/Move assignment + toto &operator=(toto const &) = default; + toto &operator=(toto &&) = default; + + /// Simple accessor + [[nodiscard]] int get_i() const { return i; } + + /** + * A simple function with :math:`G(\tau)` + * + * @param u Nothing useful + */ + int f(int u) { return u; } + + /// Arithmetic operations + toto operator+(toto const &b) const; + toto &operator+=(toto const &b); + + /// Comparison + bool operator==(toto const &b) const; + + /// HDF5 + static std::string hdf5_format() { return "Toto"; } + + friend void h5_write(h5::group grp, std::string subgroup_name, toto const &m); + friend void h5_read(h5::group grp, std::string subgroup_name, toto &m); + + /// Serialization + template void serialize(Archive &ar, const unsigned int) { ar &i; } + }; + + /** + * Chain digits of two integers + * + * @head A set of functions that implement chaining + * + * @tail Do I really need to explain more ? + * + * @param i The first integer + * @param j The second integer + * @return An integer containing the digits of both i and j + * + */ + int chain(int i, int j); + +} // namespace app4triqs diff --git a/deps/.gitignore b/deps/.gitignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/deps/.gitignore @@ -0,0 +1 @@ +* diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt new file mode 100644 index 00000000..e26dfbae --- /dev/null +++ b/deps/CMakeLists.txt @@ -0,0 +1,67 @@ +include(external_dependency.cmake) + +# Add your dependencies with the function +# +# external_dependency(name +# [VERSION ] +# [GIT_REPO ] +# [GIT_TAG ] +# [BUILD_ALWAYS] +# [EXCLUDE_FROM_ALL] +# ) +# +# Resolve the dependency using the following steps in order. +# If a step was successful, skip the remaining ones. +# +# 1. Use find_package(name []) +# to locate the package in the system. +# Skip this step if Build_Deps option is set. +# 2. Try to find a directory containing the sources +# at ${CMAKE_CURRENT_SOURCE_DIR}/name and +# ${CMAKE_SOURCE_DIR}/deps/name. If found +# build it as a cmake sub-project. +# 3. If GIT_REPO is provided, git clone the sources, +# and build them as a cmake sub-project. +# +# Addtional options: +# +# GIT_TAG - Use this keyword to specify the git-tag, branch or commit hash +# +# BUILD_ALWAYS - If set, this dependency will always be built from source +# and will never be searched in the system. +# +# EXCLUDE_FROM_ALL - If set, targets of the dependency cmake subproject +# will not be included in the ALL target of the project. +# In particular the dependency will not be installed. + +if(NOT DEFINED Build_Deps) + set(Build_Deps "Always" CACHE STRING "Do we build dependencies from source? [Never/Always/IfNotFound]") +else() + set(Build_Deps_Opts "Never" "Always" "IfNotFound") + if(NOT ${Build_Deps} IN_LIST Build_Deps_Opts) + message(FATAL_ERROR "Build_Deps option should be either 'Never', 'Always' or 'IfNotFound'") + endif() + set(Build_Deps ${Build_Deps} CACHE STRING "Do we build dependencies from source? [Never/Always/IfNotFound]") + if(NOT IS_SUBPROJECT AND NOT Build_Deps STREQUAL "Always" AND (ASAN OR UBSAN)) + message(WARNING "For builds with llvm sanitizers (ASAN/UBSAN) it is recommended to use -DBuild_Deps=Always to avoid false positives.") + endif() +endif() + +# -- Cpp2Py -- +if(PythonSupport OR (NOT IS_SUBPROJECT AND Build_Documentation)) + external_dependency(Cpp2Py + GIT_REPO https://github.com/TRIQS/cpp2py + VERSION 2.0 + GIT_TAG unstable + BUILD_ALWAYS + EXCLUDE_FROM_ALL + ) +endif() + +# -- GTest -- +external_dependency(GTest + GIT_REPO https://github.com/google/googletest + GIT_TAG main + BUILD_ALWAYS + EXCLUDE_FROM_ALL +) diff --git a/deps/external_dependency.cmake b/deps/external_dependency.cmake new file mode 100644 index 00000000..252cead8 --- /dev/null +++ b/deps/external_dependency.cmake @@ -0,0 +1,95 @@ +# Copyright (c) 2020 Simons Foundation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You may obtain a copy of the License at +# https://www.gnu.org/licenses/gpl-3.0.txt + + +# Consider ROOT env variables in find_package +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() + +# Make sure that imported targets are always global +get_property(IMPORTED_ALWAYS_GLOBAL GLOBAL PROPERTY IMPORTED_ALWAYS_GLOBAL) +if(NOT IMPORTED_ALWAYS_GLOBAL) + function(add_library) + set(_args ${ARGN}) + if ("${_args}" MATCHES ";IMPORTED") + list(APPEND _args GLOBAL) + endif() + _add_library(${_args}) + endfunction() + set_property(GLOBAL PROPERTY IMPORTED_ALWAYS_GLOBAL TRUE) +endif() + +# Define External Dependency Function +function(external_dependency) + cmake_parse_arguments(ARG "EXCLUDE_FROM_ALL;BUILD_ALWAYS" "VERSION;GIT_REPO;GIT_TAG" "" ${ARGN}) + + # -- Was dependency already found? + get_property(${ARGV0}_FOUND GLOBAL PROPERTY ${ARGV0}_FOUND) + if(${ARGV0}_FOUND) + message(STATUS "Dependency ${ARGV0} was already resolved.") + return() + endif() + + # -- Try to find package in system. + if(NOT ARG_BUILD_ALWAYS AND NOT Build_Deps STREQUAL "Always") + find_package(${ARGV0} ${ARG_VERSION} QUIET HINTS ${CMAKE_INSTALL_PREFIX}) + if(${ARGV0}_FOUND) + message(STATUS "Found dependency ${ARGV0} in system ${${ARGV0}_ROOT}") + return() + elseif(Build_Deps STREQUAL "Never") + message(FATAL_ERROR "Could not find dependency ${ARGV0} in system. Please install the dependency manually or use -DBuild_Deps=IfNotFound during cmake configuration to automatically build all dependencies that are not found.") + endif() + endif() + + # -- Build package from source + message(STATUS " =============== Configuring Dependency ${ARGV0} =============== ") + if(ARG_EXCLUDE_FROM_ALL) + set(subdir_opts EXCLUDE_FROM_ALL) + set(Build_Tests OFF) + set(Build_Documentation OFF) + endif() + if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}) + message(STATUS "Found sources for dependency ${ARGV0} at ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") + add_subdirectory(${ARGV0} ${subdir_opts}) + elseif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/deps/${ARGV0}) + message(STATUS "Found sources for dependency ${ARGV0} at ${CMAKE_SOURCE_DIR}/deps/${ARGV0}") + add_subdirectory(${ARGV0} ${subdir_opts}) + elseif(ARG_GIT_REPO) + set(bin_dir ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}) + set(src_dir ${bin_dir}_src) + if(NOT IS_DIRECTORY ${src_dir}) + if(ARG_GIT_TAG) + set(clone_opts --branch ${ARG_GIT_TAG} -c advice.detachedHead=false) + endif() + if(NOT GIT_EXECUTABLE) + find_package(Git REQUIRED) + endif() + execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ARG_GIT_REPO} --depth 1 ${clone_opts} ${src_dir} + RESULT_VARIABLE clone_failed + ERROR_VARIABLE clone_error + ) + if(clone_failed) + message(FATAL_ERROR "Failed to clone sources for dependency ${ARGV0}.\n ${clone_error}") + endif() + endif() + add_subdirectory(${src_dir} ${bin_dir} ${subdir_opts}) + else() + message(FATAL_ERROR "Could not find or build dependency ${ARGV0}") + endif() + message(STATUS " =============== End ${ARGV0} Configuration =============== ") + set_property(GLOBAL PROPERTY ${ARGV0}_FOUND TRUE) + +endfunction() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..40eb49cd --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,81 @@ +# Generate the sphinx config file +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY) + +# ----------------------------------------------------------------------------- +# Create an optional target that allows us to regenerate the C++ doc with c++2rst +# ----------------------------------------------------------------------------- +add_custom_target(${PROJECT_NAME}_docs_cpp2rst) +include(${PROJECT_SOURCE_DIR}/share/cmake/extract_flags.cmake) +extract_flags(${PROJECT_NAME}_c BUILD_INTERFACE) +separate_arguments(${PROJECT_NAME}_c_CXXFLAGS) +macro(generate_docs header_file) + add_custom_command( + TARGET ${PROJECT_NAME}_docs_cpp2rst + COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/cpp2rst_generated + COMMAND + PYTHONPATH=${CPP2PY_BINARY_DIR}:$ENV{PYTHONPATH} + PATH=${CPP2PY_BINARY_DIR}/bin:${CPP2PY_ROOT}/bin:$ENV{PATH} + c++2rst + ${header_file} + -N ${PROJECT_NAME} + --output_directory ${CMAKE_CURRENT_SOURCE_DIR}/cpp2rst_generated + -I${PROJECT_SOURCE_DIR}/c++ + --cxxflags="${${PROJECT_NAME}_c_CXXFLAGS}" + ) +endmacro(generate_docs) + +generate_docs(${PROJECT_SOURCE_DIR}/c++/${PROJECT_NAME}/${PROJECT_NAME}.hpp) + +# -------------------------------------------------------- +# Build & Run the C++ doc examples and capture the output +# -------------------------------------------------------- + +add_custom_target(${PROJECT_NAME}_docs_example_output) +file(GLOB_RECURSE ExampleList RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) +foreach(example ${ExampleList}) + get_filename_component(f ${example} NAME_WE) + get_filename_component(d ${example} DIRECTORY) + add_executable(${PROJECT_NAME}_doc_${f} EXCLUDE_FROM_ALL ${example}) + set_property(TARGET ${PROJECT_NAME}_doc_${f} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${d}) + target_link_libraries(${PROJECT_NAME}_doc_${f} triqs) + add_custom_command(TARGET ${PROJECT_NAME}_doc_${f} + COMMAND ${PROJECT_NAME}_doc_${f} > ${CMAKE_CURRENT_SOURCE_DIR}/${d}/${f}.output 2>/dev/null + WORKING_DIRECTORY ${d} + ) + add_dependencies(${PROJECT_NAME}_docs_example_output ${PROJECT_NAME}_doc_${f}) +endforeach() + +# --------------------------------- +# Top Sphinx target +# --------------------------------- +if(NOT DEFINED SPHINXBUILD_EXECUTABLE) + find_package(Sphinx) +endif() + +# Sphinx has internal caching, always run it +add_custom_target(${PROJECT_NAME}_docs_sphinx ALL) +add_custom_command( + TARGET ${PROJECT_NAME}_docs_sphinx + COMMAND PYTHONPATH=${PROJECT_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SPHINXBUILD_EXECUTABLE} -j auto -c . -b html ${CMAKE_CURRENT_SOURCE_DIR} html +) + +option(Sphinx_Only "When building the documentation, skip the Python Modules and the generation of C++ Api and example outputs" OFF) +if(NOT Sphinx_Only) + # Autodoc usage requires the python modules to be built first + get_property(CPP2PY_MODULES_LIST GLOBAL PROPERTY CPP2PY_MODULES_LIST) + if(CPP2PY_MODULES_LIST) + add_dependencies(${PROJECT_NAME}_docs_sphinx ${CPP2PY_MODULES_LIST}) + endif() + + # Generation of C++ Api and Example Outputs + add_dependencies(${PROJECT_NAME}_docs_sphinx ${PROJECT_NAME}_docs_cpp2rst ${PROJECT_NAME}_docs_example_output) +endif() + +# --------------------------------- +# Install +# --------------------------------- +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ COMPONENT documentation DESTINATION share/doc/${PROJECT_NAME} + FILES_MATCHING + REGEX "\\.(html|pdf|png|gif|jpg|svg|ico|js|xsl|css|py|txt|inv|bib|ttf|woff2|eot|sh)$" + PATTERN "_*" +) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md new file mode 100644 index 00000000..8d708da5 --- /dev/null +++ b/doc/ChangeLog.md @@ -0,0 +1,35 @@ +(changelog)= + +# Changelog + +## Version 3.1.0 + +app4triqs version 3.1.0 is a compatibility +release for TRIQS version 3.1.0 that +* moves to cmake 3.12.4 and c++20 +* improves ghactions and jenkins configuration +* switches documentation to read-the-docs theme +* uses googletest main branch +* fixes several skeleton issues + +We thank all contributors: Alexander Hampel, Dylan Simon, Nils Wentzell + + +## Version 3.0.0 + +app4triqs version 3.0.0 is a compatibility +release for TRIQS version 3.0.0 that +* introduces compatibility with Python 3 (Python 2 no longer supported) +* adds a cmake-based dependency management +* fixes several application issues + + +## Version 2.2.0 + +app4triqs Version 2.2.0 provides a project +skeleton for TRIQS applications based on +the TRIQS Library Version 2.2.0. +It is intended for applications with both +Python and C++ components. + +This is the initial release for this project. diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css new file mode 100644 index 00000000..a8c2f1bd --- /dev/null +++ b/doc/_static/css/custom.css @@ -0,0 +1,5 @@ +@import url("theme.css"); + +.wy-nav-content { + max-width: 70em; +} diff --git a/doc/_static/logo_cea.png b/doc/_static/logo_cea.png new file mode 100644 index 00000000..1a28b439 Binary files /dev/null and b/doc/_static/logo_cea.png differ diff --git a/doc/_static/logo_cnrs.png b/doc/_static/logo_cnrs.png new file mode 100644 index 00000000..53c7af0e Binary files /dev/null and b/doc/_static/logo_cnrs.png differ diff --git a/doc/_static/logo_erc.jpg b/doc/_static/logo_erc.jpg new file mode 100644 index 00000000..b7181ee0 Binary files /dev/null and b/doc/_static/logo_erc.jpg differ diff --git a/doc/_static/logo_flatiron.png b/doc/_static/logo_flatiron.png new file mode 100644 index 00000000..9c97b4be Binary files /dev/null and b/doc/_static/logo_flatiron.png differ diff --git a/doc/_static/logo_github.png b/doc/_static/logo_github.png new file mode 100644 index 00000000..54bca717 Binary files /dev/null and b/doc/_static/logo_github.png differ diff --git a/doc/_static/logo_simons.jpg b/doc/_static/logo_simons.jpg new file mode 100644 index 00000000..88431238 Binary files /dev/null and b/doc/_static/logo_simons.jpg differ diff --git a/doc/_static/logo_x.png b/doc/_static/logo_x.png new file mode 100644 index 00000000..18aba0bc Binary files /dev/null and b/doc/_static/logo_x.png differ diff --git a/doc/_static/triqs_logo/Icon/JPG/Triqs_Icon_RGB_Black.jpg b/doc/_static/triqs_logo/Icon/JPG/Triqs_Icon_RGB_Black.jpg new file mode 100755 index 00000000..a25819aa Binary files /dev/null and b/doc/_static/triqs_logo/Icon/JPG/Triqs_Icon_RGB_Black.jpg differ diff --git a/doc/_static/triqs_logo/Icon/JPG/Triqs_Icon_RGB_Full.jpg b/doc/_static/triqs_logo/Icon/JPG/Triqs_Icon_RGB_Full.jpg new file mode 100755 index 00000000..8fac42ac Binary files /dev/null and b/doc/_static/triqs_logo/Icon/JPG/Triqs_Icon_RGB_Full.jpg differ diff --git a/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_Black.svg b/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_Black.svg new file mode 100755 index 00000000..ff598488 --- /dev/null +++ b/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_Black.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_Full.svg b/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_Full.svg new file mode 100755 index 00000000..76d6707d --- /dev/null +++ b/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_Full.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_White.svg b/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_White.svg new file mode 100755 index 00000000..4fbd963d --- /dev/null +++ b/doc/_static/triqs_logo/Icon/SVG/Triqs_Icon_RGB_White.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/_static/triqs_logo/Logo/JPG/Triqs_Logo_RGB_Black.jpg b/doc/_static/triqs_logo/Logo/JPG/Triqs_Logo_RGB_Black.jpg new file mode 100755 index 00000000..a9206e03 Binary files /dev/null and b/doc/_static/triqs_logo/Logo/JPG/Triqs_Logo_RGB_Black.jpg differ diff --git a/doc/_static/triqs_logo/Logo/JPG/Triqs_Logo_RGB_Full.jpg b/doc/_static/triqs_logo/Logo/JPG/Triqs_Logo_RGB_Full.jpg new file mode 100755 index 00000000..58e6a815 Binary files /dev/null and b/doc/_static/triqs_logo/Logo/JPG/Triqs_Logo_RGB_Full.jpg differ diff --git a/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_Black.svg b/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_Black.svg new file mode 100755 index 00000000..27ff0f46 --- /dev/null +++ b/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_Black.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_Full.svg b/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_Full.svg new file mode 100755 index 00000000..149bdb6c --- /dev/null +++ b/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_Full.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_White.svg b/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_White.svg new file mode 100755 index 00000000..eb273f97 --- /dev/null +++ b/doc/_static/triqs_logo/Logo/SVG/Triqs_Logo_RGB_White.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/_static/triqs_logo/triqs_favicon.ico b/doc/_static/triqs_logo/triqs_favicon.ico new file mode 100644 index 00000000..9e20d735 Binary files /dev/null and b/doc/_static/triqs_logo/triqs_favicon.ico differ diff --git a/doc/_templates/autosummary_class_template.rst b/doc/_templates/autosummary_class_template.rst new file mode 100644 index 00000000..49fc6786 --- /dev/null +++ b/doc/_templates/autosummary_class_template.rst @@ -0,0 +1,29 @@ +{{ fullname | escape | underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + +{% block methods %} +{% if methods %} +.. rubric:: {{ _('Methods') }} + +.. autosummary:: + :toctree: + {% for item in methods %} + ~{{ name }}.{{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block attributes %} +{% if attributes %} +.. rubric:: {{ _('Attributes') }} + +.. autosummary:: + :toctree: + {% for item in attributes %} + ~{{ name }}.{{ item }} + {%- endfor %} +{% endif %} +{% endblock %} diff --git a/doc/_templates/autosummary_module_template.rst b/doc/_templates/autosummary_module_template.rst new file mode 100644 index 00000000..737206f8 --- /dev/null +++ b/doc/_templates/autosummary_module_template.rst @@ -0,0 +1,68 @@ +{{ fullname | escape | underline}} + +.. automodule:: {{ fullname }} + +{% block functions %} +{% if functions %} +.. rubric:: Functions + +.. autosummary:: + :toctree: + {% for item in functions %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block attributes %} +{% if attributes %} +.. rubric:: Module Attributes + +.. autosummary:: + :toctree: + {% for item in attributes %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block classes %} +{% if classes %} +.. rubric:: {{ _('Classes') }} + +.. autosummary:: + :toctree: + :template: autosummary_class_template.rst + {% for item in classes %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block exceptions %} +{% if exceptions %} +.. rubric:: {{ _('Exceptions') }} + +.. autosummary:: + :toctree: + {% for item in exceptions %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block modules %} +{% if modules %} +.. rubric:: Modules + +.. autosummary:: + :toctree: + :template: autosummary_module_template.rst + :recursive: + + {% for item in modules %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + diff --git a/doc/_templates/sideb.html b/doc/_templates/sideb.html new file mode 100644 index 00000000..b4cc0b15 --- /dev/null +++ b/doc/_templates/sideb.html @@ -0,0 +1,14 @@ +

+ CEA + Ecole Polytechnique +
+ CNRS +ERC + Flatiron Institute +
+ Simons Foundation +

+
+

+ Visit the project on GitHub +

diff --git a/doc/about.rst b/doc/about.rst new file mode 100644 index 00000000..c91ecb86 --- /dev/null +++ b/doc/about.rst @@ -0,0 +1,8 @@ +.. _about: + +About app4triqs +*************** + +An example application using ``cpp2py`` and TRIQS. + +Written and maintained by N. Wentzell with contributions from H. U.R. Strand. diff --git a/doc/conf.py.in b/doc/conf.py.in new file mode 100644 index 00000000..3eb0de9d --- /dev/null +++ b/doc/conf.py.in @@ -0,0 +1,144 @@ +# -*- coding: utf-8 -*- +# +# TRIQS documentation build configuration file + +import sys +sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext") + +# exclude these folders from scanning by sphinx +exclude_patterns = ['_templates'] + +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.mathjax', + 'sphinx.ext.intersphinx', + 'sphinx.ext.doctest', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', + 'sphinx.ext.autosummary', + 'sphinx.ext.githubpages', + 'sphinx_autorun', + 'nbsphinx', + 'myst_parser', + 'matplotlib.sphinxext.plot_directive', + 'numpydoc'] + +myst_enable_extensions = [ + "amsmath", + "colon_fence", + "deflist", + "dollarmath", + "html_admonition", + "html_image", + "linkify", + "replacements", + "smartquotes", + "substitution", + "tasklist", +] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +source_suffix = '.rst' + +# Turn on sphinx.ext.autosummary +autosummary_generate = True +autosummary_imported_members=False + +project = '@PROJECT_NAME@' +version = '@PROJECT_VERSION@' + +# this makes the current project version available as var in every rst file +rst_epilog = """ +.. |PROJECT_VERSION| replace:: {version} +""".format( +version = version, +) + +copyright = '2018-2021 The Simons Foundation, authors: A. Hampel, O. Parcollet, D. Simons, H. Strand, N. Wentzell' + +mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=default" +templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates'] + +# this requires the sphinx_rtd_theme to be installed via pip +html_theme = 'sphinx_rtd_theme' +# this loads the custom css file to change the page width +html_style = 'css/custom.css' + +html_favicon = '@CMAKE_CURRENT_SOURCE_DIR@/_static/triqs_logo/triqs_favicon.ico' +#html_logo = '@CMAKE_CURRENT_SOURCE_DIR@/logos/logo.png' + +# options for the the rtd theme +html_theme_options = { + 'logo_only': False, + 'display_version': True, + 'prev_next_buttons_location': 'bottom', + 'style_external_links': False, + 'vcs_pageview_mode': '', + 'style_nav_header_background': '#7E588A', + # Toc options + 'collapse_navigation': False, + 'sticky_navigation': True, + 'navigation_depth': 5, + 'includehidden': True, + 'titles_only': False +} + +html_show_sphinx = False + +html_context = {'header_title': '@PROJECT_NAME@'} + +html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static'] +html_sidebars = {'index': ['sideb.html', 'searchbox.html']} + +htmlhelp_basename = '@PROJECT_NAME@doc' + +# Plot options +plot_include_source = True +plot_html_show_source_link = False +plot_html_show_formats = False + +intersphinx_mapping = {'python': ('https://docs.python.org/3.11', None), 'triqslibs': ('https://triqs.github.io/triqs/latest', None)} + +# open links in new tab instead of same window +from sphinx.writers.html import HTMLTranslator +from docutils import nodes +from docutils.nodes import Element + +class PatchedHTMLTranslator(HTMLTranslator): + + def visit_reference(self, node: Element) -> None: + atts = {'class': 'reference'} + if node.get('internal') or 'refuri' not in node: + atts['class'] += ' internal' + else: + atts['class'] += ' external' + # --------------------------------------------------------- + # Customize behavior (open in new tab, secure linking site) + atts['target'] = '_blank' + atts['rel'] = 'noopener noreferrer' + # --------------------------------------------------------- + if 'refuri' in node: + atts['href'] = node['refuri'] or '#' + if self.settings.cloak_email_addresses and atts['href'].startswith('mailto:'): + atts['href'] = self.cloak_mailto(atts['href']) + self.in_mailto = True + else: + assert 'refid' in node, \ + 'References must have "refuri" or "refid" attribute.' + atts['href'] = '#' + node['refid'] + if not isinstance(node.parent, nodes.TextElement): + assert len(node) == 1 and isinstance(node[0], nodes.image) + atts['class'] += ' image-reference' + if 'reftitle' in node: + atts['title'] = node['reftitle'] + if 'target' in node: + atts['target'] = node['target'] + self.body.append(self.starttag(node, 'a', '', **atts)) + + if node.get('secnumber'): + self.body.append(('%s' + self.secnumber_suffix) % + '.'.join(map(str, node['secnumber']))) + +def setup(app): + app.set_translator('html', PatchedHTMLTranslator) diff --git a/doc/documentation.rst b/doc/documentation.rst new file mode 100644 index 00000000..a05d717f --- /dev/null +++ b/doc/documentation.rst @@ -0,0 +1,29 @@ +.. _documentation: + +Documentation +************* + + +.. math:: + + (a + b)^2 &= (a + b)(a + b) \\ + &= a^2 + 2ab + b^2 + + +C++ reference manual +==================== + +.. toctree:: + :maxdepth: 5 + + cpp2rst_generated/contents + +Python reference manual +======================= + +.. autosummary:: + :toctree: _autosummary + :template: autosummary_module_template.rst + :recursive: + + app4triqs diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 00000000..94054b86 --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,33 @@ +.. _welcome: + +app4triqs +********* + +.. sidebar:: app4triqs |PROJECT_VERSION| + + This is the homepage of app4triqs |PROJECT_VERSION|. + For changes see the :ref:`changelog page `. + + .. image:: _static/logo_github.png + :width: 75% + :align: center + :target: https://github.com/triqs/app4triqs + + +An example application using cpp2py and :ref:`TRIQS `. + +This documentation is generated based on `rst `_ files +and the comments in the sources and headers. + +Learn how to use app4triqs in the :ref:`documentation`. + + +.. toctree:: + :maxdepth: 2 + :hidden: + + install + documentation + issues + ChangeLog.md + about diff --git a/doc/install.rst b/doc/install.rst new file mode 100644 index 00000000..1c7766b7 --- /dev/null +++ b/doc/install.rst @@ -0,0 +1,77 @@ +.. highlight:: bash + +.. _install: + +Install app4triqs +******************* + +Compiling app4triqs from source +=============================== + +.. note:: To guarantee reproducibility in scientific calculations we strongly recommend the use of a stable `release `_ of both TRIQS and its applications. + +Prerequisites +------------- + +#. The :ref:`TRIQS ` library, see :ref:`TRIQS installation instruction `. + In the following, we assume that TRIQS is installed in the directory ``path_to_triqs``. + +Installation steps +------------------ + +#. Download the source code of the latest stable version by cloning the ``TRIQS/app4triqs`` repository from GitHub:: + + $ git clone https://github.com/TRIQS/app4triqs app4triqs.src + +#. Create and move to a new directory where you will compile the code:: + + $ mkdir app4triqs.build && cd app4triqs.build + +#. Ensure that your shell contains the TRIQS environment variables by sourcing the ``triqsvars.sh`` file from your TRIQS installation:: + + $ source path_to_triqs/share/triqs/triqsvars.sh + +#. In the build directory call cmake, including any additional custom CMake options, see below:: + + $ cmake ../app4triqs.src + +#. Compile the code, run the tests and install the application:: + + $ make + $ make test + $ make install + +Version compatibility +--------------------- + +Keep in mind that the version of ``app4triqs`` must be compatible with your TRIQS library version, +see :ref:`TRIQS website `. +In particular the Major and Minor Version numbers have to be the same. +To use a particular version, go into the directory with the sources, and look at all available versions:: + + $ cd app4triqs.src && git tag + +Checkout the version of the code that you want:: + + $ git checkout 2.1.0 + +and follow steps 2 to 4 above to compile the code. + +Custom CMake options +-------------------- + +The compilation of ``app4triqs`` can be configured using CMake-options:: + + cmake ../app4triqs.src -DOPTION1=value1 -DOPTION2=value2 ... + ++-----------------------------------------------------------------+-----------------------------------------------+ +| Options | Syntax | ++=================================================================+===============================================+ +| Specify an installation path other than path_to_triqs | -DCMAKE_INSTALL_PREFIX=path_to_app4triqs | ++-----------------------------------------------------------------+-----------------------------------------------+ +| Build in Debugging Mode | -DCMAKE_BUILD_TYPE=Debug | ++-----------------------------------------------------------------+-----------------------------------------------+ +| Disable testing (not recommended) | -DBuild_Tests=OFF | ++-----------------------------------------------------------------+-----------------------------------------------+ +| Build the documentation | -DBuild_Documentation=ON | ++-----------------------------------------------------------------+-----------------------------------------------+ diff --git a/doc/issues.rst b/doc/issues.rst new file mode 100644 index 00000000..bdd0d5c2 --- /dev/null +++ b/doc/issues.rst @@ -0,0 +1,23 @@ +.. _issues: + +Reporting issues +**************** + +Please report all problems and bugs directly at the github issue page +``_. In order to make it easier for us +to solve the issue please follow these guidelines: + +#. In all cases specify which version of the application you are using. You can + find the version number in the file :file:`CMakeLists.txt` at the root of the + application sources. + +#. If you have a problem during the installation, give us information about + your operating system and the compiler you are using. Include the outputs of + the ``cmake`` and ``make`` commands as well as the ``CMakeCache.txt`` file + which is in the build directory. Please include these outputs in a + `gist `_ file referenced in the issue. + +#. If you are experiencing a problem during the execution of the application, provide + a script which allows to quickly reproduce the problem. + +Thanks! diff --git a/doc/sphinxext/sphinx_autorun/__init__.py b/doc/sphinxext/sphinx_autorun/__init__.py new file mode 100644 index 00000000..1afa0377 --- /dev/null +++ b/doc/sphinxext/sphinx_autorun/__init__.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +""" +sphinxcontirb.autorun +~~~~~~~~~~~~~~~~~~~~~~ + +Run the code and insert stdout after the code block. +""" +import os +from subprocess import PIPE, Popen + +from docutils import nodes +from docutils.parsers.rst import Directive, directives +from sphinx.errors import SphinxError + +from sphinx_autorun import version + +__version__ = version.version + + +class RunBlockError(SphinxError): + category = 'runblock error' + + +class AutoRun(object): + here = os.path.abspath(__file__) + pycon = os.path.join(os.path.dirname(here), 'pycon.py') + config = { + 'pycon': 'python ' + pycon, + 'pycon_prefix_chars': 4, + 'pycon_show_source': False, + 'console': 'bash', + 'console_prefix_chars': 1, + } + + @classmethod + def builder_init(cls, app): + cls.config.update(app.builder.config.autorun_languages) + + +class RunBlock(Directive): + has_content = True + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = { + 'linenos': directives.flag, + } + + def run(self): + config = AutoRun.config + language = self.arguments[0] + + if language not in config: + raise RunBlockError('Unknown language %s' % language) + + # Get configuration values for the language + args = config[language].split() + input_encoding = config.get(language+'_input_encoding', 'utf8') + output_encoding = config.get(language+'_output_encoding', 'utf8') + prefix_chars = config.get(language+'_prefix_chars', 0) + show_source = config.get(language+'_show_source', True) + + # Build the code text + proc = Popen(args, bufsize=1, stdin=PIPE, stdout=PIPE, stderr=PIPE) + codelines = (line[prefix_chars:] for line in self.content) + code = u'\n'.join(codelines).encode(input_encoding) + + # Run the code + stdout, stderr = proc.communicate(code) + + # Process output + if stdout: + out = stdout.decode(output_encoding) + if stderr: + out = stderr.decode(output_encoding) + + # Get the original code with prefixes + if show_source: + code = u'\n'.join(self.content) + code_out = u'\n'.join((code, out)) + else: + code_out = out + + literal = nodes.literal_block(code_out, code_out) + literal['language'] = language + literal['linenos'] = 'linenos' in self.options + return [literal] + + +def setup(app): + app.add_directive('runblock', RunBlock) + app.connect('builder-inited', AutoRun.builder_init) + app.add_config_value('autorun_languages', AutoRun.config, 'env') diff --git a/doc/sphinxext/sphinx_autorun/pycon.py b/doc/sphinxext/sphinx_autorun/pycon.py new file mode 100644 index 00000000..c0edf861 --- /dev/null +++ b/doc/sphinxext/sphinx_autorun/pycon.py @@ -0,0 +1,31 @@ +import sys +from code import InteractiveInterpreter + + +def main(): + """ + Print lines of input along with output. + """ + source_lines = (line.rstrip() for line in sys.stdin) + console = InteractiveInterpreter() + source = '' + try: + while True: + source = next(source_lines) + # Allow the user to ignore specific lines of output. + if not source.endswith('# ignore'): + print('>>>', source) + more = console.runsource(source) + while more: + next_line = next(source_lines) + print('...', next_line) + source += '\n' + next_line + more = console.runsource(source) + except StopIteration: + if more: + print('... ') + more = console.runsource(source + '\n') + + +if __name__ == '__main__': + main() diff --git a/doc/sphinxext/sphinx_autorun/version.py b/doc/sphinxext/sphinx_autorun/version.py new file mode 100644 index 00000000..433d173a --- /dev/null +++ b/doc/sphinxext/sphinx_autorun/version.py @@ -0,0 +1,4 @@ +# coding: utf-8 +# file generated by setuptools_scm +# don't change, don't track in version control +version = '1.1.1' diff --git a/doc/sphinxext/triqs_example/triqs_example.py b/doc/sphinxext/triqs_example/triqs_example.py new file mode 100644 index 00000000..2c90ac4c --- /dev/null +++ b/doc/sphinxext/triqs_example/triqs_example.py @@ -0,0 +1,123 @@ +import tempfile +# -*- coding: utf-8 -*- +# seems to be executed at the level of the conf.py +# so we need to link the lib at that place... +""" +""" +import os +import codecs +from os import path +from subprocess import Popen,PIPE +from docutils import nodes +from docutils.parsers.rst import Directive +from docutils.parsers.rst import directives +from sphinx.errors import SphinxError + +class TriqsExampleError(SphinxError): + category = 'triqs_example error' + +class TriqsExampleRun: + #here = os.path.abspath(__file__) + #pycon = os.path.join(os.path.dirname(here),'pycon.py') + config = dict( + ) + @classmethod + def builder_init(cls,app): + #cls.config.update(app.builder.config.autorun_languages) + #cls.config.update(app.builder.config.autocompile_opts) + pass + +class TriqsExample(Directive): + has_content = True + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = { + 'linenos': directives.flag, + } + + def run(self): + document = self.state.document + filename = self.arguments[0] + if not document.settings.file_insertion_enabled: + return [document.reporter.warning('File insertion disabled', + line=self.lineno)] + env = document.settings.env + if filename.startswith('/') or filename.startswith(os.sep): + rel_fn = filename[1:] + else: + docdir = path.dirname(env.doc2path(env.docname, base=None)) + rel_fn = path.normpath(path.join(docdir, filename)) + try: + fn = path.join(env.srcdir, rel_fn) + except UnicodeDecodeError: + # the source directory is a bytestring with non-ASCII characters; + # let's try to encode the rel_fn in the file system encoding + rel_fn = rel_fn.encode(sys.getfilesystemencoding()) + fn = path.join(env.srcdir, rel_fn) + + encoding = self.options.get('encoding', env.config.source_encoding) + try: + f = codecs.open(fn, 'rU', encoding) + lines = f.readlines() + f.close() + except (IOError, OSError): + return [document.reporter.warning( + 'Include file %r not found or reading it failed' % filename, + line=self.lineno)] + except UnicodeError: + return [document.reporter.warning( + 'Encoding %r used for reading included file %r seems to ' + 'be wrong, try giving an :encoding: option' % + (encoding, filename))] + + config = TriqsExampleRun.config + + # Get configuration values for the language + input_encoding = 'utf8' #config.get(language+'_input_encoding','ascii') + output_encoding = 'utf8' #config.get(language+'_output_encoding','ascii') + show_source = True + + # Build the code text + code = ''.join(lines).strip() + filename_clean = filename.rsplit('.',1)[0] + if filename_clean.startswith('./') : filename_clean = filename_clean[2:] + #print "Running the example ....",filename_clean + #print "Root ?", env.doc2path(env.docname, base=None) + + import subprocess as S + error = True + try : + stdout ='' + #resout = S.check_output("./example_bin/doc_%s"%(filename_clean) ,stderr=S.STDOUT,shell=True) + resout = S.check_output("./%s/doc_%s"%(docdir,filename_clean) ,stderr=S.STDOUT,shell=True) + if resout : + stdout = '---------- Result is -------\n' + resout.strip() + error = False + except S.CalledProcessError as E : + stdout ='---------- RunTime error -------\n' + stdout += E.output + + # Process output + if stdout: + stdout = stdout.decode(output_encoding,'ignore') + out = ''.join(stdout).decode(output_encoding) + else: + out = '' #.join(stderr).decode(output_encoding) + + # Get the original code with prefixes + code_out = '\n'.join((code,out)) + + if error : # report on console + print(" Error in processing ") + print(code_out) + + literal = nodes.literal_block(code_out,code_out) + literal['language'] = 'c' + literal['linenos'] = 'linenos' in self.options + return [literal] + +def setup(app): + app.add_directive('triqs_example', TriqsExample) + app.connect('builder-inited',TriqsExampleRun.builder_init) + diff --git a/doc/themes/triqs/layout.html b/doc/themes/triqs/layout.html new file mode 100644 index 00000000..0275e11a --- /dev/null +++ b/doc/themes/triqs/layout.html @@ -0,0 +1,52 @@ +{# + layout.html + ~~~~~~~~~~~ + + TRIQS layout template heavily based on the sphinxdoc theme. + + :copyright: Copyright 2013 by the TRIQS team. + :copyright: Copyright 2007-2013 by the Sphinx team. + :license: BSD, see LICENSE for details. +#} +{%- extends "basic/layout.html" %} + +{# put the sidebar before the body #} +{% block sidebar1 %}{{ sidebar() }}{% endblock %} +{% block sidebar2 %}{% endblock %} + +{% block extrahead %} + + + + +{{ super() }} +{%- if not embedded %} + +{%- endif %} +{% endblock %} + +{% block rootrellink %} +
  • Home »
  • +{% endblock %} + +{% block header %} + +{% endblock %} diff --git a/doc/themes/triqs/static/bodybg.png b/doc/themes/triqs/static/bodybg.png new file mode 100644 index 00000000..506b6f90 Binary files /dev/null and b/doc/themes/triqs/static/bodybg.png differ diff --git a/doc/themes/triqs/static/cufon-yui.js b/doc/themes/triqs/static/cufon-yui.js new file mode 100644 index 00000000..935614e1 --- /dev/null +++ b/doc/themes/triqs/static/cufon-yui.js @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2009 Simo Kinnunen. + * Licensed under the MIT license. + * + * @version 1.09i + */ +var Cufon=(function(){var m=function(){return m.replace.apply(null,arguments)};var x=m.DOM={ready:(function(){var C=false,E={loaded:1,complete:1};var B=[],D=function(){if(C){return}C=true;for(var F;F=B.shift();F()){}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",D,false);window.addEventListener("pageshow",D,false)}if(!window.opera&&document.readyState){(function(){E[document.readyState]?D():setTimeout(arguments.callee,10)})()}if(document.readyState&&document.createStyleSheet){(function(){try{document.body.doScroll("left");D()}catch(F){setTimeout(arguments.callee,1)}})()}q(window,"load",D);return function(F){if(!arguments.length){D()}else{C?F():B.push(F)}}})(),root:function(){return document.documentElement||document.body}};var n=m.CSS={Size:function(C,B){this.value=parseFloat(C);this.unit=String(C).match(/[a-z%]*$/)[0]||"px";this.convert=function(D){return D/B*this.value};this.convertFrom=function(D){return D/this.value*B};this.toString=function(){return this.value+this.unit}},addClass:function(C,B){var D=C.className;C.className=D+(D&&" ")+B;return C},color:j(function(C){var B={};B.color=C.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(E,D,F){B.opacity=parseFloat(F);return"rgb("+D+")"});return B}),fontStretch:j(function(B){if(typeof B=="number"){return B}if(/%$/.test(B)){return parseFloat(B)/100}return{"ultra-condensed":0.5,"extra-condensed":0.625,condensed:0.75,"semi-condensed":0.875,"semi-expanded":1.125,expanded:1.25,"extra-expanded":1.5,"ultra-expanded":2}[B]||1}),getStyle:function(C){var B=document.defaultView;if(B&&B.getComputedStyle){return new a(B.getComputedStyle(C,null))}if(C.currentStyle){return new a(C.currentStyle)}return new a(C.style)},gradient:j(function(F){var G={id:F,type:F.match(/^-([a-z]+)-gradient\(/)[1],stops:[]},C=F.substr(F.indexOf("(")).match(/([\d.]+=)?(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)/ig);for(var E=0,B=C.length,D;E0){E=" "+E}}else{if(B400}if(I==500){I=400}for(var J in G){if(!k(G,J)){continue}J=parseInt(J,10);if(!F||JD){D=J}K.push(J)}if(ID){I=D}K.sort(function(M,L){return(E?(M>=I&&L>=I)?ML:(M<=I&&L<=I)?M>L:Mcufoncanvas{text-indent:0;}@media screen{cvml\\:shape,cvml\\:rect,cvml\\:fill,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute;}cufoncanvas{position:absolute;text-align:left;}cufon{display:inline-block;position:relative;vertical-align:'+(h?"middle":"text-bottom")+";}cufon cufontext{position:absolute;left:-10000in;font-size:1px;}a cufon{cursor:pointer}}@media print{cufon cufoncanvas{display:none;}}").replace(/;/g,"!important;"));function c(i,j){return a(i,/(?:em|ex|%)$|^[a-z-]+$/i.test(j)?"1em":j)}function a(l,m){if(m==="0"){return 0}if(/px$/i.test(m)){return parseFloat(m)}var k=l.style.left,j=l.runtimeStyle.left;l.runtimeStyle.left=l.currentStyle.left;l.style.left=m.replace("%","em");var i=l.style.pixelLeft;l.style.left=k;l.runtimeStyle.left=j;return i}function f(l,k,j,n){var i="computed"+n,m=k[i];if(isNaN(m)){m=k.get(n);k[i]=m=(m=="normal")?0:~~j.convertFrom(a(l,m))}return m}var g={};function d(p){var q=p.id;if(!g[q]){var n=p.stops,o=document.createElement("cvml:fill"),i=[];o.type="gradient";o.angle=180;o.focus="0";o.method="sigma";o.color=n[0][1];for(var m=1,l=n.length-1;mO){O=K}if(I>N){N=I}if(K":{"w":232},"?":{"d":"413,-133r0,133r-192,0r0,-133r192,0xm221,-188v-13,-173,78,-281,237,-282r341,0v53,0,80,-24,80,-71v0,-47,-27,-71,-80,-71r-799,0r0,-166r817,-1v141,-1,227,93,227,236v0,149,-87,234,-227,234r-315,0v-67,-1,-99,45,-89,121r-192,0","w":1218},"@":{"d":"305,-388v0,55,25,70,85,70r436,0r0,-146r-439,0v-55,0,-82,25,-82,76xm339,-62v-218,3,-334,-116,-339,-327v-4,-168,93,-282,227,-315v106,-26,574,-16,605,-3v56,23,105,70,105,151r0,316r-579,0v-98,2,-164,-54,-164,-148v0,-106,69,-154,188,-154r444,0v-2,-97,-62,-97,-185,-100v-135,-3,-342,-4,-427,22v-86,26,-136,115,-136,231v0,166,96,250,261,250r483,0r0,77r-483,0","w":1060},"A":{"d":"754,-341v0,-61,-24,-84,-89,-84r-626,0r0,-131r667,0v135,5,215,66,215,217r0,339r-745,0v-108,1,-176,-63,-176,-171v0,-107,69,-171,176,-170r578,0xm754,-131r0,-85r-534,0v-35,0,-53,14,-53,43v0,28,18,42,53,42r534,0","w":1096},"B":{"d":"969,-278v0,176,-93,278,-267,278r-702,0r0,-778r167,0r0,222r535,0v170,-2,267,101,267,278xm794,-278v0,-81,-38,-139,-114,-139r-513,0r0,278r513,0v76,0,114,-58,114,-139","w":1097},"C":{"d":"0,-278v0,-173,94,-278,267,-278r595,0r0,139r-573,0v-76,0,-114,58,-114,139v0,81,38,139,114,139r573,0r0,139r-595,0v-173,1,-267,-105,-267,-278","w":1022},"D":{"d":"0,-278v-1,-176,93,-278,267,-278r521,0r0,-222r167,0r0,778r-688,0v-171,2,-266,-102,-267,-278xm175,-278v0,81,38,139,114,139r499,0r0,-278r-499,0v-76,0,-114,58,-114,139","w":1130},"E":{"d":"176,-216v24,58,48,85,113,85r581,0r0,131r-603,0v-173,1,-267,-105,-267,-278v0,-173,94,-278,267,-278r603,0r0,131r-581,0v-65,4,-87,27,-113,84r694,0r0,125r-694,0","w":1022},"F":{"d":"105,-341v-10,-142,29,-222,167,-222r501,1r0,130r-423,0v-60,-4,-81,31,-78,91r501,-2r0,131r-501,2r0,425r-167,0r0,-425r-105,0r0,-131r105,0","w":906},"G":{"d":"0,-278v0,-173,94,-278,267,-278r770,1r0,571v3,126,-82,208,-203,208r-773,-2r0,-130r743,1v55,0,68,-33,66,-93r-603,0v-173,1,-267,-105,-267,-278xm175,-278v0,81,37,139,114,139r581,-2r0,-275r-581,-1v-76,0,-114,58,-114,139","w":1204},"H":{"d":"735,-359v1,-35,-25,-58,-58,-58r-510,0r0,417r-167,0r0,-778r167,0r0,222r537,0v116,-4,198,68,198,170r0,386r-167,0r0,-359"},"I":{"d":"167,0r-167,0r0,-556r167,0r0,556xm167,-612r-167,0r0,-133r167,0r0,133","w":334},"J":{"d":"743,-612r-167,0r0,-133r167,0r0,133xm743,40v-5,114,-100,182,-221,182r-522,0r0,-139r510,0v44,0,66,-24,66,-73r0,-566r167,0r0,596","w":916},"K":{"d":"767,-481r146,0r0,-77r-146,0r0,77xm1040,-2v25,-199,-69,-334,-263,-334r-610,1r0,-442r-167,0r0,775r167,0r0,-195r588,0v95,-4,128,100,107,195r178,0xm914,-481v0,97,-49,145,-146,145r0,-145r146,0xm767,-481v4,77,-98,149,-175,146r175,0r0,-146","w":1195},"L":{"d":"183,-299v0,80,47,132,132,132r523,0r0,167r-569,0v-174,4,-268,-107,-268,-282r0,-276r182,0r0,259","w":996},"M":{"d":"961,-556v116,-4,197,66,197,170r0,386r-167,0r0,-359v0,-39,-19,-58,-58,-58r-273,0r0,417r-167,0r0,-417r-326,0r0,417r-167,0r0,-556r961,0","w":1312},"N":{"d":"688,-556v116,-4,198,68,198,170r0,386r-167,0r0,-359v0,-39,-19,-58,-58,-58r-494,0r0,417r-167,0r0,-556r688,0","w":1057},"O":{"d":"7,-368v-3,-111,96,-207,207,-207r536,0v112,-3,207,95,207,207r0,162v3,111,-96,207,-207,207r-536,0v-110,3,-207,-97,-207,-207r0,-162xm264,-445v-45,-1,-85,40,-85,85r0,138v-1,45,40,85,85,85r428,0v45,1,85,-40,85,-85r0,-138v1,-45,-40,-85,-85,-85r-428,0","w":1104},"P":{"d":"986,-278v1,176,-93,278,-267,278r-552,0r0,222r-167,0r0,-778r719,0v171,-2,266,102,267,278xm811,-278v0,-81,-38,-139,-114,-139r-530,0r0,278r530,0v76,0,114,-58,114,-139","w":1141},"Q":{"d":"0,-278v-1,-176,93,-278,267,-278r777,2r0,776r-167,0r0,-223r-610,1v-171,2,-266,-102,-267,-278xm175,-278v0,81,38,139,114,139r588,-1r0,-275r-588,-2v-77,0,-114,58,-114,139","w":1211},"R":{"d":"610,-558v134,0,213,83,197,228r-167,0v4,-51,-8,-86,-58,-86r-415,-1r0,417r-167,0r0,-556","w":950},"S":{"d":"913,-170v0,103,-65,170,-175,170r-738,0r0,-131r705,1v37,0,55,-14,55,-43v0,-28,-18,-42,-55,-42r-530,-1v-102,1,-175,-66,-175,-169v0,-101,66,-171,175,-171r708,0r0,131r-675,0v-37,0,-55,14,-55,42v0,28,18,42,55,42r530,1v102,-1,175,67,175,170","w":1039},"T":{"d":"267,-208v1,58,20,77,78,77r425,0r0,131r-504,0v-116,-3,-166,-47,-166,-167r0,-258r-100,0r0,-131r100,0r0,-222r167,0r0,222r503,0r0,131r-503,0r0,217","w":917},"U":{"d":"198,0v-119,6,-198,-71,-198,-170r0,-386r167,0r0,358v0,39,19,59,58,59r506,0r0,-417r167,0r0,556r-700,0"},"V":{"d":"167,-139r564,0r0,-417r167,0r0,556r-898,0r0,-556r167,0r0,417"},"W":{"d":"197,0v-115,4,-197,-68,-197,-170r0,-386r167,0r0,358v0,39,19,59,58,59r273,0r0,-417r167,0r0,417r326,0r0,-417r167,0r0,556r-961,0","w":1323},"X":{"d":"132,-208r646,0r0,-131r-646,0r0,131xm1,-138v-2,-70,61,-133,131,-131r0,131r-131,0xm0,-138r132,0r0,138r-132,0r0,-138xm1,-396v-2,71,61,133,131,131r0,-131r-131,0xm0,-396r132,0r0,-158r-132,0r0,158xm909,-138v2,-70,-61,-133,-131,-131r0,131r131,0xm910,-138r-132,0r0,138r132,0r0,-138xm909,-396v2,71,-61,133,-131,131r0,-131r131,0xm910,-396r-132,0r0,-158r132,0r0,158xm133,-454v-2,62,53,117,115,115r-115,0r0,-115xm133,-94v-2,-62,53,-117,115,-115r-115,0r0,115xm777,-454v2,62,-53,117,-115,115r115,0r0,-115xm778,-93v2,-62,-54,-117,-115,-115r115,0r0,115","w":1017},"Y":{"d":"754,92v53,-1,68,-31,66,-92r-622,0v-119,6,-198,-71,-198,-170r0,-386r167,0r0,336v-1,49,32,82,81,81r572,0r0,-417r167,0r0,576v3,124,-85,207,-204,207r-769,0r0,-135r740,0","w":1169},"Z":{"d":"0,-170v0,101,66,170,175,170r738,0r0,-131r-704,1v-37,0,-56,-14,-56,-43v0,-28,19,-42,56,-42r529,-1v102,1,175,-66,175,-169v0,-102,-66,-171,-175,-171r-707,-2r0,131r674,2v37,0,55,14,55,42v0,28,-18,42,-55,42r-530,1v-102,-1,-175,67,-175,170","w":1039},"[":{"d":"0,-931r306,0r0,153r-153,0r0,778r153,0r0,153r-306,0r0,-1084","w":361},"\\":{"d":"877,0r-692,-778r-185,0r681,778r196,0","w":942},"]":{"w":366},"^":{"w":406},"_":{"d":"0,61r1001,0r0,161r-1001,0r0,-161","w":1172},"`":{"d":"0,-806r94,0r112,111r-95,0","w":261},"a":{"d":"754,-341v0,-61,-24,-84,-89,-84r-626,0r0,-131r667,0v135,5,215,66,215,217r0,339r-745,0v-108,1,-176,-63,-176,-171v0,-107,69,-171,176,-170r578,0xm754,-131r0,-85r-534,0v-35,0,-53,14,-53,43v0,28,18,42,53,42r534,0","w":1096},"b":{"d":"969,-278v0,176,-93,278,-267,278r-702,0r0,-778r167,0r0,222r535,0v170,-2,267,101,267,278xm794,-278v0,-81,-38,-139,-114,-139r-513,0r0,278r513,0v76,0,114,-58,114,-139","w":1097},"c":{"d":"0,-278v0,-173,94,-278,267,-278r595,0r0,139r-573,0v-76,0,-114,58,-114,139v0,81,38,139,114,139r573,0r0,139r-595,0v-173,1,-267,-105,-267,-278","w":1022},"d":{"d":"0,-278v-1,-176,93,-278,267,-278r521,0r0,-222r167,0r0,778r-688,0v-171,2,-266,-102,-267,-278xm175,-278v0,81,38,139,114,139r499,0r0,-278r-499,0v-76,0,-114,58,-114,139","w":1130},"e":{"d":"176,-216v24,58,48,85,113,85r581,0r0,131r-603,0v-173,1,-267,-105,-267,-278v0,-173,94,-278,267,-278r603,0r0,131r-581,0v-65,4,-87,27,-113,84r694,0r0,125r-694,0","w":1022},"f":{"d":"105,-341v-10,-142,29,-222,167,-222r501,1r0,130r-423,0v-60,-4,-81,31,-78,91r501,-2r0,131r-501,2r0,425r-167,0r0,-425r-105,0r0,-131r105,0","w":906},"g":{"d":"0,-278v0,-173,94,-278,267,-278r770,1r0,571v3,126,-82,208,-203,208r-773,-2r0,-130r743,1v55,0,68,-33,66,-93r-603,0v-173,1,-267,-105,-267,-278xm175,-278v0,81,37,139,114,139r581,-2r0,-275r-581,-1v-76,0,-114,58,-114,139","w":1204},"h":{"d":"735,-359v1,-35,-25,-58,-58,-58r-510,0r0,417r-167,0r0,-778r167,0r0,222r537,0v116,-4,198,68,198,170r0,386r-167,0r0,-359"},"i":{"d":"167,0r-167,0r0,-556r167,0r0,556xm167,-612r-167,0r0,-133r167,0r0,133","w":334},"j":{"d":"743,-612r-167,0r0,-133r167,0r0,133xm743,40v-5,114,-100,182,-221,182r-522,0r0,-139r510,0v44,0,66,-24,66,-73r0,-566r167,0r0,596","w":916},"k":{"d":"767,-481r146,0r0,-77r-146,0r0,77xm1040,-2v25,-199,-69,-334,-263,-334r-610,1r0,-442r-167,0r0,775r167,0r0,-195r588,0v95,-4,128,100,107,195r178,0xm914,-481v0,97,-49,145,-146,145r0,-145r146,0xm767,-481v4,77,-98,149,-175,146r175,0r0,-146","w":1195},"l":{"d":"183,-299v0,80,47,132,132,132r523,0r0,167r-569,0v-174,4,-268,-107,-268,-282r0,-276r182,0r0,259","w":996},"m":{"d":"961,-556v116,-4,197,66,197,170r0,386r-167,0r0,-359v0,-39,-19,-58,-58,-58r-273,0r0,417r-167,0r0,-417r-326,0r0,417r-167,0r0,-556r961,0","w":1312},"n":{"d":"688,-556v116,-4,198,68,198,170r0,386r-167,0r0,-359v0,-39,-19,-58,-58,-58r-494,0r0,417r-167,0r0,-556r688,0","w":1057},"o":{"d":"7,-368v-3,-111,96,-207,207,-207r536,0v112,-3,207,95,207,207r0,162v3,111,-96,207,-207,207r-536,0v-110,3,-207,-97,-207,-207r0,-162xm264,-445v-45,-1,-85,40,-85,85r0,138v-1,45,40,85,85,85r428,0v45,1,85,-40,85,-85r0,-138v1,-45,-40,-85,-85,-85r-428,0","w":1104},"p":{"d":"986,-278v1,176,-93,278,-267,278r-552,0r0,222r-167,0r0,-778r719,0v171,-2,266,102,267,278xm811,-278v0,-81,-38,-139,-114,-139r-530,0r0,278r530,0v76,0,114,-58,114,-139","w":1141},"q":{"d":"0,-278v-1,-176,93,-278,267,-278r777,2r0,776r-167,0r0,-223r-610,1v-171,2,-266,-102,-267,-278xm175,-278v0,81,38,139,114,139r588,-1r0,-275r-588,-2v-77,0,-114,58,-114,139","w":1211},"r":{"d":"610,-558v134,0,213,83,197,228r-167,0v4,-51,-8,-86,-58,-86r-415,-1r0,417r-167,0r0,-556","w":950},"s":{"d":"913,-170v0,103,-65,170,-175,170r-738,0r0,-131r705,1v37,0,55,-14,55,-43v0,-28,-18,-42,-55,-42r-530,-1v-102,1,-175,-66,-175,-169v0,-101,66,-171,175,-171r708,0r0,131r-675,0v-37,0,-55,14,-55,42v0,28,18,42,55,42r530,1v102,-1,175,67,175,170","w":1039},"t":{"d":"267,-208v1,58,20,77,78,77r425,0r0,131r-504,0v-116,-3,-166,-47,-166,-167r0,-258r-100,0r0,-131r100,0r0,-222r167,0r0,222r503,0r0,131r-503,0r0,217","w":917},"u":{"d":"198,0v-119,6,-198,-71,-198,-170r0,-386r167,0r0,358v0,39,19,59,58,59r506,0r0,-417r167,0r0,556r-700,0"},"v":{"d":"167,-139r564,0r0,-417r167,0r0,556r-898,0r0,-556r167,0r0,417"},"w":{"d":"197,0v-115,4,-197,-68,-197,-170r0,-386r167,0r0,358v0,39,19,59,58,59r273,0r0,-417r167,0r0,417r326,0r0,-417r167,0r0,556r-961,0","w":1323},"x":{"d":"132,-208r646,0r0,-131r-646,0r0,131xm1,-138v-2,-70,61,-133,131,-131r0,131r-131,0xm0,-138r132,0r0,138r-132,0r0,-138xm1,-396v-2,71,61,133,131,131r0,-131r-131,0xm0,-396r132,0r0,-158r-132,0r0,158xm909,-138v2,-70,-61,-133,-131,-131r0,131r131,0xm910,-138r-132,0r0,138r132,0r0,-138xm909,-396v2,71,-61,133,-131,131r0,-131r131,0xm910,-396r-132,0r0,-158r132,0r0,158xm133,-454v-2,62,53,117,115,115r-115,0r0,-115xm133,-94v-2,-62,53,-117,115,-115r-115,0r0,115xm777,-454v2,62,-53,117,-115,115r115,0r0,-115xm778,-93v2,-62,-54,-117,-115,-115r115,0r0,115","w":1017},"y":{"d":"754,92v53,-1,68,-31,66,-92r-622,0v-119,6,-198,-71,-198,-170r0,-386r167,0r0,336v-1,49,32,82,81,81r572,0r0,-417r167,0r0,576v3,124,-85,207,-204,207r-769,0r0,-135r740,0","w":1169},"z":{"d":"0,-170v0,101,66,170,175,170r738,0r0,-131r-704,1v-37,0,-56,-14,-56,-43v0,-28,19,-42,56,-42r529,-1v102,1,175,-66,175,-169v0,-102,-66,-171,-175,-171r-707,-2r0,131r674,2v37,0,55,14,55,42v0,28,-18,42,-55,42r-530,1v-102,-1,-175,67,-175,170","w":1039},"{":{"d":"0,-466v58,7,98,-17,100,-66v3,-102,-10,-222,10,-308v23,-50,68,-91,143,-91r196,0r0,153r-163,0v-22,0,-33,11,-33,33r0,289v1,35,-29,68,-64,67v36,0,65,30,64,66r0,290v0,22,11,33,33,33r163,0r0,153r-196,0v-87,1,-153,-65,-153,-153r0,-246v-1,-49,-42,-75,-100,-67r0,-153","w":515},"|":{"w":211},"}":{"d":"349,-778v0,-93,-61,-152,-153,-153r-196,0r0,153r163,0v22,0,33,11,33,33r0,289v-1,35,29,68,64,67v-36,0,-65,30,-64,66r0,290v0,22,-11,33,-33,33r-163,0r0,153r196,0v91,0,153,-64,153,-153r0,-246v1,-49,42,-75,100,-67r0,-153v-58,7,-99,-17,-100,-66r0,-246","w":515},"~":{"w":342},"\u0131":{"w":256},"\u00c7":{"w":729},"\u00d6":{"w":1084},"\u00dc":{"w":761},"\u00e7":{"w":578},"\u00f6":{"d":"7,-368v-3,-111,96,-207,207,-207r536,0v112,-3,207,95,207,207r0,162v3,111,-96,207,-207,207r-536,0v-110,3,-207,-97,-207,-207r0,-162xm264,-445v-45,-1,-85,40,-85,85r0,138v-1,45,40,85,85,85r428,0v45,1,85,-40,85,-85r0,-138v1,-45,-40,-85,-85,-85r-428,0xm289,-650r0,-128r379,0r0,128r-379,0","w":1084},"\u00fc":{"d":"198,0v-119,6,-198,-71,-198,-170r0,-386r167,0r0,358v0,39,19,59,58,59r506,0r0,-417r167,0r0,556r-700,0xm284,-650r0,-128r379,0r0,128r-379,0","w":1032},"\u00a0":{"w":668}}}); diff --git a/doc/themes/triqs/static/triqs.css b/doc/themes/triqs/static/triqs.css new file mode 100644 index 00000000..e183cb21 --- /dev/null +++ b/doc/themes/triqs/static/triqs.css @@ -0,0 +1,449 @@ +/* + * sphinx13.css + * ~~~~~~~~~~~~ + * + * Sphinx stylesheet -- sphinx13 theme. + * + * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. + * :license: BSD, see LICENSE for details. + * + */ + +@import url("basic.css"); + +/* -- page layout ----------------------------------------------------------- */ + +body { + font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; + font-size: 14px; + text-align: center; + background-image: url(bodybg.png); + color: black; + padding: 0; + border-right: 1px solid #0a507a; + border-left: 1px solid #0a507a; + + margin: 0 auto; + min-width: 780px; + max-width: 1080px; +} + + +.red{ + color: red +} +.blue{ + color: blue +} +.green{ + color: green +} + +.param{ + color: blue +} + +a.triqs { + color: #073958; + text-decoration: none; +} + +a.triqs:hover { + color: #0a527f; + text-decoration: none; +} + +.pageheader { + background-color: #dcdcdc; + text-align: left; + padding: 10px 15px; + color: #073958; + border: none; +} + +.pageheader ul { + float: right; + color: #073958; + list-style-type: none; + padding-left: 0; + margin-top: 22px; + margin-right: 10px; +} + +.pageheader li { + float: left; + margin: 0 0 0 10px; +} + +.pageheader li a { + padding: 8px 12px; + color: #073958; + text-shadow: none; +} + +.pageheader li a:hover { + background-color: #f9f9f0; + color: #0a507a; + text-shadow: none; +} + +div.document { + background-color: white; + text-align: left; +} + +div.bodywrapper { + margin: 0 240px 0 0; + border-right: 1px solid #0a507a; +} + +div.body { + margin: 0; + padding: 0.5em 20px 20px 20px; +} + +div.related { + font-size: 1em; + color: white; +} + +div.related ul { + background-image: url(relbg.png); + height: 1.9em; + border-top: 1px solid #002e50; + border-bottom: 1px solid #002e50; +} + +div.related ul li { + margin: 0 5px 0 0; + padding: 0; + float: left; +} + +div.related ul li.right { + float: right; + margin-right: 5px; +} + +div.related ul li a { + margin: 0; + padding: 0 5px 0 5px; + line-height: 1.75em; + color: #f9f9f0; + text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5); +} + +div.related ul li a:hover { + color: white; + /*text-decoration: underline;*/ + text-shadow: 0px 0px 1px rgba(255, 255, 255, 0.5); +} + +div.sphinxsidebarwrapper { + position: relative; + top: 0px; + padding: 0; +} + +div.sphinxsidebar { + margin: 0; + padding: 0 15px 15px 0; + width: 210px; + float: right; + font-size: 1em; + text-align: left; +} + +div.sphinxsidebar .logo { + font-size: 1.8em; + color: #0A507A; + font-weight: 300; + text-align: center; +} + +div.sphinxsidebar .logo img { + vertical-align: middle; +} + +div.sphinxsidebar input { + border: 1px solid #aaa; + font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; + font-size: 1em; +} + +div.sphinxsidebar h3 { + font-size: 1.5em; + border-top: 1px solid #0a507a; + margin-top: 1em; + margin-bottom: 0.5em; + padding-top: 0.5em; +} + +div.sphinxsidebar h4 { + font-size: 1.2em; + margin-bottom: 0; +} + +div.sphinxsidebar h3, div.sphinxsidebar h4 { + margin-right: -15px; + margin-left: -15px; + padding-right: 14px; + padding-left: 14px; + color: #333; + font-weight: 300; + /*text-shadow: 0px 0px 0.5px rgba(0, 0, 0, 0.4);*/ +} + +div.sphinxsidebarwrapper > h3:first-child { + margin-top: 0.5em; + border: none; +} + +div.sphinxsidebar h3 a { + color: #333; +} + +div.sphinxsidebar ul { + color: #444; + margin-top: 7px; + padding: 0; + line-height: 130%; +} + +div.sphinxsidebar ul ul { + margin-left: 20px; + list-style-image: url(listitem.png); +} + +div.footer { + background-image: url(footerbg.png); + color: #ccc; + text-shadow: 0 0 .2px rgba(255, 255, 255, 0.8); + padding: 3px 8px 3px 0; + clear: both; + font-size: 0.8em; + text-align: right; +} + +/* no need to make a visible link to Sphinx on the Sphinx page */ +div.footer a { + color: #ccc; +} + +/* -- body styles ----------------------------------------------------------- */ + +p { + margin: 0.8em 0 0.5em 0; +} + +a { + color: #A2881D; + text-decoration: none; +} + +a:hover { + color: #E1C13F; +} + +div.body a { + text-decoration: underline; +} + +h1 { + margin: 10px 0 0 0; + font-size: 2.4em; + color: #0A507A; + font-weight: 300; +} + +h2 { + margin: 1.em 0 0.2em 0; + font-size: 1.5em; + font-weight: 300; + padding: 0; + color: #174967; +} + +h3 { + margin: 1em 0 -0.3em 0; + font-size: 1.3em; + font-weight: 300; +} + +div.body h1 a, div.body h2 a, div.body h3 a, div.body h4 a, div.body h5 a, div.body h6 a { + text-decoration: none; +} + +div.body h1 a tt, div.body h2 a tt, div.body h3 a tt, div.body h4 a tt, div.body h5 a tt, div.body h6 a tt { + color: #0A507A !important; + font-size: inherit !important; +} + +a.headerlink { + color: #0A507A !important; + font-size: 12px; + margin-left: 6px; + padding: 0 4px 0 4px; + text-decoration: none !important; + float: right; +} + +a.headerlink:hover { + background-color: #ccc; + color: white!important; +} + +cite, code, tt { + font-family: 'Consolas', 'DejaVu Sans Mono', + 'Bitstream Vera Sans Mono', monospace; + font-size: 14px; + letter-spacing: -0.02em; +} + +tt { + background-color: #f2f2f2; + border: 1px solid #ddd; + border-radius: 2px; + color: #333; + padding: 1px; +} + +tt.descname, tt.descclassname, tt.xref { + border: 0; +} + +hr { + border: 1px solid #abc; + margin: 2em; +} + +a tt { + border: 0; + color: #a2881d; +} + +a tt:hover { + color: #e1c13f; +} + +pre { + font-family: 'Consolas', 'DejaVu Sans Mono', + 'Bitstream Vera Sans Mono', monospace; + font-size: 13px; + letter-spacing: 0.015em; + line-height: 120%; + padding: 0.5em; + border: 1px solid #ccc; + border-radius: 2px; + background-color: #f8f8f8; +} + +pre a { + color: inherit; + text-decoration: underline; +} + +td.linenos pre { + padding: 0.5em 0; +} + +div.quotebar { + background-color: #f8f8f8; + max-width: 250px; + float: right; + padding: 0px 7px; + border: 1px solid #ccc; + margin-left: 1em; +} + +div.topic { + background-color: #f8f8f8; +} + +table { + border-collapse: collapse; + margin: 0 -0.5em 0 -0.5em; +} + +table td, table th { + padding: 0.2em 0.5em 0.2em 0.5em; +} + +div.admonition, div.warning { + font-size: 0.9em; + margin: 1em 0 1em 0; + border: 1px solid #86989B; + border-radius: 2px; + background-color: #f7f7f7; + padding: 0; +} + +div.admonition p, div.warning p { + margin: 0.5em 1em 0.5em 1em; + padding: 0; +} + +div.admonition pre, div.warning pre { + margin: 0.4em 1em 0.4em 1em; +} + +div.admonition p.admonition-title, +div.warning p.admonition-title { + margin-top: 1em; + padding-top: 0.5em; + font-weight: bold; +} + +div.warning { + border: 1px solid #940000; +/* background-color: #FFCCCF;*/ +} + +div.warning p.admonition-title { +} + +div.admonition ul, div.admonition ol, +div.warning ul, div.warning ol { + margin: 0.1em 0.5em 0.5em 3em; + padding: 0; +} + +div.admonition .highlight, div.warning .highlight { + background-color: #f7f7f7; +} + +.viewcode-back { + font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', + 'Verdana', sans-serif; +} + +div.viewcode-block:target { + background-color: #f4debf; + border-top: 1px solid #ac9; + border-bottom: 1px solid #ac9; +} + + +.my-code-block.std-ref { + color : red; +} + +.cppbrief { + color: #C6792C; + font-style: oblique; +} + +.cppsynopsis { + background-color: #E7EDF9; + /*font-family: 'Open Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif;*/ + /*font-family: monospace; */ + font-family: Verdana, Arial, Lucida Console; + font-size=80%; + /*font-style: oblique;*/ + /* white-space: pre;*/ +} + + + diff --git a/doc/themes/triqs/theme.conf b/doc/themes/triqs/theme.conf new file mode 100644 index 00000000..96ca439a --- /dev/null +++ b/doc/themes/triqs/theme.conf @@ -0,0 +1,4 @@ +[theme] +inherit = basic +stylesheet = triqs.css +pygments_style = sphinx diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 00000000..748dc4a5 --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,7 @@ +# Configure the version of packaging files +configure_file(conda/meta.yaml.in conda/meta.yaml) +configure_file(conda/build.sh conda/build.sh COPYONLY) +configure_file(conda/conda_build_config.yaml conda/conda_build_config.yaml COPYONLY) +configure_file(TRIQS-app4triqs-foss-2021b.eb.in TRIQS-app4triqs-foss-2021b.eb) + + diff --git a/packaging/TRIQS-app4triqs-foss-2021b.eb.in b/packaging/TRIQS-app4triqs-foss-2021b.eb.in new file mode 100644 index 00000000..384c7818 --- /dev/null +++ b/packaging/TRIQS-app4triqs-foss-2021b.eb.in @@ -0,0 +1,60 @@ +easyblock = 'CMakeMake' + +name = 'TRIQS-app4triqs' +version = '@PROJECT_VERSION@' + +homepage = 'https://triqs.github.io/app4triqs/' +description = """ + PROVIDE HERE A DESCRIPTION OF YOUR APPLICATION +""" + +docurls = ['https://triqs.github.io/app4triqs/%(version_major_minor)s.x/'] +software_license = 'LicenseGPLv3' + +toolchain = {'name': 'foss', 'version': '2021b'} +toolchainopts = {'pic': True, 'usempi': True} + +source_urls = ['https://github.com/TRIQS/app4triqs/releases/download/%(version)s/'] +sources = ['app4triqs-%(version)s.tar.gz'] +checksums = ['PUT HERE THE SHA256 OF THE RELEASE TARBALL'] + +dependencies = [ + ('Python', '3.9.6'), + ('SciPy-bundle', '2021.10'), + ('Boost', '1.77.0'), + ('Clang', '13.0.1'), + ('Clang-Python-bindings', '13.0.1'), + ('GMP', '6.2.1'), + ('HDF5', '1.10.7'), + ('Mako', '1.1.4'), + ('TRIQS', '3.3.0'), + ('NFFT', '3.5.2') +] + +builddependencies = [ + ('CMake', '3.22.1') +] + +separate_build_dir = True + +runtest = 'test' + +sanity_check_paths = { + 'files': ['lib/libapp4triqs_c.a'], + 'dirs': ['include/app4triqs', 'lib', 'share', + 'lib/python%(pyshortver)s/site-packages/app4triqs'], +} + +sanity_check_commands = ["python -c 'import app4triqs'"] + +modextrapaths = { + 'CPLUS_INCLUDE_PATH': 'include', + 'PYTHONPATH': 'lib/python%(pyshortver)s/site-packages', + 'CMAKE_PREFIX_PATH': 'lib/cmake/app4triqs', +} +modextravars = { + 'APP4TRIQS_ROOT': '%(installdir)s', + 'APP4TRIQS_VERSION': '%(version)s', +} + +moduleclass = 'phys' diff --git a/packaging/conda/build.sh b/packaging/conda/build.sh new file mode 100644 index 00000000..740a84dd --- /dev/null +++ b/packaging/conda/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +mkdir build +cd build + +# Openmpi Specific environment setup - Cf. https://github.com/conda-forge/libnetcdf-feedstock/pull/80 +export OMPI_MCA_btl=self,tcp +export OMPI_MCA_plm=isolated +export OMPI_MCA_rmaps_base_oversubscribe=yes +export OMPI_MCA_btl_vader_single_copy_mechanism=none +mpiexec="mpiexec --allow-run-as-root" + +source $PREFIX/share/triqs/triqsvars.sh + +cmake \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DCMAKE_BUILD_TYPE=Release \ + .. + +make -j${CPU_COUNT} VERBOSE=1 +CTEST_OUTPUT_ON_FAILURE=1 ctest +make install diff --git a/packaging/conda/conda_build_config.yaml b/packaging/conda/conda_build_config.yaml new file mode 100644 index 00000000..289631fa --- /dev/null +++ b/packaging/conda/conda_build_config.yaml @@ -0,0 +1,3 @@ +mpi: + - mpich + - openmpi diff --git a/packaging/conda/meta.yaml.in b/packaging/conda/meta.yaml.in new file mode 100644 index 00000000..bad6e1cd --- /dev/null +++ b/packaging/conda/meta.yaml.in @@ -0,0 +1,57 @@ +{% set version = "@PROJECT_VERSION@" %} + +package: + name: app4triqs + version: {{ version }} + +source: + url: https://github.com/TRIQS/app4triqs/releases/download/{{ version }}/app4triqs-{{ version }}.tar.gz + sha256: PUT HERE THE SHA256 OF YOUR RELEASE TARBALL + +build: + number: 0 + skip: True # [win or py<30] + +requirements: + build: + - cmake + - make + - {{ compiler('c') }} + - {{ compiler('cxx') }} + host: + - triqs {{ '.'.join(version.split('.')[:2]) }} + - boost-cpp + - hdf5 + - {{ mpi }} + - libblas + - liblapack + - python + run: + - {{ pin_compatible("triqs", max_pin="x.x") }} + - boost-cpp + - hdf5 + - {{ mpi }} + - libblas + - liblapack + - python + +test: + commands: + - export OMPI_MCA_btl=self,tcp + - export OMPI_MCA_plm=isolated + - export OMPI_MCA_rmaps_base_oversubscribe=yes + - export OMPI_MCA_btl_vader_single_copy_mechanism=none + - export mpiexec="mpiexec --allow-run-as-root" + - python -c "import app4triqs" + +about: + home: https://triqs.github.io/app4triqs + license: GPL-3.0-or-later + license_family: GPL + license_file: LICENSE.txt + summary: 'An application based on the TRIQS library' + +extra: + recipe-maintainers: + - wentzell + - pgunn diff --git a/python/app4triqs/CMakeLists.txt b/python/app4triqs/CMakeLists.txt new file mode 100644 index 00000000..753f3145 --- /dev/null +++ b/python/app4triqs/CMakeLists.txt @@ -0,0 +1,26 @@ +# Configure the version +configure_file(version.py.in version.py) + +# All Python files. Copy them in the build dir to have a complete package for the tests. +file(GLOB_RECURSE python_sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py) +file(GLOB_RECURSE wrap_generators RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_desc.py) +list(REMOVE_ITEM python_sources "${wrap_generators}") +foreach(file ${python_sources}) + configure_file(${file} ${file} COPYONLY) +endforeach() + +# Install python files to proper location +set(PYTHON_LIB_DEST ${TRIQS_PYTHON_LIB_DEST_ROOT}/${PROJECT_NAME}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${PYTHON_LIB_DEST}) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT} FILES_MATCHING PATTERN "*.py" PATTERN "*_desc.py" EXCLUDE) + +# Build and install any python modules +foreach(gen ${wrap_generators}) + string(REPLACE "_desc.py" "" gen ${gen}) + get_filename_component(module_name ${gen} NAME_WE) + get_filename_component(module_dir ${gen} DIRECTORY) + add_cpp2py_module(NAME ${module_name} DIRECTORY ${module_dir}) + add_library(${PROJECT_NAME}::${module_name} ALIAS ${module_name}) + target_link_libraries(${module_name} ${PROJECT_NAME}_c triqs_py) + install(TARGETS ${module_name} DESTINATION ${PYTHON_LIB_DEST}/${module_dir}) +endforeach() diff --git a/python/app4triqs/__init__.py b/python/app4triqs/__init__.py new file mode 100644 index 00000000..1d6bdf56 --- /dev/null +++ b/python/app4triqs/__init__.py @@ -0,0 +1,30 @@ +################################################################################ +# +# TRIQS: a Toolbox for Research in Interacting Quantum Systems +# +# Copyright (C) 2016-2018, N. Wentzell +# Copyright (C) 2018-2019, The Simons Foundation +# author: N. Wentzell +# +# TRIQS is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# TRIQS. If not, see . +# +################################################################################ + +r""" +DOC + +""" +from .app4triqs_module import Toto, chain + +__all__ = ['Toto', 'chain'] diff --git a/python/app4triqs/app4triqs_module_desc.py b/python/app4triqs/app4triqs_module_desc.py new file mode 100644 index 00000000..161e72f7 --- /dev/null +++ b/python/app4triqs/app4triqs_module_desc.py @@ -0,0 +1,76 @@ +# Generated automatically using the command : +# c++2py ../../c++/app4triqs/app4triqs.hpp -p --members_read_only -N app4triqs -a app4triqs -m app4triqs_module -o app4triqs_module --moduledoc="The app4triqs python module" -C triqs --cxxflags="-std=c++17" --target_file_only +from cpp2py.wrap_generator import * + +# The module +module = module_(full_name = "app4triqs_module", doc = r"The app4triqs python module", app_name = "app4triqs") + +# Imports + +# Add here all includes +module.add_include("app4triqs/app4triqs.hpp") + +# Add here anything to add in the C++ code at the start, e.g. namespace using +module.add_preamble(""" +#include + +using namespace app4triqs; +""") + + +# The class toto +c = class_( + py_type = "Toto", # name of the python class + c_type = "app4triqs::toto", # name of the C++ class + doc = r"""A very useful and important class""", # doc of the C++ class + hdf5 = True, + arithmetic = ("add_only"), + comparisons = "==", + serializable = "tuple" +) + +c.add_constructor("""()""", doc = r"""""") + +c.add_constructor("""(int i_)""", doc = r"""Construct from integer + +Parameters +---------- +i_ + a scalar :math:`G(\tau)`""") + +c.add_method("""int f (int u)""", + doc = r"""A simple function with :math:`G(\tau)` + +Parameters +---------- +u + Nothing useful""") + +c.add_method("""std::string hdf5_format ()""", + is_static = True, + doc = r"""HDF5""") + +c.add_property(name = "i", + getter = cfunction("int get_i ()"), + doc = r"""Simple accessor""") + +module.add_class(c) + +module.add_function ("int app4triqs::chain (int i, int j)", doc = r"""Chain digits of two integers + +Parameters +---------- +i + The first integer + +j + The second integer + +Returns +------- +out + An integer containing the digits of both i and j""") + + + +module.generate_code() diff --git a/python/app4triqs/version.py.in b/python/app4triqs/version.py.in new file mode 100644 index 00000000..2d63daf1 --- /dev/null +++ b/python/app4triqs/version.py.in @@ -0,0 +1,32 @@ +################################################################################ +# +# TRIQS: a Toolbox for Research in Interacting Quantum Systems +# +# Copyright (C) 2016-2018, N. Wentzell +# Copyright (C) 2018-2019, Simons Foundation +# author: N. Wentzell +# +# TRIQS is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# TRIQS. If not, see . +# +################################################################################ + +version = "@PROJECT_VERSION@" +triqs_hash = "@TRIQS_GIT_HASH@" +@PROJECT_NAME@_hash = "@PROJECT_GIT_HASH@" + +def show_version(): + print("\nYou are using @PROJECT_NAME@ version %s\n"%version) + +def show_git_hash(): + print("\nYou are using @PROJECT_NAME@ git hash %s based on triqs git hash %s\n"%("@PROJECT_GIT_HASH@", triqs_hash)) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..5fa6fa3d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +# Required python packages for this application (these should also be added to Dockerfile for Jenkins) +mako +numpy +scipy +# For documentation builds we additionaly require +#sphinx +#numpydoc +#nbsphinx +#sphinx_rtd_theme +#myst_parser +#linkify-it-py diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt new file mode 100644 index 00000000..8d258a5f --- /dev/null +++ b/share/CMakeLists.txt @@ -0,0 +1,37 @@ +add_subdirectory(cmake) + +if(NOT IS_SUBPROJECT + AND NOT CMAKE_INSTALL_PREFIX STREQUAL TRIQS_ROOT + AND NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr" + AND NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" +) + + if(PythonSupport) + set(EXPORT_PYTHON_PATH "export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CPP2PY_PYTHON_LIB_DEST_ROOT}:$PYTHONPATH") + set(MODFILE_PYTHON_PATH "prepend-path PYTHONPATH $root/${CPP2PY_PYTHON_LIB_DEST_ROOT}") + endif() + + configure_file(${PROJECT_NAME}.modulefile.in ${PROJECT_NAME}.modulefile @ONLY) + configure_file(${PROJECT_NAME}vars.sh.in ${PROJECT_NAME}vars.sh @ONLY) + + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.modulefile + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}vars.sh + DESTINATION share/${PROJECT_NAME} + ) + + message(STATUS "*********************************************************************************") + message(STATUS "* Custom install Location. Use: ") + message(STATUS "* ") + message(STATUS "* source ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/${PROJECT_NAME}vars.sh ") + message(STATUS "* ") + message(STATUS "* to set up the environment variables ") + if(DEFINED ENV{MODULEPATH}) + message(STATUS "* ") + message(STATUS "* Consider copying ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.modulefile ") + message(STATUS "* into your environment module directories ") + endif() + message(STATUS "*********************************************************************************") + +endif() diff --git a/share/app4triqs.modulefile.in b/share/app4triqs.modulefile.in new file mode 100644 index 00000000..2c9befe8 --- /dev/null +++ b/share/app4triqs.modulefile.in @@ -0,0 +1,39 @@ +#%Module1.0 +# +# To be installed as ${MODULEPATH}/@PROJECT_NAME@/@PROJECT_VERSION@ + +set name @PROJECT_NAME@ +set version @PROJECT_VERSION@ +set root @CMAKE_INSTALL_PREFIX@ +set git_hash @PROJECT_GIT_HASH@ + +set url "https://github.com/TRIQS/@PROJECT_NAME@" +set description "An example application using cpp2py and triqs." + +module-whatis "$description" + +proc ModulesHelp { } { + global description url version git_hash + puts stderr "Description: $description" + puts stderr "URL: $url" + puts stderr "Version: $version" + puts stderr "Git hash: $git_hash" +} + +# You may need to edit the next line if the triqs module +# is installed under a different name in your setup. +prereq triqs/@TRIQS_VERSION@ + +# Only one version of @PROJECT_NAME@ can be loaded at a time +conflict $name + +setenv @PROJECT_NAME@_ROOT $root +setenv @PROJECT_NAME@_VERSION $version +setenv @PROJECT_NAME@_GIT_HASH $git_hash + +prepend-path PATH $root/bin +prepend-path CPLUS_INCLUDE_PATH $root/include +prepend-path LIBRARY_PATH $root/lib +prepend-path LD_LIBRARY_PATH $root/lib +prepend-path CMAKE_PREFIX_PATH $root +@MODFILE_PYTHON_PATH@ diff --git a/share/app4triqsvars.sh.in b/share/app4triqsvars.sh.in new file mode 100644 index 00000000..a499f10b --- /dev/null +++ b/share/app4triqsvars.sh.in @@ -0,0 +1,10 @@ +# Source this in your environment. + +export @PROJECT_NAME@_ROOT=@CMAKE_INSTALL_PREFIX@ + +export CPLUS_INCLUDE_PATH=@CMAKE_INSTALL_PREFIX@/include:$CPLUS_INCLUDE_PATH +export PATH=@CMAKE_INSTALL_PREFIX@/bin:$PATH +export LIBRARY_PATH=@CMAKE_INSTALL_FULL_LIBDIR@:$LIBRARY_PATH +export LD_LIBRARY_PATH=@CMAKE_INSTALL_FULL_LIBDIR@:$LD_LIBRARY_PATH +export CMAKE_PREFIX_PATH=@CMAKE_INSTALL_PREFIX@:$CMAKE_PREFIX_PATH +@EXPORT_PYTHON_PATH@ diff --git a/share/cmake/CMakeLists.txt b/share/cmake/CMakeLists.txt new file mode 100644 index 00000000..c845b7b4 --- /dev/null +++ b/share/cmake/CMakeLists.txt @@ -0,0 +1,10 @@ +configure_file(${PROJECT_NAME}-config.cmake.in ${PROJECT_NAME}-config.cmake @ONLY) +configure_file(${PROJECT_NAME}-config-version.cmake.in ${PROJECT_NAME}-config-version.cmake @ONLY) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} +) + +install(EXPORT ${PROJECT_NAME}-targets NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) diff --git a/share/cmake/Modules/FindSphinx.cmake b/share/cmake/Modules/FindSphinx.cmake new file mode 100644 index 00000000..6901b853 --- /dev/null +++ b/share/cmake/Modules/FindSphinx.cmake @@ -0,0 +1,37 @@ +# Copyright Olivier Parcollet 2017. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# This module looks for sphinx documentation tool +# and define a function that prepares the Makefile for sphinx-build + +find_program(SPHINXBUILD_EXECUTABLE + NAMES sphinx-build + PATHS /usr/bin /opt/local/bin /usr/local/bin #opt/sphinx-doc/bin + PATH_SUFFIXES bin + ) + +if (NOT SPHINXBUILD_EXECUTABLE) + message(FATAL_ERROR "I cannot find sphinx to build the triqs documentation") +endif() + +execute_process( + COMMAND "${SPHINXBUILD_EXECUTABLE}" --version + OUTPUT_VARIABLE SPHINXBUILD_VERSION + ERROR_VARIABLE SPHINXBUILD_VERSION + ) +if (SPHINXBUILD_VERSION MATCHES "[Ss]phinx.* ([0-9]+\\.[0-9]+(\\.|b)[0-9]+)") + set (SPHINXBUILD_VERSION "${CMAKE_MATCH_1}") +endif() + +if (SPHINXBUILD_VERSION VERSION_EQUAL 1.6.3) + message(FATAL_ERROR "sphinx-build found at ${SPHINXBUILD_EXECUTABLE} but version 1.6.3 has a bug. Upgrade sphinx.") +else() + message(STATUS "sphinx-build program found at ${SPHINXBUILD_EXECUTABLE} with version ${SPHINXBUILD_VERSION}") +endif () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx DEFAULT_MSG SPHINXBUILD_EXECUTABLE) + +mark_as_advanced( SPHINXBUILD_EXECUTABLE ) diff --git a/share/cmake/app4triqs-config-version.cmake.in b/share/cmake/app4triqs-config-version.cmake.in new file mode 100644 index 00000000..c4c43a4b --- /dev/null +++ b/share/cmake/app4triqs-config-version.cmake.in @@ -0,0 +1,13 @@ +set(PACKAGE_VERSION @PROJECT_VERSION@) + +if (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) +endif() + +if (PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE TRUE) +endif() + +if (PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/share/cmake/app4triqs-config.cmake.in b/share/cmake/app4triqs-config.cmake.in new file mode 100644 index 00000000..b6bb5bbd --- /dev/null +++ b/share/cmake/app4triqs-config.cmake.in @@ -0,0 +1,40 @@ +# This file allows other CMake Projects to find us +# We provide general project information +# and reestablish the exported CMake Targets + +# Multiple inclusion guard +if(NOT @PROJECT_NAME@_FOUND) +set(@PROJECT_NAME@_FOUND TRUE) +set_property(GLOBAL PROPERTY @PROJECT_NAME@_FOUND TRUE) + +# version +set(@PROJECT_NAME@_VERSION @PROJECT_VERSION@ CACHE STRING "@PROJECT_NAME@ version") +set(@PROJECT_NAME@_GIT_HASH @PROJECT_GIT_HASH@ CACHE STRING "@PROJECT_NAME@ git hash") + +# Root of the installation +set(@PROJECT_NAME@_ROOT @CMAKE_INSTALL_PREFIX@ CACHE STRING "@PROJECT_NAME@ root directory") + +## Find the target dependencies +#function(find_dep) +# get_property(${ARGV0}_FOUND GLOBAL PROPERTY ${ARGV0}_FOUND) +# if(NOT ${ARGV0}_FOUND) +# find_package(${ARGN} REQUIRED HINTS @CMAKE_INSTALL_PREFIX@) +# endif() +#endfunction() +#find_dep(depname 1.0) + +# Include the exported targets of this project +include(@CMAKE_INSTALL_FULL_LIBDIR@/cmake/@PROJECT_NAME@/@PROJECT_NAME@-targets.cmake) + +message(STATUS "Found @PROJECT_NAME@-config.cmake with version @PROJECT_VERSION@, hash = @PROJECT_GIT_HASH@, root = @CMAKE_INSTALL_PREFIX@") + +# Was the Project built with Documentation? +set(@PROJECT_NAME@_WITH_DOCUMENTATION @Build_Documentation@ CACHE BOOL "Was @PROJECT_NAME@ build with documentation?") + +# Was the Project built with PythonSupport? +set(@PROJECT_NAME@_WITH_PYTHON_SUPPORT @PythonSupport@ CACHE BOOL "Was @PROJECT_NAME@ build with python support?") +if(@PythonSupport@) + set(@PROJECT_NAME@_MODULE_DIR @CMAKE_INSTALL_PREFIX@/@CPP2PY_PYTHON_LIB_DEST_ROOT@ CACHE BOOL "The @PROJECT_NAME@ python module directory") +endif() + +endif() diff --git a/share/cmake/extract_flags.cmake b/share/cmake/extract_flags.cmake new file mode 100644 index 00000000..dd4edffc --- /dev/null +++ b/share/cmake/extract_flags.cmake @@ -0,0 +1,125 @@ +# Copyright (c) 2019-2020 Simons Foundation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You may obtain a copy of the License at +# https://www.gnu.org/licenses/gpl-3.0.txt +# Author: Nils Wentzell + +# Recursively fetch all targets that the interface of a target depends upon +macro(get_all_interface_targets name target) + get_property(TARGET_LINK_LIBRARIES TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES) + foreach(lib IN LISTS TARGET_LINK_LIBRARIES) + if(TARGET ${lib}) + # Append to list + list(APPEND ${name}_INTERFACE_TARGETS ${lib}) + # Recure into target dependencies + get_all_interface_targets(${name} ${lib}) + endif() + endforeach() +endmacro() + +# Extract the property from the target and recursively from all targets it depends upon +macro(get_property_recursive) + cmake_parse_arguments(get_property_recursive "" "TARGET" "PROPERTY" ${ARGN}) + set(target ${get_property_recursive_TARGET}) + set(property ${get_property_recursive_PROPERTY}) + get_all_interface_targets(${target} ${target}) + foreach(t IN LISTS ${target}_INTERFACE_TARGETS ITEMS ${target}) + get_property(p TARGET ${t} PROPERTY ${property}) + list(APPEND ${ARGV0} ${p}) + endforeach() + # Clean duplicates and any occurance of '/usr/include' dirs + if(${ARGV0}) + list(REMOVE_DUPLICATES ${ARGV0}) + list(REMOVE_ITEM ${ARGV0} /usr/include) + endif() +endmacro() + +# Recursively fetch all compiler flags attached to the interface of a target +macro(extract_flags) + + cmake_parse_arguments(ARG "BUILD_INTERFACE" "" "" ${ARGN}) + + set(target ${ARGV0}) + unset(${target}_CXXFLAGS) + unset(${target}_LDFLAGS) + + get_property_recursive(opts TARGET ${target} PROPERTY INTERFACE_COMPILE_OPTIONS) + foreach(opt ${opts}) + set(${target}_LDFLAGS "${${target}_LDFLAGS} ${opt}") + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} ${opt}") + endforeach() + + get_property_recursive(cxx_features TARGET ${target} PROPERTY INTERFACE_COMPILE_FEATURES) + if(cxx_std_23 IN_LIST cxx_features) + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -std=c++2b") + elseif(cxx_std_20 IN_LIST cxx_features) + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -std=c++20") + elseif(cxx_std_17 IN_LIST cxx_features) + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -std=c++17") + endif() + + get_property_recursive(defs TARGET ${target} PROPERTY INTERFACE_COMPILE_DEFINITIONS) + foreach(def ${defs}) + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -D${def}") + endforeach() + + get_property_recursive(inc_dirs TARGET ${target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + get_property_recursive(sys_inc_dirs TARGET ${target} PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if(inc_dirs) + list(REMOVE_ITEM sys_inc_dirs ${inc_dirs}) + endif() + foreach(dir ${inc_dirs}) + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -I${dir}") + endforeach() + foreach(dir ${sys_inc_dirs}) + set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -isystem${dir}") + endforeach() + + get_property_recursive(libs TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES) + foreach(lib ${libs}) + if(NOT TARGET ${lib} AND NOT IS_DIRECTORY ${lib}) + set(${target}_LDFLAGS "${${target}_LDFLAGS} ${lib}") + endif() + endforeach() + + # ==== We have to replace generator expressions explicitly ==== + + if(ARG_BUILD_INTERFACE) + string(REGEX REPLACE "\\$" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE "\\$" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + else() + string(REGEX REPLACE "\\$" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE "\\$" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + string(REGEX REPLACE "\\$<\\$:([^ ]*)>" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE "\\$<\\$:([^ ]*)>" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + string(REGEX REPLACE "\\$<\\$:([^ ]*)>" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE "\\$<\\$:([^ ]*)>" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + string(REGEX REPLACE "\\$<\\$:([^ ]*)>" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE "\\$<\\$:([^ ]*)>" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + endif() + + # Remove all remaining generator expressions + string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + + # Filter out system directories from LDFLAGS and CXXFLAGS + string(REGEX REPLACE " -L/usr/lib " " " ${target}_LDFLAGS "${${target}_LDFLAGS}") + string(REGEX REPLACE " -I/usr/include " " " ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + string(REGEX REPLACE " -isystem/usr/include " " " ${target}_CXXFLAGS "${${target}_CXXFLAGS}") + +endmacro() diff --git a/share/replace_and_rename.py b/share/replace_and_rename.py new file mode 100755 index 00000000..a773d19d --- /dev/null +++ b/share/replace_and_rename.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 + +import sys +import os +import glob + +if len(sys.argv) != 2: + print("Please pass the application name") + sys.exit() + +app_name = str(sys.argv[1]).lower() +capital_name = app_name.upper() + +# Move app4triqs directories if necessary +if os.path.isdir("c++/app4triqs"): os.rename("c++/app4triqs", "c++/" + app_name) +if os.path.isdir("python/app4triqs"): os.rename("python/app4triqs", "python/" + app_name) + +# Ignore these files +ignore_lst = [".git/", "replace_and_rename.py", "squash_history.sh"] + +# Find the root directory of app4triqs +app4triqs_root = os.path.abspath(os.path.dirname(__file__) + "/..") + +# Blacklisted file-formats +fmt_blacklist = ['.png', '.h5', '.jpg', '.ico'] + +# Recurse over all subdirectories and files +for root, dirs, files in os.walk(app4triqs_root): + + for fname in files: + fpath = os.path.join(root, fname) + + if os.path.splitext(fname)[1] in fmt_blacklist: + continue + + # Ignore certain files / directories + if any(it in fpath for it in ignore_lst): continue + + if os.path.isfile(fpath): + # Rename files containing app4triqs in their filename + if "app4triqs" in fname: + new_fpath = os.path.join(root, fname.replace("app4triqs", app_name)) + os.rename(fpath, new_fpath) + fpath = new_fpath + + # Replace app4triqs and APP4TRIQS in all files + with open(fpath, 'r') as f: + s = f.read() + if "app4triqs" in s or "APP4TRIQS" in s: + with open(fpath, 'w') as f: + f.write(s.replace("app4triqs", app_name).replace("APP4TRIQS", capital_name)) diff --git a/share/squash_history.sh b/share/squash_history.sh new file mode 100755 index 00000000..8c03c08f --- /dev/null +++ b/share/squash_history.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +git reset $(git commit-tree HEAD\^{tree} -m "Initialize project from github.com/triqs/app4triqs@$(git rev-parse --short HEAD)") +git merge --allow-unrelated-histories -s ours HEAD@{1} -m "Track app4triqs skeleton" +git remote rm origin +git remote add app4triqs_remote https://github.com/triqs/app4triqs diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..e79313ff --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(c++) + +if(PythonSupport) + add_subdirectory(python) +endif() diff --git a/test/c++/CMakeLists.txt b/test/c++/CMakeLists.txt new file mode 100644 index 00000000..14ac6ae1 --- /dev/null +++ b/test/c++/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copy h5 files to binary dir +file(GLOB_RECURSE all_h5_ref_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ref.h5) +foreach(file ${all_h5_ref_files}) + configure_file(${file} ${file} COPYONLY) +endforeach() + +# List of all tests +file(GLOB_RECURSE all_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) + +foreach(test ${all_tests}) + get_filename_component(test_name ${test} NAME_WE) + get_filename_component(test_dir ${test} DIRECTORY) + add_executable(${test_name} ${test}) + target_link_libraries(${test_name} ${PROJECT_NAME}::${PROJECT_NAME}_c ${PROJECT_NAME}_warnings gtest_main) + set_property(TARGET ${test_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_dir}) + add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_dir}) + # Run clang-tidy if found + if(CLANG_TIDY_EXECUTABLE) + set_target_properties(${test_name} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}") + endif() + # Run cppcheck if found + if(CPPCHECK_EXECUTABLE) + add_custom_command( + TARGET ${test_name} + COMMAND ${CPPCHECK_EXECUTABLE} + --enable=warning,style,performance,portability + --std=c++20 + --template=gcc + --verbose + --force + --quiet + ${CMAKE_CURRENT_SOURCE_DIR}/${test} + ) + endif() +endforeach() diff --git a/test/c++/basic.cpp b/test/c++/basic.cpp new file mode 100644 index 00000000..aecf6894 --- /dev/null +++ b/test/c++/basic.cpp @@ -0,0 +1,30 @@ +#include +#include + +using namespace app4triqs; + +TEST(Toto, Add) { // NOLINT + + toto a(0); + toto b(2); + + auto c = a + b; + EXPECT_EQ(c, b); // NOLINT +} + +TEST(Toto, H5) { // NOLINT + + toto a(0); + { // Local scope for file + h5::file f("f.h5", 'w'); + h5_write(f, "a", a); + } + + toto a2; + { + h5::file f("f.h5", 'a'); + h5_read(f, "a", a2); + } + + EXPECT_EQ(a, a2); // NOLINT +} diff --git a/test/python/Basic.py b/test/python/Basic.py new file mode 100644 index 00000000..c0472fc5 --- /dev/null +++ b/test/python/Basic.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import unittest + +from app4triqs import Toto, chain +from h5 import * +from triqs.utility import mpi + +class test_toto(unittest.TestCase): + + def test_add(self): + + a=Toto(0) + b=Toto(2) + + c=a+b + self.assertEqual(c, b) + + + def test_h5(self): + + a=Toto(0) + with HDFArchive("f.h5",'w') as A: + A["a"] = a + with HDFArchive("f.h5",'r') as A: + a_read = A["a"] + self.assertEqual(a, a_read) + + + def test_mpi(self): + + a=Toto(0) + + if mpi.is_master_node(): + a=Toto(1) + mpi.bcast(a) + + self.assertEqual(a, Toto(1)) + +class test_chain(unittest.TestCase): + + def test_chain(self): + + i = 111 + j = 222 + ij = chain(i,j) + self.assertEqual(ij, 111222) + +if __name__ == '__main__': + unittest.main() diff --git a/test/python/CMakeLists.txt b/test/python/CMakeLists.txt new file mode 100644 index 00000000..aa9d877e --- /dev/null +++ b/test/python/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copy h5 files to binary dir +file(GLOB_RECURSE all_h5_ref_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ref.h5) +foreach(file ${all_h5_ref_files}) + configure_file(${file} ${file} COPYONLY) +endforeach() + +# List of all tests +set(all_tests Basic) + +foreach(test ${all_tests}) + get_filename_component(test_name ${test} NAME_WE) + get_filename_component(test_dir ${test} DIRECTORY) + add_test(NAME Py_${test_name} COMMAND ${TRIQS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test_dir}/${test_name}.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${test_dir}) + set_property(TEST Py_${test_name} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${PROJECT_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SANITIZER_RT_PRELOAD}) +endforeach()