Skip to content

Commit

Permalink
Merge remote-tracking branch 'app4triqs_remote/cpp_only_notriqs' into…
Browse files Browse the repository at this point in the history
… unstable
  • Loading branch information
Wentzell committed Aug 6, 2020
2 parents 771c902 + 0456dfa commit 2232c02
Show file tree
Hide file tree
Showing 30 changed files with 448 additions and 206 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
$<$<CONFIG:Debug>:-Og>
$<$<CONFIG:Debug>:-ggdb3>
)
add_compile_options($<$<CONFIG:Debug>:-ggdb3>)

# Create an Interface target for compiler warnings
add_library(${PROJECT_NAME}_warnings INTERFACE)
Expand Down
24 changes: 24 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions deps/external_dependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions doc/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions doc/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'
Expand All @@ -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)}
11 changes: 2 additions & 9 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand All @@ -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 |
Expand Down
104 changes: 0 additions & 104 deletions doc/sphinxext/autorun/autorun.py

This file was deleted.

93 changes: 93 additions & 0 deletions doc/sphinxext/sphinx_autorun/__init__.py
Original file line number Diff line number Diff line change
@@ -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')
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from code import InteractiveInterpreter


def main():
"""
Print lines of input along with output.
Expand All @@ -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 :

4 changes: 4 additions & 0 deletions doc/sphinxext/sphinx_autorun/version.py
Original file line number Diff line number Diff line change
@@ -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'
Binary file added doc/themes/agogo/static/bgfooter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/themes/agogo/static/bgtop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/themes/triqs/static/bodybg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/themes/triqs/static/footerbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/themes/triqs/static/headerbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/themes/triqs/static/listitem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/themes/triqs/static/relbg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2232c02

Please sign in to comment.