From 41f7b4bc1eb56e0f79f28f8a5fc07e94b610362a Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Thu, 5 Sep 2019 16:53:34 -0400 Subject: [PATCH] Create a C++-only version of the app4triqs skeleton --- .github/workflows/build.yml | 5 +- CMakeLists.txt | 11 ---- README.md | 7 +-- deps/CMakeLists.txt | 2 +- doc/CMakeLists.txt | 8 +-- doc/documentation.rst | 10 --- python/app4triqs/CMakeLists.txt | 26 -------- python/app4triqs/__init__.py | 30 --------- python/app4triqs/app4triqs_module_desc.py | 76 ----------------------- python/app4triqs/version.py.in | 31 --------- share/CMakeLists.txt | 5 -- share/app4triqs.modulefile.in | 1 - share/app4triqsvars.sh.in | 1 - share/cmake/app4triqs-config.cmake.in | 6 -- test/CMakeLists.txt | 4 -- test/python/Basic.py | 37 ----------- test/python/CMakeLists.txt | 15 ----- 17 files changed, 7 insertions(+), 268 deletions(-) delete mode 100644 python/app4triqs/CMakeLists.txt delete mode 100644 python/app4triqs/__init__.py delete mode 100644 python/app4triqs/app4triqs_module_desc.py delete mode 100644 python/app4triqs/version.py.in delete mode 100644 test/python/Basic.py delete mode 100644 test/python/CMakeLists.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52c7a83..6f4c896 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: build on: push: - branches: [ notriqs, '[0-9]+.[0-9]+.x' ] + branches: [ cpp_only_notriqs, '[0-9]+.[0-9]+.x' ] pull_request: - branches: [ notriqs, '[0-9]+.[0-9]+.x' ] + branches: [ cpp_only_notriqs, '[0-9]+.[0-9]+.x' ] workflow_call: workflow_dispatch: @@ -72,6 +72,7 @@ jobs: python3-clang-15 python3-dev python3-mako + python3-matplotlib python3-mpi4py python3-numpy python3-pip diff --git a/CMakeLists.txt b/CMakeLists.txt index 655052e..dde54d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,14 +63,8 @@ if(NOT IS_SUBPROJECT) message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------") endif() -# Python Support -option(PythonSupport "Build with Python support" ON) - # 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) @@ -152,11 +146,6 @@ 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) diff --git a/README.md b/README.md index a277b13..d8c3ad0 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To adapt this skeleton for a new TRIQS application, the following steps are nece * Run the following commands in order after replacing **appname** accordingly ```bash -git clone https://github.com/triqs/app4triqs --branch unstable appname +git clone https://github.com/triqs/app4triqs --branch cpp_only_notriqs appname cd appname ./share/squash_history.sh ./share/replace_and_rename.py appname @@ -36,7 +36,7 @@ You can merge future changes to the app4triqs skeleton into your project with th ```bash git remote update -git merge app4triqs_remote/unstable -X ours -m "Merge latest app4triqs skeleton changes" +git merge app4triqs_remote/cpp_only_notriqs -X ours -m "Merge latest app4triqs skeleton changes" ``` If you should encounter any conflicts resolve them and `git commit`. @@ -61,9 +61,6 @@ according to your needs (replace app4triqs in the following by the name of your * 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). diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 40a4c4e..4231d14 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -48,7 +48,7 @@ else() endif() # -- Cpp2Py -- -if(PythonSupport OR (NOT IS_SUBPROJECT AND Build_Documentation)) +if(NOT IS_SUBPROJECT AND Build_Documentation) external_dependency(Cpp2Py GIT_REPO https://github.com/TRIQS/cpp2py VERSION 2.0 diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index bc73e29..7c18023 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -55,17 +55,11 @@ endif() add_custom_target(${PROJECT_NAME}_docs_sphinx ALL) add_custom_command( TARGET ${PROJECT_NAME}_docs_sphinx - COMMAND PYTHONPATH=${PROJECT_BINARY_DIR}/python:${h5_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SPHINXBUILD_EXECUTABLE} -c . -j auto -b html ${CMAKE_CURRENT_SOURCE_DIR} html + COMMAND ${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() diff --git a/doc/documentation.rst b/doc/documentation.rst index a05d717..a196de6 100644 --- a/doc/documentation.rst +++ b/doc/documentation.rst @@ -17,13 +17,3 @@ C++ reference manual :maxdepth: 5 cpp2rst_generated/contents - -Python reference manual -======================= - -.. autosummary:: - :toctree: _autosummary - :template: autosummary_module_template.rst - :recursive: - - app4triqs diff --git a/python/app4triqs/CMakeLists.txt b/python/app4triqs/CMakeLists.txt deleted file mode 100644 index 12c3dad..0000000 --- a/python/app4triqs/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# 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 ${CPP2PY_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 ${CPP2PY_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) - install(TARGETS ${module_name} DESTINATION ${PYTHON_LIB_DEST}/${module_dir}) -endforeach() diff --git a/python/app4triqs/__init__.py b/python/app4triqs/__init__.py deleted file mode 100644 index 1d6bdf5..0000000 --- a/python/app4triqs/__init__.py +++ /dev/null @@ -1,30 +0,0 @@ -################################################################################ -# -# 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 deleted file mode 100644 index 92b3335..0000000 --- a/python/app4triqs/app4triqs_module_desc.py +++ /dev/null @@ -1,76 +0,0 @@ -# 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" --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 deleted file mode 100644 index 475c61e..0000000 --- a/python/app4triqs/version.py.in +++ /dev/null @@ -1,31 +0,0 @@ -################################################################################ -# -# 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@" -@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\n"%("@PROJECT_GIT_HASH@")) diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 46b4d8d..5062ac3 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -5,11 +5,6 @@ if(NOT IS_SUBPROJECT 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) diff --git a/share/app4triqs.modulefile.in b/share/app4triqs.modulefile.in index 6b6289d..bde963c 100644 --- a/share/app4triqs.modulefile.in +++ b/share/app4triqs.modulefile.in @@ -32,4 +32,3 @@ 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 index a499f10..b0ba52a 100644 --- a/share/app4triqsvars.sh.in +++ b/share/app4triqsvars.sh.in @@ -7,4 +7,3 @@ 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/app4triqs-config.cmake.in b/share/cmake/app4triqs-config.cmake.in index b6bb5bb..c6c4aa6 100644 --- a/share/cmake/app4triqs-config.cmake.in +++ b/share/cmake/app4triqs-config.cmake.in @@ -31,10 +31,4 @@ message(STATUS "Found @PROJECT_NAME@-config.cmake with version @PROJECT_VERSION@ # 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/test/CMakeLists.txt b/test/CMakeLists.txt index e79313f..d93e9ea 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1 @@ add_subdirectory(c++) - -if(PythonSupport) - add_subdirectory(python) -endif() diff --git a/test/python/Basic.py b/test/python/Basic.py deleted file mode 100644 index d0eba90..0000000 --- a/test/python/Basic.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python - -import unittest - -from app4triqs import Toto, chain -from h5 import * - -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) - -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 deleted file mode 100644 index bcb22bc..0000000 --- a/test/python/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# 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 ${CPP2PY_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:${h5_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SANITIZER_RT_PRELOAD}) -endforeach()