diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55cbc54..4ad2f6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: build on: push: - branches: [ unstable ] + branches: [ unstable, cpp_only ] pull_request: - branches: [ unstable ] + branches: [ unstable, cpp_only ] workflow_call: workflow_dispatch: diff --git a/CMakeLists.txt b/CMakeLists.txt index dca0f45..d0ca6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,17 +69,8 @@ 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) @@ -142,11 +133,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 1657290..e0cbdfa 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 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 -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 e26dfba..8688a34 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 40eb49c..64d3cde 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -56,17 +56,11 @@ endif() 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 + 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/_autosummary/app4triqs.app4triqs_module.Toto.rst b/doc/_autosummary/app4triqs.app4triqs_module.Toto.rst new file mode 100644 index 0000000..ad86e27 --- /dev/null +++ b/doc/_autosummary/app4triqs.app4triqs_module.Toto.rst @@ -0,0 +1,32 @@ +app4triqs.app4triqs\_module.Toto +================================ + +.. currentmodule:: app4triqs.app4triqs_module + +.. autoclass:: Toto + :members: + :show-inheritance: + :inherited-members: + + +.. automethod:: __init__ + + +.. rubric:: Methods + +.. autosummary:: + + ~Toto.__init__ + ~Toto.f + ~Toto.hdf5_format + + + + + +.. rubric:: Attributes + +.. autosummary:: + + ~Toto.i + diff --git a/doc/_autosummary/app4triqs.app4triqs_module.chain.rst b/doc/_autosummary/app4triqs.app4triqs_module.chain.rst new file mode 100644 index 0000000..2714847 --- /dev/null +++ b/doc/_autosummary/app4triqs.app4triqs_module.chain.rst @@ -0,0 +1,6 @@ +app4triqs.app4triqs\_module.chain +================================= + +.. currentmodule:: app4triqs.app4triqs_module + +.. autofunction:: chain \ No newline at end of file diff --git a/doc/_autosummary/app4triqs.app4triqs_module.rst b/doc/_autosummary/app4triqs.app4triqs_module.rst new file mode 100644 index 0000000..021a721 --- /dev/null +++ b/doc/_autosummary/app4triqs.app4triqs_module.rst @@ -0,0 +1,39 @@ +app4triqs.app4triqs\_module +=========================== + +.. automodule:: app4triqs.app4triqs_module + + + +.. rubric:: Functions + +.. autosummary:: + :toctree: + + chain + + + + + + + + + +.. rubric:: Classes + +.. autosummary:: + :toctree: + :template: autosummary_class_template.rst + + Toto + + + + + + + + + + diff --git a/doc/_autosummary/app4triqs.rst b/doc/_autosummary/app4triqs.rst new file mode 100644 index 0000000..43197c8 --- /dev/null +++ b/doc/_autosummary/app4triqs.rst @@ -0,0 +1,35 @@ +app4triqs +========= + +.. automodule:: app4triqs + + + + + + + + + + + + + + + + + + + +.. rubric:: Modules + +.. autosummary:: + :toctree: + :template: autosummary_module_template.rst + :recursive: + + + app4triqs.app4triqs_module + app4triqs.version + + diff --git a/doc/_autosummary/app4triqs.version.rst b/doc/_autosummary/app4triqs.version.rst new file mode 100644 index 0000000..a21daae --- /dev/null +++ b/doc/_autosummary/app4triqs.version.rst @@ -0,0 +1,32 @@ +app4triqs.version +================= + +.. automodule:: app4triqs.version + + + +.. rubric:: Functions + +.. autosummary:: + :toctree: + + show_git_hash + show_version + + + + + + + + + + + + + + + + + + diff --git a/doc/_autosummary/app4triqs.version.show_git_hash.rst b/doc/_autosummary/app4triqs.version.show_git_hash.rst new file mode 100644 index 0000000..b67d7dd --- /dev/null +++ b/doc/_autosummary/app4triqs.version.show_git_hash.rst @@ -0,0 +1,6 @@ +app4triqs.version.show\_git\_hash +================================= + +.. currentmodule:: app4triqs.version + +.. autofunction:: show_git_hash \ No newline at end of file diff --git a/doc/_autosummary/app4triqs.version.show_version.rst b/doc/_autosummary/app4triqs.version.show_version.rst new file mode 100644 index 0000000..b9d59c6 --- /dev/null +++ b/doc/_autosummary/app4triqs.version.show_version.rst @@ -0,0 +1,6 @@ +app4triqs.version.show\_version +=============================== + +.. currentmodule:: app4triqs.version + +.. autofunction:: show_version \ No newline at end of file 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 753f314..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 ${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 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 161e72f..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" -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 deleted file mode 100644 index 2d63daf..0000000 --- a/python/app4triqs/version.py.in +++ /dev/null @@ -1,32 +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@" -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/share/CMakeLists.txt b/share/CMakeLists.txt index 8d258a5..708e8e6 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -6,11 +6,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 2c9befe..f55633a 100644 --- a/share/app4triqs.modulefile.in +++ b/share/app4triqs.modulefile.in @@ -36,4 +36,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 c0472fc..0000000 --- a/test/python/Basic.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/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 deleted file mode 100644 index aa9d877..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 ${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()