diff --git a/CMakeLists.txt b/CMakeLists.txt index a3f334c..7ffc3c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,10 +76,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Global compiler options option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) -add_compile_options( - $<$:-Og> - $<$:-ggdb3> -) +add_compile_options($<$:-ggdb3>) # Create an Interface target for compiler warnings add_library(${PROJECT_NAME}_warnings INTERFACE) diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..2e8a6c6 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,24 @@ +# See packaging for various base options +FROM flatironinstitute/triqs:base +ARG APPNAME=itertools + +COPY requirements.txt /src/$APPNAME/requirements.txt +RUN pip3 install -r /src/$APPNAME/requirements.txt + +RUN useradd -u 993 -m build + +ENV SRC=/src \ + BUILD=/home/build \ + INSTALL=/usr/local \ + PYTHONPATH=/usr/local/lib/python$PYTHON_VERSION/site-packages \ + CMAKE_PREFIX_PATH=/usr/lib/cmake/$APPNAME + +COPY --chown=build . $SRC/$APPNAME +WORKDIR $BUILD/$APPNAME +RUN chown build . +USER build +ARG BUILD_DOC=0 +ARG BUILD_ID +RUN cmake $SRC/$APPNAME -DCMAKE_INSTALL_PREFIX=$INSTALL -DBuild_Documentation=$BUILD_DOC -DBuild_Deps=Always -DCLANG_OPT="$CXXFLAGS" -DMATHJAX_PATH="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2" && make -j2 || make -j1 VERBOSE=1 +USER root +RUN make install diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 249a110..541e730 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -17,7 +17,8 @@ include(external_dependency.cmake) # 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 ${PROJECT_SOURCE_DIR}/deps/name. If found +# 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. @@ -34,7 +35,7 @@ include(external_dependency.cmake) # In particular the dependency will not be installed. if(NOT DEFINED Build_Deps) - set(Build_Deps "Never" CACHE STRING "Do we build dependencies from source? [Never/Always/IfNotFound]") + set(Build_Deps "IfNotFound" 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) diff --git a/deps/external_dependency.cmake b/deps/external_dependency.cmake index e7cc44e..7ba1b7a 100644 --- a/deps/external_dependency.cmake +++ b/deps/external_dependency.cmake @@ -51,6 +51,9 @@ function(external_dependency) 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) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 8b5adca..6f0deb3 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -14,7 +14,8 @@ macro(generate_docs header_file) COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/cpp2rst_generated COMMAND PYTHONPATH=${CPP2PY_BINARY_DIR}:$ENV{PYTHONPATH} - ${CPP2PY_BINARY_DIR}/bin/c++2rst + 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 diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index c71910b..5f9652e 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -1,10 +1,8 @@ -Version 2.2.0 -------------- +Version 1.0.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. +Itertools Version 1.0.0 is a single-header +C++ library that allows, with a simple interface, +for the writing of various types of range-based for loops. This is the initial release for this project. diff --git a/doc/conf.py.in b/doc/conf.py.in index f9551f0..eac5203 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -3,7 +3,7 @@ # documentation build configuration file import sys -sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext/autorun") +sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext") sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext/numpydoc") extensions = ['sphinx.ext.autodoc', @@ -14,8 +14,8 @@ extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.autosummary', 'sphinx.ext.githubpages', + 'sphinx_autorun', 'matplotlib.sphinxext.plot_directive', - 'autorun', 'numpydoc'] source_suffix = '.rst' @@ -42,4 +42,4 @@ html_sidebars = {'index': ['sideb.html', 'searchbox.html']} htmlhelp_basename = '@PROJECT_NAME@doc' -intersphinx_mapping = {'python': ('http://docs.python.org/2.7', None)} +intersphinx_mapping = {'python': ('https://docs.python.org/3.8', None)} diff --git a/doc/install.rst b/doc/install.rst index 6927329..8a406fa 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -13,20 +13,13 @@ Installation steps $ git clone https://github.com/TRIQS/itertools itertools.src -#. Make sure that all additional dependencies are installed on your system and available in your environment. - Alternatively build the dependencies from source instead with:: - - $ (cd deps && ./download.sh) - - In this case they will be installed together with your application. - #. Create and move to a new directory where you will compile the code:: $ mkdir itertools.build && cd itertools.build #. In the build directory call cmake, including any additional custom CMake options, see below:: - $ cmake -DCMAKE_INSTALL_PREFIX=path_to_install_dir ../app4triqs.src + $ cmake -DCMAKE_INSTALL_PREFIX=path_to_install_dir ../itertools.src #. Compile the code, run the tests and install the application:: @@ -52,7 +45,7 @@ Custom CMake options The compilation of ``itertools`` can be configured using CMake-options:: - cmake ../itertools.src -DOPTION1=value1 -DOPTION2=value2 ... ../itertools.src + cmake ../itertools.src -DOPTION1=value1 -DOPTION2=value2 ... +-----------------------------------------------------------------+-----------------------------------------------+ | Options | Syntax | diff --git a/doc/sphinxext/autorun/autorun.py b/doc/sphinxext/autorun/autorun.py deleted file mode 100644 index cbd2974..0000000 --- a/doc/sphinxext/autorun/autorun.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- -""" -sphinxcontirb.autorun -~~~~~~~~~~~~~~~~~~~~~~ - -Run the code and insert stdout after the code block. - - -""" -import os -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 -from pygments import highlight -from pygments.lexers import PythonLexer -from pygments.formatters import HtmlFormatter - -class RunBlockError(SphinxError): - category = 'runblock error' - -class AutoRun: - here = os.path.abspath(__file__) - pycon = os.path.join(os.path.dirname(here),'pycon.py') - config = dict( - 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','ascii') - input_encoding = 'utf8' - output_encoding = 'utf8' - #output_encoding = config.get(language+'_output_encoding','ascii') - 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 = '\n'.join(codelines).encode(input_encoding) - - # Run the code - stdout,stderr = proc.communicate(code) - - # Process output - out ='' - if stdout: - out += ''.join(stdout).decode(output_encoding) - if stderr: - out += ''.join(stderr).decode(output_encoding) - - # Get the original code with prefixes - if show_source: - code = '\n'.join(self.content) - else: - code = '' - #code_out = u'\n\n ---Output:---\n'.join((highlight(code, PythonLexer(), HtmlFormatter()),out)) - code_out = '\n\n ---Output:---\n'.join((code,out)) - - literal = nodes.literal_block(code_out,code_out) - #literal['language'] = language - literal['language'] = 'python' - 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') - -# vim: set expandtab shiftwidth=4 softtabstop=4 : diff --git a/doc/sphinxext/sphinx_autorun/__init__.py b/doc/sphinxext/sphinx_autorun/__init__.py new file mode 100644 index 0000000..1afa037 --- /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/autorun/pycon.py b/doc/sphinxext/sphinx_autorun/pycon.py similarity index 77% rename from doc/sphinxext/autorun/pycon.py rename to doc/sphinxext/sphinx_autorun/pycon.py index 22ad46c..c0edf86 100644 --- a/doc/sphinxext/autorun/pycon.py +++ b/doc/sphinxext/sphinx_autorun/pycon.py @@ -1,7 +1,7 @@ import sys from code import InteractiveInterpreter - + def main(): """ Print lines of input along with output. @@ -12,23 +12,20 @@ def main(): try: while True: source = next(source_lines) - print('>>>', source) + # 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 + source += '\n' + next_line more = console.runsource(source) except StopIteration: if more: print('... ') more = console.runsource(source + '\n') - - + if __name__ == '__main__': main() - - -# vim: set expandtab shiftwidth=4 softtabstop=4 : - diff --git a/doc/sphinxext/sphinx_autorun/version.py b/doc/sphinxext/sphinx_autorun/version.py new file mode 100644 index 0000000..433d173 --- /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/themes/agogo/static/bgfooter.png b/doc/themes/agogo/static/bgfooter.png new file mode 100644 index 0000000..9ce5bdd Binary files /dev/null and b/doc/themes/agogo/static/bgfooter.png differ diff --git a/doc/themes/agogo/static/bgtop.png b/doc/themes/agogo/static/bgtop.png new file mode 100644 index 0000000..a0d4709 Binary files /dev/null and b/doc/themes/agogo/static/bgtop.png differ diff --git a/doc/themes/triqs/static/bodybg.png b/doc/themes/triqs/static/bodybg.png new file mode 100644 index 0000000..506b6f9 Binary files /dev/null and b/doc/themes/triqs/static/bodybg.png differ diff --git a/doc/themes/triqs/static/footerbg.png b/doc/themes/triqs/static/footerbg.png new file mode 100644 index 0000000..d1922b4 Binary files /dev/null and b/doc/themes/triqs/static/footerbg.png differ diff --git a/doc/themes/triqs/static/headerbg.png b/doc/themes/triqs/static/headerbg.png new file mode 100644 index 0000000..6d3e1d5 Binary files /dev/null and b/doc/themes/triqs/static/headerbg.png differ diff --git a/doc/themes/triqs/static/listitem.png b/doc/themes/triqs/static/listitem.png new file mode 100644 index 0000000..e45715f Binary files /dev/null and b/doc/themes/triqs/static/listitem.png differ diff --git a/doc/themes/triqs/static/relbg.png b/doc/themes/triqs/static/relbg.png new file mode 100644 index 0000000..4722585 Binary files /dev/null and b/doc/themes/triqs/static/relbg.png differ diff --git a/packaging/Dockerfile.centos-gcc b/packaging/Dockerfile.centos-gcc new file mode 100644 index 0000000..25bc70b --- /dev/null +++ b/packaging/Dockerfile.centos-gcc @@ -0,0 +1,38 @@ +FROM centos:8 + +RUN dnf -y install dnf-plugins-core epel-release && \ + dnf config-manager --set-enabled PowerTools && \ + dnf -y update && \ + dnf -y install \ + blas-devel \ + boost-devel \ + cmake3 \ + fftw-devel \ + gcc-c++ \ + gcc-gfortran \ + git \ + vim \ + lldb \ + gmp-devel \ + hdf5-devel \ + lapack-devel \ + make \ + openmpi-devel \ + python3-devel \ + python3-mako \ + python3-matplotlib \ + python3-mpi4py-openmpi \ + python3-numpy \ + python3-pip \ + python3-pytz \ + python3-scipy \ + python3-virtualenv + +# for openmpi +ENV PYTHON_VERSION=3.6 \ + CC=gcc CXX=g++ \ + PATH=/usr/lib64/openmpi/bin:${PATH} \ + LD_LIBRARY_PATH=/usr/lib64/openmpi/lib \ + PKG_CONFIG_PATH=/usr/lib64/openmpi/lib/pkgconfig \ + MPI_PYTHON3_SITEARCH=/usr/lib64/python3.6/site-packages/openmpi \ + OMPI_MCA_btl=^uct diff --git a/packaging/Dockerfile.msan b/packaging/Dockerfile.msan index 9f67908..b1835c9 100644 --- a/packaging/Dockerfile.msan +++ b/packaging/Dockerfile.msan @@ -1,6 +1,7 @@ -FROM ubuntu:disco -ARG RELEASE=disco -ARG LLVM=8 +FROM ubuntu:focal +ARG APPNAME=itertools +ARG LLVM=10 +ARG NTHREAD=10 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ clang-${LLVM} \ @@ -8,61 +9,99 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ g++ \ gfortran \ git \ + vim \ + lldb-${LLVM} \ + hdf5-tools \ libblas-dev \ - libboost-all-dev \ + libboost-dev \ libclang-${LLVM}-dev \ libfftw3-dev \ - libgfortran3 \ + libgfortran4 \ libgmp-dev \ - zlib1g-dev \ - intel-mkl \ - python-clang-${LLVM} \ python-dev \ - python-h5py \ - python-mako \ - python-matplotlib \ - python-numpy \ - python-scipy \ - python-sphinx \ - python-nbsphinx \ - python-pip + python3-dev \ + python3-clang-${LLVM} \ + python3-mako \ + python3-matplotlib \ + python3-numpy \ + python3-pip \ + python3-scipy -ENV CC=clang-${LLVM} CXX=clang++-${LLVM} LLVM_VERSION=${LLVM}.0.0 +ENV PYTHON_VERSION=3.8 \ + CC=clang-${LLVM} CXX=clang++-${LLVM} LLVM_VERSION=${LLVM}.0.0 +RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM} 60 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM} --slave /usr/bin/clang-cpp clang-cpp /usr/bin/clang-cpp-${LLVM} -ADD http://releases.llvm.org/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz /tmp/ -ADD http://releases.llvm.org/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz /tmp/ +# Build libcxx with MSAN +ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz /tmp/ +ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz /tmp/ RUN mkdir /tmp/build && cd /tmp/build && \ tar -C /tmp -xf /tmp/libcxx-${LLVM_VERSION}.src.tar.xz && \ tar -C /tmp -xf /tmp/libcxxabi-${LLVM_VERSION}.src.tar.xz && \ - cmake /tmp/libcxxabi-${LLVM_VERSION}.src -DLLVM_CONFIG_PATH=/usr/bin/llvm-config-${LLVM} -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-${LLVM} -DLIBCXXABI_LIBCXX_PATH=/tmp/libcxx-${LLVM_VERSION}.src -DLLVM_USE_SANITIZER=Memory && make -j2 && make install && \ + cmake /tmp/libcxxabi-${LLVM_VERSION}.src -DLLVM_CONFIG_PATH=/usr/bin/llvm-config-${LLVM} -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-${LLVM} -DLIBCXXABI_LIBCXX_PATH=/tmp/libcxx-${LLVM_VERSION}.src -DLLVM_USE_SANITIZER=MemoryWithOrigins && make -j${NTHREAD} && make install && \ rm -rf * && \ - cmake /tmp/libcxx-${LLVM_VERSION}.src -DLLVM_CONFIG_PATH=/usr/bin/llvm-config-${LLVM} -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-${LLVM} -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=/tmp/libcxxabi-${LLVM_VERSION}.src/include -DLLVM_USE_SANITIZER=Memory && make -j2 install && \ + cmake /tmp/libcxx-${LLVM_VERSION}.src -DLLVM_CONFIG_PATH=/usr/bin/llvm-config-${LLVM} -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-${LLVM} -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=/tmp/libcxxabi-${LLVM_VERSION}.src/include -DLLVM_USE_SANITIZER=MemoryWithOrigins && make -j${NTHREAD} install && \ rm -rf /tmp/libcxx* /tmp/build -ENV CXXFLAGS="-stdlib=libc++ -fsanitize=memory" CFLAGS="-fsanitize=memory" LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM}/lib LDFLAGS="-fsanitize=memory" -RUN update-alternatives --set liblapack.so-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libmkl_rt.so && \ - update-alternatives --set libblas.so-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libmkl_rt.so +# Build Environment using MSAN +ENV CXXFLAGS="-stdlib=libc++ -fsanitize=memory -fno-omit-frame-pointer -fsanitize-recover=all -fsanitize-memory-track-origins -ggdb3" \ + CFLAGS="-fsanitize=memory -fno-omit-frame-pointer -fsanitize-recover=all -fsanitize-memory-track-origins -ggdb3" \ + LD_LIBRARY_PATH=/usr/lib/llvm-${LLVM}/lib \ + LDFLAGS="-fsanitize=memory" \ + MSAN_SYMBOLIZER_PATH=/usr/lib/llvm-${LLVM}/bin/llvm-symbolizer -ADD https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.5/src/CMake-hdf5-1.10.5.tar.gz /tmp/ -RUN mkdir /tmp/build && cd /tmp/build && \ - tar -C /tmp -xf /tmp/CMake-hdf5-1.10.5.tar.gz && \ - cmake /tmp/CMake-hdf5-1.10.5/hdf5-1.10.5 -DCMAKE_INSTALL_PREFIX=/usr && make -j2 && make install && \ - rm -rf * && \ - rm -rf /tmp/CMake-hdf5-1.10.5* /tmp/build +# HDF5 +ADD https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/src/CMake-hdf5-1.12.0.tar.gz /tmp/ +RUN cd /tmp && tar xf /tmp/CMake-hdf5-1.12.0.tar.gz && chmod 1777 . && \ + mkdir build && cd build && \ + cmake /tmp/CMake-hdf5-1.12.0/hdf5-1.12.0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/hdf5 && make -j${NTHREAD} && make install && \ + cd /tmp && rm -rf /tmp/CMake-hdf5-1.12.0* /tmp/build +ENV HDF5_ROOT=/opt/hdf5 + +# libevent +ADD https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz /tmp/ +RUN cd /tmp && tar xf /tmp/libevent-2.1.11-stable.tar.gz && cd libevent-2.1.11-stable && \ + ./configure --prefix=/opt/openmpi --enable-shared && make -j${NTHREAD} && make install && \ + cd /tmp && rm -rf /tmp/libevent* + +# hwloc +ADD https://download.open-mpi.org/release/hwloc/v2.2/hwloc-2.2.0.tar.bz2 /tmp/ +COPY packaging/hwloc.patch /tmp/ +RUN cd /tmp && tar xf /tmp/hwloc-2.2.0.tar.bz2 && patch -p0 -i hwloc.patch && cd hwloc-2.2.0 && \ + ./configure --prefix=/opt/openmpi --enable-shared && make -j${NTHREAD} && make install && \ + cd /tmp && rm -rf /tmp/hwloc* + +# OpenMPI +ADD https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.4.tar.bz2 /tmp/ +RUN cd /tmp && tar xf /tmp/openmpi-4.0.4.tar.bz2 && cd openmpi-4.0.4 && \ + ./configure --prefix=/opt/openmpi --enable-shared --disable-mpi-fortran --disable-pty-support --with-hwloc=/opt/openmpi --with-libevent=/opt/openmpi && make -j${NTHREAD} && make install && \ + cd /tmp && rm -rf /tmp/openmpi-4.0.4* +ENV MPI_ROOT=/opt/openmpi \ + MPICC=/opt/openmpi/bin/mpicc + +# Use libflame to provide blas / lapack +RUN git clone https://github.com/Wentzell/libflame /tmp/libflame && cd /tmp/libflame && \ + ./configure --prefix=/opt/libflame --enable-lapack2flame --enable-builtin-blas && make -j${NTHREAD} && make install && \ + cd /tmp && rm -rf /tmp/libflame + +# Dockerfile.build with sanitization enabled +COPY requirements.txt /src/$APPNAME/requirements.txt +# Install numpy first to prevent h5py from pulling in a newer version first +RUN pip3 install `grep numpy /src/$APPNAME/requirements.txt` && \ + pip3 install -r /src/$APPNAME/requirements.txt RUN useradd -m build ENV SRC=/src \ BUILD=/home/build \ INSTALL=/usr/local \ - PYTHONPATH=/usr/local/lib/python2.7/site-packages:${PYTHONPATH} \ - CMAKE_PREFIX_PATH=/usr/lib/cmake/itertools:${CMAKE_PREFIX_PATH} + PYTHONPATH=/usr/local/lib/python3.8/site-packages \ + CMAKE_PREFIX_PATH=/usr/lib/cmake/$APPNAME -COPY . ${SRC}/itertools -WORKDIR ${BUILD}/itertools -RUN chown -R build ${SRC}/itertools . +COPY . ${SRC}/$APPNAME +WORKDIR ${BUILD}/$APPNAME +RUN chown -R build . ${SRC}/$APPNAME USER build -RUN cmake $SRC/itertools -DCMAKE_INSTALL_PREFIX=$INSTALL -DMSAN=ON -DPYTHON_EXECUTABLE=$(which python) -RUN make VERBOSE=1 -j8 -ENV MSAN_SYMBOLIZER_PATH=/usr/lib/llvm-${LLVM}/bin/llvm-symbolizer CTEST_OUTPUT_ON_FAILURE=1 -RUN make test || true +RUN cmake $SRC/$APPNAME -DCMAKE_INSTALL_PREFIX=$INSTALL -DBuild_Deps=Always -DCLANG_OPT="$CXXFLAGS" -DMSAN=ON \ + -DLAPACK_LIBRARIES=/opt/libflame/lib/libflame.a -DBLAS_LIBRARIES=/opt/libflame/lib/libflame.a && \ + make -j${NTHREAD} +RUN make test CTEST_OUTPUT_ON_FAILURE=1 || true diff --git a/packaging/Dockerfile.ubuntu-clang b/packaging/Dockerfile.ubuntu-clang new file mode 100644 index 0000000..4875d9b --- /dev/null +++ b/packaging/Dockerfile.ubuntu-clang @@ -0,0 +1,41 @@ +FROM ubuntu:focal +ARG LLVM=9 + +# This platform includes dependencies for building docs +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + clang-${LLVM} \ + cmake \ + g++ \ + gfortran \ + git \ + vim \ + lldb-${LLVM} \ + hdf5-tools \ + libblas-dev \ + libboost-all-dev \ + libclang-${LLVM}-dev \ + libc++-${LLVM}-dev \ + libc++abi-${LLVM}-dev \ + libfftw3-dev \ + libgfortran4 \ + libgmp-dev \ + libhdf5-dev \ + liblapack-dev \ + libopenmpi-dev \ + openmpi-bin \ + openmpi-common \ + openmpi-doc \ + python3-clang-${LLVM} \ + python3-dev \ + python3-mako \ + python3-matplotlib \ + python3-mpi4py \ + python3-numpy \ + python3-pip \ + python3-scipy \ + python3-sphinx \ + python3-nbsphinx + +ENV PYTHON_VERSION=3.8 \ + CC=clang-${LLVM} CXX=clang++-${LLVM} CXXFLAGS="-stdlib=libc++" +RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM} 60 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM} --slave /usr/bin/clang-cpp clang-cpp /usr/bin/clang-cpp-${LLVM} diff --git a/packaging/Dockerfile.ubuntu-gcc b/packaging/Dockerfile.ubuntu-gcc new file mode 100644 index 0000000..2ac2476 --- /dev/null +++ b/packaging/Dockerfile.ubuntu-gcc @@ -0,0 +1,32 @@ +FROM ubuntu:bionic +ARG RELEASE=bionic + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + cmake \ + g++ \ + gfortran \ + git \ + vim \ + lldb-9 \ + hdf5-tools \ + libblas-dev \ + libboost-all-dev \ + libfftw3-dev \ + libgfortran3 \ + libgmp-dev \ + libhdf5-dev \ + liblapack-dev \ + libopenmpi-dev \ + openmpi-bin \ + openmpi-common \ + openmpi-doc \ + python3-dev \ + python3-mako \ + python3-matplotlib \ + python3-mpi4py \ + python3-numpy \ + python3-pip \ + python3-scipy + +ENV PYTHON_VERSION=3.6 \ + CC=gcc CXX=g++ diff --git a/packaging/TRIQS-app4triqs-3.0.0-foss-2019a-Python-3.7.2.eb b/packaging/TRIQS-app4triqs-3.0.0-foss-2019a-Python-3.7.2.eb new file mode 100644 index 0000000..12088a3 --- /dev/null +++ b/packaging/TRIQS-app4triqs-3.0.0-foss-2019a-Python-3.7.2.eb @@ -0,0 +1,61 @@ +easyblock = 'CMakeMake' + +name = 'TRIQS-itertools' +version = '3.0.0' +versionsuffix = '-Python-%(pyver)s' + +homepage = 'https://triqs.github.io/itertools/' +description = """ + TRIQS (Toolbox for Research on Interacting Quantum Systems) is a + scientific project providing a set of C++ and Python libraries to + develop new tools for the study of interacting quantum systems. + + PROVIDE HERE A DESCRIPTION OF YOUR APPLICATION +""" + +docurls = ['https://triqs.github.io/itertools/%(version_major_minor)s.x/'] +software_license = 'LicenseGPLv3' + +toolchain = {'name': 'foss', 'version': '2019a'} +toolchainopts = {'pic': True, 'usempi': True} + +source_urls = ['https://github.com/TRIQS/itertools/releases/download/%(version)s/'] +sources = ['itertools-%(version)s.tar.gz'] +checksums = ['PUT HERE THE SHA256 OF THE RELEASE TARBALL'] + +dependencies = [ + ('Python', '3.7.2'), + ('SciPy-bundle', '2019.03'), + ('Boost', '1.70.0'), + ('Clang', '8.0.0'), + ('GMP', '6.1.2'), + ('HDF5', '1.10.5'), + ('Mako', '1.0.8'), + ('h5py', '2.9.0'), + ('TRIQS', '3.0.0', versionsuffix), + ('NFFT', '3.5.1') +] + +builddependencies = [ + ('CMake', '3.13.3') +] + +separate_build_dir = True + +runtest = 'test' + +sanity_check_paths = { + 'files': ['include/itertools/itertools.hpp'], + 'dirs': ['include', 'include/itertools', 'share'], +} + +modextrapaths = { + 'CPLUS_INCLUDE_PATH': 'include', + 'CMAKE_PREFIX_PATH': 'lib/cmake/itertools', +} +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 0000000..2532460 --- /dev/null +++ b/packaging/conda/build.sh @@ -0,0 +1,20 @@ +#!/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" + +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 index 672f354..289631f 100644 --- a/packaging/conda/conda_build_config.yaml +++ b/packaging/conda/conda_build_config.yaml @@ -1,5 +1,3 @@ mpi: - mpich - openmpi -python: - - 2.7.* *_cpython # [not (aarch64 or ppc64le or win)]] diff --git a/packaging/conda/meta.yaml b/packaging/conda/meta.yaml index f069059..bc2ca27 100644 --- a/packaging/conda/meta.yaml +++ b/packaging/conda/meta.yaml @@ -1,16 +1,16 @@ -{% set version = "2.2.1" %} +{% set version = "3.0.0" %} package: - name: app4triqs + name: itertools version: {{ version }} source: - url: https://github.com/TRIQS/app4triqs/releases/download/{{ version }}/app4triqs-{{ version }}.tar.gz - sha256: # Put here the sha256sum of the arxiv + url: https://github.com/TRIQS/itertools/releases/download/{{ version }}/itertools-{{ version }}.tar.gz + sha256: PUT HERE THE SHA256 OF YOUR RELEASE TARBALL build: number: 0 - skip: True # [win or py>30] + skip: True # [win or py<30] requirements: build: @@ -19,22 +19,9 @@ requirements: - {{ compiler('c') }} - {{ compiler('cxx') }} host: - - triqs {{ '.'.join(version.split('.')[:2]) }} - - boost-cpp - - nfft - - hdf5 - {{ mpi }} - - libblas - - liblapack - - python run: - - {{ pin_compatible("triqs", max_pin="x.x") }} - - nfft - - hdf5 - {{ mpi }} - - libblas - - liblapack - - python test: commands: @@ -43,14 +30,14 @@ test: - 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 triqs_cthyb" + - python -c "import itertools" about: - home: https://triqs.github.io/cthyb + home: https://triqs.github.io/itertools license: GPL-3.0-or-later license_family: GPL license_file: LICENSE.txt - summary: 'A skeleton for a TRIQS application' + summary: 'An application based on the TRIQS library' extra: recipe-maintainers: diff --git a/share/cmake/extract_flags.cmake b/share/cmake/extract_flags.cmake index dfcf67b..e00ee62 100644 --- a/share/cmake/extract_flags.cmake +++ b/share/cmake/extract_flags.cmake @@ -89,7 +89,8 @@ macro(extract_flags) endif() endforeach() - # We have to replace generator expressions explicitly + # ==== 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}") @@ -97,6 +98,25 @@ macro(extract_flags) 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/cmake/itertools-config.cmake.in b/share/cmake/itertools-config.cmake.in index 678ec41..84f1be7 100644 --- a/share/cmake/itertools-config.cmake.in +++ b/share/cmake/itertools-config.cmake.in @@ -15,13 +15,12 @@ set(@PROJECT_NAME@_GIT_HASH @PROJECT_GIT_HASH@ CACHE STRING "@PROJECT_NAME@ git set(@PROJECT_NAME@_ROOT @CMAKE_INSTALL_PREFIX@ CACHE STRING "@PROJECT_NAME@ root directory") ## Find the target dependencies -#include(CMakeFindDependencyMacro) -#find_dependency(... HINTS @CMAKE_INSTALL_PREFIX@) +#find_package(... REQUIRED HINTS @CMAKE_INSTALL_PREFIX@) # Include the exported targets of this project include(@CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@/@PROJECT_NAME@-targets.cmake) -message(STATUS "Found @PROJECT_NAME@-config.cmake with version @PROJECT_VERSION@, hash = @PROJECT_GIT_HASH@") +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?") diff --git a/test/c++/CMakeLists.txt b/test/c++/CMakeLists.txt index 071b5fd..36466c3 100644 --- a/test/c++/CMakeLists.txt +++ b/test/c++/CMakeLists.txt @@ -11,7 +11,7 @@ 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}_c gtest_main ${PROJECT_NAME}_warnings) + 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