From a46565037bf434cd7e376745b412949bfa78f786 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 12:57:52 +0200 Subject: [PATCH 01/27] adapt conanfile for conan2 --- conanfile.py | 122 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 33 deletions(-) diff --git a/conanfile.py b/conanfile.py index 85ec24052..1aa58cb3a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,76 +1,132 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" class PROPOSALConan(ConanFile): name = "proposal" homepage = "https://github.com/tudo-astroparticlephysics/PROPOSAL" - license = "GNU Lesser General Public License v3.0" - description = "the very best lepton and photon propagator" + license = "LGPL-3.0" + package_type = "library" + url = "https://github.com/conan-io/conan-center-index" + description = "monte Carlo based lepton and photon propagator" topics = ("propagator", "lepton", "photon", "stochastic") + settings = "os", "compiler", "build_type", "arch" - exports_sources = "*" options = { "shared": [True, False], "fPIC": [True, False], - "with_testing": [True, False], "with_python": [True, False], + "with_testing": [True, False], "with_documentation": [True, False], } default_options = { "shared": False, "fPIC": True, + "with_python" : False, "with_testing": False, - "with_python": False, "with_documentation": False, } - generators = "cmake_find_package", "cmake_paths" - _cmake = None + + @property + def _min_cppstd(self): + return "14" + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15", + "msvc": "191", + "gcc": "5", + "clang": "5", + "apple-clang": "5", + } def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + self.folders.generators = "build" def requirements(self): - self.requires("cubicinterpolation/0.1.5") - self.requires("spdlog/1.10.0") - self.requires("nlohmann_json/3.9.1") + # cubicinterpolation: headers are transitively included, and function calls are made + # from implementation in headers (templates) + self.requires("cubicinterpolation/0.1.5", transitive_headers=True, transitive_libs=True) + # spdlog: requires transitive_libs due to direct calls to functionality from headers + self.requires("spdlog/1.11.0", transitive_headers=True, transitive_libs=True) + # nlohmann_json: public headers include json.hpp and json_fwd.hpp + self.requires("nlohmann_json/3.11.2", transitive_headers=True) if self.options.with_python: self.requires("pybind11/2.10.1") if self.options.with_testing: - self.requires("boost/1.78.0") + self.requires("boost/1.75.0") self.requires("gtest/1.11.0") if self.options.with_documentation: self.requires("doxygen/1.8.20") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = self.options.with_testing - self._cmake.definitions["BUILD_PYTHON"] = self.options.with_python - self._cmake.definitions["BUILD_DOCUMENTATION"] = self.options.with_documentation - self._cmake.configure() - return self._cmake + def build_requirements(self): + self.tool_requires("cmake/3.22.6") + + def validate(self): + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration( + "Can not build shared library on Visual Studio." + ) + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + minimum_version = self._minimum_compilers_version.get( + str(self.settings.compiler), False + ) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support" + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() cmake.install() if self.options.with_testing: - cmake.test() + cmake_test() def package(self): - self.copy("LICENSE", dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = self.options.with_testing + tc.variables["BUILD_PYTHON"] = self.options.with_python + tc.variables["BUILD_DOCUMENTATION"] = self.options.with_documentation + tc.generate() + deps = CMakeDeps(self) + deps.generate() def package_info(self): - self.cpp_info.names["cmake_find_package"] = "PROPOSAL" + self.cpp_info.set_property("cmake_file_name", "PROPOSAL") + self.cpp_info.set_property("cmake_target_name", "PROPOSAL::PROPOSAL") self.cpp_info.libs = ["PROPOSAL"] - self.cpp_info.requires = [ - "cubicinterpolation::CubicInterpolation", - "spdlog::spdlog", - "nlohmann_json::nlohmann_json", - ] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "PROPOSAL" + self.cpp_info.names["cmake_find_package_multi"] = "PROPOSAL" \ No newline at end of file From 951a9d862913f70da8d0c0d18a3289e53695c822 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 13:26:44 +0200 Subject: [PATCH 02/27] adapt setup.py --- pyproject.toml | 4 ++-- setup.py | 43 +++++++------------------------------------ 2 files changed, 9 insertions(+), 38 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aa349d554..6838842da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=45", "wheel", - "cmake>=3.16", - "conan~=1.33", + "cmake>=3.23", + "conan>=2.0.0", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 37dac0689..0442b61f6 100644 --- a/setup.py +++ b/setup.py @@ -32,8 +32,7 @@ def get_cmake(): if ret.returncode == 0: return exe - raise OSError("You need cmake >= 3.16") - + raise OSError("You need cmake >= 3.23") def exists_conan_default_file(): profiles = sp.check_output(["conan", "profile", "list"], encoding="UTF-8").split() @@ -41,36 +40,15 @@ def exists_conan_default_file(): return True return False - -def create_conan_profile(name): - cmd = ["conan", "profile", "new", f"{name}", "--detect"] +def create_conan_profile(): + cmd = ["conan", "profile", "detect"] r = sp.run(cmd) if r.returncode != 0: raise RuntimeError( - "conan was not able to create a new profile named {name}." + "conan was not able to create a new default profile." ) -def is_old_libcxx(): - """ if we are on gcc, we might be using an old library ABI """ - - cmd = ["conan", "profile", "get", "settings.compiler", "default"] - r = sp.check_output(cmd, encoding="UTF-8") - compiler = r.split()[0] - - if compiler != "gcc": - return False - - cmd = ["conan", "profile", "get", "settings.compiler.libcxx", "default"] - r = sp.check_output(cmd, encoding="UTF-8") - libcxx = r.split()[0] - - if libcxx == "libstdc++11": - return False - - return True - - class CMakeExtension(Extension): def __init__(self, name, source_dir=None, target=None, **kwargs): if source_dir is None: @@ -99,14 +77,13 @@ def build_cmake(self, ext): cmake = get_cmake() rpath = '@loader_path' if sys.platform == 'darwin' else '$ORIGIN' - CMAKE_CXX_FLAGS = "" if not os.getenv("NO_CONAN", False): print( "Using conan to install dependencies. Set environment variable NO_CONAN to skip conan." ) if not exists_conan_default_file(): - create_conan_profile("default") + create_conan_profile() conan_call = [ 'conan', @@ -117,24 +94,18 @@ def build_cmake(self, ext): '--build=missing' ] sp.run(conan_call, cwd=self.build_temp, check=True) - if is_old_libcxx(): - CMAKE_CXX_FLAGS = '-DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=OFF"' cmake_call = [ cmake, + ext.source_dir, + '-DCMAKE_TOOLCHAIN_FILE={}/build/conan_toolchain.cmake'.format(ext.source_dir), '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, '-DCMAKE_BUILD_TYPE=' + cfg, - '-DBUILD_TESTING=OFF', - '-DBUILD_PYTHON=ON', - '-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE', - '-DBUILD_EXAMPLE=OFF', '-DPython_EXECUTABLE=' + sys.executable, '-DCMAKE_INSTALL_RPATH={}'.format(rpath), '-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON', '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF', ] - if CMAKE_CXX_FLAGS: - cmake_call.append(CMAKE_CXX_FLAGS) sp.run(cmake_call, cwd=self.build_temp, check=True) build_call = [ cmake, From 486b71468dec877306923e254954262dd12913e0 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 13:44:27 +0200 Subject: [PATCH 03/27] adapt github workflows --- .github/workflows/cpp.yml | 28 ++++++---------------------- .github/workflows/python.yml | 7 ------- conanfile.py | 2 -- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 04e36d753..3ed7ba56b 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -72,28 +72,12 @@ jobs: with: python-version: '3.8' - name: Install python dependencies - run: python -m pip install 'conan~=1.33' + run: python -m pip install conan - name: Initialize conan if : steps.cache-conan.outputs.cache-hit != 'true' - run: conan profile new default --detect - - name: Update conan profile - if : ${{ matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-latest' }} - run: conan profile update settings.compiler.libcxx=libstdc++11 default - - name: Update conan profile - run: conan profile update settings.compiler.cppstd=14 default - - name: create build directory - if : steps.cache-build.outputs.cache-hit != 'true' - run: mkdir PROPOSAL_BUILD - - name: Install PROPOSAL dependencies - run: cd PROPOSAL_BUILD && conan install .. -o with_testing=True --build=missing - - name: Run build automatisation tool - run: cmake . -B PROPOSAL_BUILD -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_TESTING=TRUE - - name: Build lib - if: ${{ matrix.os != 'windows-latest' }} - run: cmake --build PROPOSAL_BUILD - - name: Build lib - if: ${{ matrix.os == 'windows-latest' }} - run: cmake --build PROPOSAL_BUILD --target ALL_BUILD --config Release + run: conan profile detect + - name: Build and Install PROPOSAL + run: conan build . -o with_testing=True --build=missing test: runs-on: ${{ matrix.os }} @@ -115,7 +99,7 @@ jobs: compilerpp : "g++-5" - os : "windows-latest" env: - PROPOSAL_TEST_FILES: ${{ github.workspace }}/PROPOSAL_BUILD/tests/TestFiles + PROPOSAL_TEST_FILES: ${{ github.workspace }}/build/Release/tests/TestFiles steps: - uses: actions/checkout@v2 - name: Cache conan @@ -132,4 +116,4 @@ jobs: path: PROPOSAL_BUILD key: ${{ runner.os }}-cache-build-${{ matrix.compiler }}-${{ github.sha }}-key - name: Run tests - run: ctest --test-dir PROPOSAL_BUILD -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" + run: ctest --test-dir build/Release/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 9e8b39622..75ade54fc 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -13,13 +13,6 @@ jobs: with: path: ~/.conan key: ${{ runner.os }}-cache-conan-gcc-${{ hashFiles('conanfile.py') }}-key - - name: Install conan - run: python -m pip install 'conan~=1.33' - - name: Initialize conan - if : steps.cache-conan.outputs.cache-hit != 'true' - run: conan profile new default --detect - - name: Update conan profile - run: conan profile update settings.compiler.libcxx=libstdc++11 default - name: Install Python 🐍 distributions 📦 run: python -m pip install . - name: Install pytest diff --git a/conanfile.py b/conanfile.py index 1aa58cb3a..8c307b139 100644 --- a/conanfile.py +++ b/conanfile.py @@ -104,8 +104,6 @@ def build(self): cmake.configure() cmake.build() cmake.install() - if self.options.with_testing: - cmake_test() def package(self): copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) From 975b96be89db5d85c78b7c69e4762c039e7079a0 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 13:46:03 +0200 Subject: [PATCH 04/27] install conan --- .github/workflows/python.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 75ade54fc..80c535f62 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -13,6 +13,8 @@ jobs: with: path: ~/.conan key: ${{ runner.os }}-cache-conan-gcc-${{ hashFiles('conanfile.py') }}-key + - name: Install conan + run: python -m pip install conan - name: Install Python 🐍 distributions 📦 run: python -m pip install . - name: Install pytest From 930d7f4b494a4d2b22e3e658e7596aafa82cc946 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 13:55:35 +0200 Subject: [PATCH 05/27] explicitly set c++ standard for gcc5 because it defaults to gcc99 --- .github/workflows/cpp.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 3ed7ba56b..d4ae8a006 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -76,7 +76,11 @@ jobs: - name: Initialize conan if : steps.cache-conan.outputs.cache-hit != 'true' run: conan profile detect + - name: Build and Install PROPOSAL (gcc5) + if : ${{ matrix.compiler == 'gcc-5' }} + run: conan build . -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 --build=missing - name: Build and Install PROPOSAL + if : ${{ matrix.compiler != 'gcc-5' }} run: conan build . -o with_testing=True --build=missing test: From 52743c05389762d4273965adf3c0d77b8ff5fad9 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 14:43:17 +0200 Subject: [PATCH 06/27] fix cache path --- .github/workflows/cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index d4ae8a006..32b7b6d6b 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -66,7 +66,7 @@ jobs: id: cache-build uses: actions/cache@v2 with: - path: PROPOSAL_BUILD + path: build key: ${{ runner.os }}-cache-build-${{ matrix.compiler }}-${{ github.sha }}-key - uses: actions/setup-python@v2 with: @@ -117,7 +117,7 @@ jobs: id: cache-build uses: actions/cache@v2 with: - path: PROPOSAL_BUILD + path: build key: ${{ runner.os }}-cache-build-${{ matrix.compiler }}-${{ github.sha }}-key - name: Run tests run: ctest --test-dir build/Release/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" From 4e0add7084789ced4599dda977d218bdc894be83 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 15:24:42 +0200 Subject: [PATCH 07/27] correct windows path to tests --- .github/workflows/cpp.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 32b7b6d6b..2a09f99a3 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -120,4 +120,8 @@ jobs: path: build key: ${{ runner.os }}-cache-build-${{ matrix.compiler }}-${{ github.sha }}-key - name: Run tests + if: ${{ matrix.os != 'windows-latest' }} run: ctest --test-dir build/Release/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" + - name: Run tests (Windows) + if: ${{ matrix.os != 'windows-latest' }} + run: ctest --test-dir build/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" \ No newline at end of file From 2d8485300fa7dc3e42f28a1524f0c7028ed1437d Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 15:29:01 +0200 Subject: [PATCH 08/27] fix --- .github/workflows/cpp.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 2a09f99a3..05b3b8bdb 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -74,7 +74,6 @@ jobs: - name: Install python dependencies run: python -m pip install conan - name: Initialize conan - if : steps.cache-conan.outputs.cache-hit != 'true' run: conan profile detect - name: Build and Install PROPOSAL (gcc5) if : ${{ matrix.compiler == 'gcc-5' }} From 440a33b51b7881f0ef0e7cb0220042675f8c91e7 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 16:14:07 +0200 Subject: [PATCH 09/27] correct wrong setting for windows test --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 05b3b8bdb..95b9ce323 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -122,5 +122,5 @@ jobs: if: ${{ matrix.os != 'windows-latest' }} run: ctest --test-dir build/Release/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" - name: Run tests (Windows) - if: ${{ matrix.os != 'windows-latest' }} + if: ${{ matrix.os == 'windows-latest' }} run: ctest --test-dir build/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" \ No newline at end of file From 45df900f6981d926dbcadc457386d369114bb651 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 16:40:34 +0200 Subject: [PATCH 10/27] update INSTALL.md [ci skip] --- INSTALL.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 409c12afc..fa9b4e6a6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,23 +18,23 @@ For more detailed information about the specific building tools, see the listed For this installation approach, all dependencies will be fetched by conan, meaning that you don't have to install them by yourself. If you have not installed conan yet, you can do so, for example: ```sh -$ pip install "conan~=1.33" +$ pip install "conan~=2.0" ``` Clone the repository and create a build directory ```sh $ git clone https://github.com/tudo-astroparticlephysics/PROPOSAL.git -$ cd PROPOSAL && mkdir build && cd build +$ cd PROPOSAL ``` -Use conan to prepare all dependencies. You can pass additional options to conan. +To prepare all dependencies, build PROPOSAL, and install PROPOSAL, simply use the command ```sh -$ conan install .. -o with_python=True # other optional dependencies +$ conan build . -o with_python=True # other optional dependencies ``` -The following options can be passed to `conan install`: +The following options can be passed to `conan build`: | Option. | default | Description | | -------------------- | ------- | --------------------------------------------- | @@ -42,22 +42,14 @@ The following options can be passed to `conan install`: | `with_testing` | False | Build TestFiles for Python. | | `with_documentation` | False | Build doxygen documentation of C++ code (WIP) | -Build and install PROPOSAL. You may require root privileges when installing, depending on the installation location: - -```sh -$ conan build .. -``` -To set the install location, use `-pf / --package-folder` option. -The default is `build/package`. +To set the install location, use `-o / --output-folder` option. +The default is the current directory. E.g. to install proposal into `$HOME/.local/proposal`: ``` -$ conan build .. -pf $HOME/.local/proposal +$ conan build . -o $HOME/.local/proposal ``` -This will also run the tests if `with_testing` is true. - - *Note:* As an alternative, you may create a local conan package and use it in your project. See the [conan documentation](https://docs.conan.io/en/latest/) for more information. ## Building using pip (recommended for Python users) From f8c27274f6d5a2a52c8083bfa2e5bb9199ce5ab0 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 19 Apr 2023 16:45:16 +0200 Subject: [PATCH 11/27] remove old code in CMakeLists.txt --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37a47bd72..0bef1ab2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,10 +11,6 @@ project(PROPOSAL DESCRIPTION "The very best photon and lepton propagator." ) -if (EXISTS ${CMAKE_BINARY_DIR}/conan_paths.cmake) - include(${CMAKE_BINARY_DIR}/conan_paths.cmake) -endif() - if(NOT CMAKE_BUILD_TYPE) message(STATUS "No build type has been specified. Using default system build type. You may want to change this to" "'Release' if you are using PROPOSAL for production purposes.") From ea0c6498fb4e649befcc425c7de0bd8c00d6e80f Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 10:31:26 +0200 Subject: [PATCH 12/27] adapt installation process, separating conan install and CMake --- .github/workflows/cpp.yml | 17 ++++++----------- INSTALL.md | 19 ++++++++++++++----- conanfile.py | 4 +--- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 95b9ce323..5c89ae6d1 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -75,13 +75,12 @@ jobs: run: python -m pip install conan - name: Initialize conan run: conan profile detect - - name: Build and Install PROPOSAL (gcc5) - if : ${{ matrix.compiler == 'gcc-5' }} - run: conan build . -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 --build=missing + - name: Prepare dependencies using conan + run: conan install . --build=missing -o with_testing=True + - name: Call CMake + run: cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - name: Build and Install PROPOSAL - if : ${{ matrix.compiler != 'gcc-5' }} - run: conan build . -o with_testing=True --build=missing - + run: cmake --build . -j2 && cmake --install . test: runs-on: ${{ matrix.os }} needs: build @@ -102,7 +101,7 @@ jobs: compilerpp : "g++-5" - os : "windows-latest" env: - PROPOSAL_TEST_FILES: ${{ github.workspace }}/build/Release/tests/TestFiles + PROPOSAL_TEST_FILES: ${{ github.workspace }}/build/tests/TestFiles steps: - uses: actions/checkout@v2 - name: Cache conan @@ -119,8 +118,4 @@ jobs: path: build key: ${{ runner.os }}-cache-build-${{ matrix.compiler }}-${{ github.sha }}-key - name: Run tests - if: ${{ matrix.os != 'windows-latest' }} - run: ctest --test-dir build/Release/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" - - name: Run tests (Windows) - if: ${{ matrix.os == 'windows-latest' }} run: ctest --test-dir build/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md index fa9b4e6a6..67c97656b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -31,7 +31,7 @@ $ cd PROPOSAL To prepare all dependencies, build PROPOSAL, and install PROPOSAL, simply use the command ```sh -$ conan build . -o with_python=True # other optional dependencies +$ conan install . --build=missing -o with_python=True # other options ``` The following options can be passed to `conan build`: @@ -43,13 +43,22 @@ The following options can be passed to `conan build`: | `with_documentation` | False | Build doxygen documentation of C++ code (WIP) | -To set the install location, use `-o / --output-folder` option. -The default is the current directory. -E.g. to install proposal into `$HOME/.local/proposal`: +Next, call CMake, using the toolchain file created by conan: + +```sh +$ cd build +$ cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake ``` -$ conan build . -o $HOME/.local/proposal + +Now make and install PROPOSAL + +```sh +$ cmake --build . -j4 +$ cmake --install . ``` +Per default, CMake installs PROPOSAL to `/usr/local`. To change this, specify the install directory when calling CMake, for example `cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_INSTALL_PREFIX=/path/to/dir`. + *Note:* As an alternative, you may create a local conan package and use it in your project. See the [conan documentation](https://docs.conan.io/en/latest/) for more information. ## Building using pip (recommended for Python users) diff --git a/conanfile.py b/conanfile.py index 8c307b139..acc08c475 100644 --- a/conanfile.py +++ b/conanfile.py @@ -77,8 +77,6 @@ def requirements(self): if self.options.with_documentation: self.requires("doxygen/1.8.20") - def build_requirements(self): - self.tool_requires("cmake/3.22.6") def validate(self): if is_msvc(self) and self.options.shared: @@ -103,7 +101,6 @@ def build(self): cmake = CMake(self) cmake.configure() cmake.build() - cmake.install() def package(self): copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) @@ -116,6 +113,7 @@ def generate(self): tc.variables["BUILD_TESTING"] = self.options.with_testing tc.variables["BUILD_PYTHON"] = self.options.with_python tc.variables["BUILD_DOCUMENTATION"] = self.options.with_documentation + tc.variables["CMAKE_BUILD_TYPE"] = "Release" # set as default tc.generate() deps = CMakeDeps(self) deps.generate() From 90c9cea1c6818664859e64552cd2b7f4a5b0a4f9 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 10:35:43 +0200 Subject: [PATCH 13/27] explicitly set compiler.cppstd for gcc5 becaused it defaults to c++99 --- .github/workflows/cpp.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 5c89ae6d1..f9a06a4ae 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -76,7 +76,11 @@ jobs: - name: Initialize conan run: conan profile detect - name: Prepare dependencies using conan + if : ${{ matrix.compiler != 'gcc-5' }} run: conan install . --build=missing -o with_testing=True + - name: Prepare dependencies using conan (gcc5) + if : ${{ matrix.compiler == 'gcc-5' }} + run: conan install . --build=missing -o with_testing=True compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 - name: Call CMake run: cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - name: Build and Install PROPOSAL From a6526f5e363ea5bcd7cea70227404b5a27390963 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 10:50:16 +0200 Subject: [PATCH 14/27] typo in workflow for cpp build --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index f9a06a4ae..8ba1893c4 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -80,7 +80,7 @@ jobs: run: conan install . --build=missing -o with_testing=True - name: Prepare dependencies using conan (gcc5) if : ${{ matrix.compiler == 'gcc-5' }} - run: conan install . --build=missing -o with_testing=True compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 + run: conan install . --build=missing -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 - name: Call CMake run: cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - name: Build and Install PROPOSAL From 88ea90621f3d47dc91180afe1b8a7039ab933a41 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 10:59:02 +0200 Subject: [PATCH 15/27] debug --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 8ba1893c4..2612317ba 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -84,7 +84,7 @@ jobs: - name: Call CMake run: cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - name: Build and Install PROPOSAL - run: cmake --build . -j2 && cmake --install . + run: pwd && ls && cmake --build . -j2 && cmake --install . test: runs-on: ${{ matrix.os }} needs: build From 34c18a76236eec3e7a8f93fd103f9a4fbe5a1d12 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 11:15:57 +0200 Subject: [PATCH 16/27] restructure --- .github/workflows/cpp.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 2612317ba..e8f23b4f1 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -81,10 +81,14 @@ jobs: - name: Prepare dependencies using conan (gcc5) if : ${{ matrix.compiler == 'gcc-5' }} run: conan install . --build=missing -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 + - name: Enter build folder + run: cd build - name: Call CMake - run: cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - - name: Build and Install PROPOSAL - run: pwd && ls && cmake --build . -j2 && cmake --install . + run: cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + - name: Build PROPOSAL + run: cmake --build . -j2 + - name: Install PROPOSAL + run: cmake --install . test: runs-on: ${{ matrix.os }} needs: build From ea62959fe33d86367ca095daa02edbe31b27886b Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 11:19:38 +0200 Subject: [PATCH 17/27] debug --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index e8f23b4f1..13b188ba3 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -82,7 +82,7 @@ jobs: if : ${{ matrix.compiler == 'gcc-5' }} run: conan install . --build=missing -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 - name: Enter build folder - run: cd build + run: pwd && cd build && pwd && ls - name: Call CMake run: cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake - name: Build PROPOSAL From da351da8f282bf360cb639a252d9a3e9b2a7c355 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 11:24:47 +0200 Subject: [PATCH 18/27] test --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 13b188ba3..6177194e4 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -84,7 +84,7 @@ jobs: - name: Enter build folder run: pwd && cd build && pwd && ls - name: Call CMake - run: cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + run: cmake . -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake - name: Build PROPOSAL run: cmake --build . -j2 - name: Install PROPOSAL From 3e20cdd4f549813bc8436acfce8d2c17e77e3ebc Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 11:37:50 +0200 Subject: [PATCH 19/27] dont install proposal --- .github/workflows/cpp.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 6177194e4..d3292c2e9 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -81,14 +81,10 @@ jobs: - name: Prepare dependencies using conan (gcc5) if : ${{ matrix.compiler == 'gcc-5' }} run: conan install . --build=missing -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 - - name: Enter build folder - run: pwd && cd build && pwd && ls - name: Call CMake run: cmake . -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake - name: Build PROPOSAL run: cmake --build . -j2 - - name: Install PROPOSAL - run: cmake --install . test: runs-on: ${{ matrix.os }} needs: build From a7733272514efd7bbca56bfc9fac8dfeec73be5a Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 11:45:05 +0200 Subject: [PATCH 20/27] deactivate windows runner for now because zlib download is not available --- .github/workflows/cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index d3292c2e9..881a797ac 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -20,7 +20,7 @@ jobs: - os : "ubuntu-20.04" compiler : "gcc-5" compilerpp : "g++-5" - - os : "windows-latest" + #- os : "windows-latest" env: CC: ${{ matrix.compiler }} CXX: ${{ matrix.compilerpp }} @@ -103,7 +103,7 @@ jobs: - os : "ubuntu-20.04" compiler : "gcc-5" compilerpp : "g++-5" - - os : "windows-latest" + #- os : "windows-latest" env: PROPOSAL_TEST_FILES: ${{ github.workspace }}/build/tests/TestFiles steps: From 1560cfca62949af40d0df91f41be689106be97b0 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 12:17:23 +0200 Subject: [PATCH 21/27] fix path to test files --- .github/workflows/cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 881a797ac..3d2349fdd 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -105,7 +105,7 @@ jobs: compilerpp : "g++-5" #- os : "windows-latest" env: - PROPOSAL_TEST_FILES: ${{ github.workspace }}/build/tests/TestFiles + PROPOSAL_TEST_FILES: ${{ github.workspace }}/tests/TestFiles steps: - uses: actions/checkout@v2 - name: Cache conan @@ -122,4 +122,4 @@ jobs: path: build key: ${{ runner.os }}-cache-build-${{ matrix.compiler }}-${{ github.sha }}-key - name: Run tests - run: ctest --test-dir build/tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" \ No newline at end of file + run: ctest --test-dir tests -j2 --verbose -E "(Brems.*Interpolant|Photo.*Interpolant|Epair.*Interpolant|Mupair.*Interpolant)" \ No newline at end of file From 83c90c175abf13a8503a4397409be34805c8865b Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 14:19:36 +0200 Subject: [PATCH 22/27] add macOS python test and re-enable windows tests --- .github/workflows/cpp.yml | 4 ++-- .github/workflows/python.yml | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 3d2349fdd..6c393e028 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -20,7 +20,7 @@ jobs: - os : "ubuntu-20.04" compiler : "gcc-5" compilerpp : "g++-5" - #- os : "windows-latest" + - os : "windows-latest" env: CC: ${{ matrix.compiler }} CXX: ${{ matrix.compilerpp }} @@ -103,7 +103,7 @@ jobs: - os : "ubuntu-20.04" compiler : "gcc-5" compilerpp : "g++-5" - #- os : "windows-latest" + - os : "windows-latest" env: PROPOSAL_TEST_FILES: ${{ github.workspace }}/tests/TestFiles steps: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 80c535f62..847dee8df 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -4,7 +4,12 @@ on: [push] jobs: build: - runs-on: "ubuntu-latest" + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os : "ubuntu-latest" + - os : "macos-latest" steps: - uses: actions/checkout@v2 - name: Cache conan @@ -12,7 +17,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.conan - key: ${{ runner.os }}-cache-conan-gcc-${{ hashFiles('conanfile.py') }}-key + key: ${{ runner.os }}-cache-conan-${{ matrix.compiler }}-${{ hashFiles('conanfile.py') }}-key - name: Install conan run: python -m pip install conan - name: Install Python 🐍 distributions 📦 From f383b23174926a65637f015ff11add1eae8b1468 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 14:21:58 +0200 Subject: [PATCH 23/27] change python to python3 for python runner so that MacOS uses python3 instead of default python2 --- .github/workflows/python.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 847dee8df..41b6f8931 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -19,10 +19,10 @@ jobs: path: ~/.conan key: ${{ runner.os }}-cache-conan-${{ matrix.compiler }}-${{ hashFiles('conanfile.py') }}-key - name: Install conan - run: python -m pip install conan + run: python3 -m pip install conan - name: Install Python 🐍 distributions 📦 - run: python -m pip install . + run: python3 -m pip install . - name: Install pytest - run: python -m pip install pytest + run: python3 -m pip install pytest - name: run pytest - run: python -m pytest tests/python -v + run: python3 -m pytest tests/python -v From 2dff1b289998d2adcb046a495124ad3e131010ae Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Thu, 20 Apr 2023 14:42:03 +0200 Subject: [PATCH 24/27] revert increased minimal cmake version in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6838842da..246260a6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=45", "wheel", - "cmake>=3.23", + "cmake>=3.16", "conan>=2.0.0", ] build-backend = "setuptools.build_meta" From 0b19d0255e8e94490618f83143f95ba70a358536 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Fri, 21 Apr 2023 11:41:40 +0200 Subject: [PATCH 25/27] fix cmake for windows in github runner --- .github/workflows/cpp.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 6c393e028..e3762ce37 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -82,9 +82,17 @@ jobs: if : ${{ matrix.compiler == 'gcc-5' }} run: conan install . --build=missing -o with_testing=True -s:b compiler.cppstd=gnu14 -s compiler.cppstd=gnu14 - name: Call CMake + if: ${{ matrix.os != 'windows-latest' }} run: cmake . -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake + - name: Call CMake (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: cmake . -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW - name: Build PROPOSAL + if: ${{ matrix.os != 'windows-latest' }} run: cmake --build . -j2 + - name: Build PROPOSAL (Windows) + if: ${{ matrix.os != 'windows-latest' }} + run: cmake --build . -j2 --config Release test: runs-on: ${{ matrix.os }} needs: build From ca215b78cdd651f7f9ac49ff4f84b5718e46af37 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Fri, 21 Apr 2023 18:35:26 +0200 Subject: [PATCH 26/27] Update INSTALL.md Co-authored-by: Ludwig Neste <31670556+The-Ludwig@users.noreply.github.com> --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 67c97656b..88f617156 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -59,7 +59,7 @@ $ cmake --install . Per default, CMake installs PROPOSAL to `/usr/local`. To change this, specify the install directory when calling CMake, for example `cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_INSTALL_PREFIX=/path/to/dir`. -*Note:* As an alternative, you may create a local conan package and use it in your project. See the [conan documentation](https://docs.conan.io/en/latest/) for more information. +*Note:* As an alternative, you may create a local conan package and use it in your project. See the [conan documentation](https://docs.conan.io/2/) for more information. ## Building using pip (recommended for Python users) From 3aff96bfb6c021eb58ab4059b739adf17bd85738 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Fri, 21 Apr 2023 18:39:57 +0200 Subject: [PATCH 27/27] Link to new conan documentation [ci skip] --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 88f617156..e75f23f53 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -8,7 +8,7 @@ All different installation approaches are going to be explained in the following For more detailed information about the specific building tools, see the listed documentations: -- [conan documentation](https://docs.conan.io/en/latest/) +- [conan documentation](https://docs.conan.io/2/) - [CMake documentation](https://cmake.org/cmake/help/latest/) - [pip documentation](https://pip.pypa.io/en/stable/)