From 4075162fc2724617d495c61d56ffcda794b530ee Mon Sep 17 00:00:00 2001 From: Roberto Rossini <71787608+robomics@users.noreply.github.com> Date: Thu, 16 May 2024 09:14:15 +0200 Subject: [PATCH] Switch from conanfile.txt to conanfile.py (#169) --- .github/workflows/build-dockerfile.yml | 4 +- .github/workflows/codecov.yml | 6 +- .github/workflows/fuzzy-testing.yml | 4 +- .github/workflows/macos-ci.yml | 8 +-- .github/workflows/run-clang-tidy.yml | 6 +- .github/workflows/ubuntu-ci.yml | 8 +-- .github/workflows/windows-ci.yml | 8 +-- Dockerfile | 4 +- conanfile.py | 74 ++++++++++++++++++++++ conanfile.txt | 36 ----------- setup_conan_environments.sh | 2 +- test/packaging/test_find_package/README.md | 2 +- 12 files changed, 100 insertions(+), 62 deletions(-) create mode 100644 conanfile.py delete mode 100644 conanfile.txt diff --git a/.github/workflows/build-dockerfile.yml b/.github/workflows/build-dockerfile.yml index 685560a5..201e7643 100644 --- a/.github/workflows/build-dockerfile.yml +++ b/.github/workflows/build-dockerfile.yml @@ -14,7 +14,7 @@ on: - "test/**" - "CMakeLists.txt" - "Dockerfile" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -27,7 +27,7 @@ on: - "test/**" - "CMakeLists.txt" - "Dockerfile" - - "conanfile.txt" + - "conanfile.py" # https://stackoverflow.com/a/72408109 concurrency: diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index bbe083c1..757190ed 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -14,7 +14,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -27,7 +27,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" # https://stackoverflow.com/a/72408109 concurrency: @@ -67,7 +67,7 @@ jobs: - name: Generate cache key id: cache-key run: | - hash="${{ hashFiles('conanfile.txt', '.github/workflows/codecov.yml') }}" + hash="${{ hashFiles('conanfile.py', '.github/workflows/codecov.yml') }}" # This can be used by to always update a cache entry (useful e.g. for ccache) current_date="$(date '+%s')" diff --git a/.github/workflows/fuzzy-testing.yml b/.github/workflows/fuzzy-testing.yml index d12d1455..a586ff08 100644 --- a/.github/workflows/fuzzy-testing.yml +++ b/.github/workflows/fuzzy-testing.yml @@ -14,7 +14,7 @@ on: - "test/scripts/link_h5_dataset.py" - "test/scripts/patch_hictkpy.py" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -145,7 +145,7 @@ jobs: id: cache-key working-directory: hictkpy run: | - hash="${{ hashFiles('conanfile.txt') }}" + hash="${{ hashFiles('conanfile.py') }}" echo "key=fuzzy-testing-$hash" >> $GITHUB_OUTPUT diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 68a9dde9..60c8e772 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -13,7 +13,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -25,7 +25,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" # https://stackoverflow.com/a/72408109 concurrency: @@ -114,9 +114,9 @@ jobs: compiler_version="${{ matrix.compiler_version }}" build_type="${{ matrix.build_type }}" - conanfile_hash="${{ hashFiles('conanfile.txt') }}" + conanfile_hash="${{ hashFiles('conanfile.py') }}" workflow_hash="${{ hashFiles('.github/workflows/macos-ci.yml') }}" - combined_hash="${{ hashFiles('conanfile.txt', '.github/workflows/macos-ci.yml') }}" + combined_hash="${{ hashFiles('conanfile.py', '.github/workflows/macos-ci.yml') }}" # This can be used by to always update a cache entry (useful e.g. for ccache) current_date="$(date '+%s')" diff --git a/.github/workflows/run-clang-tidy.yml b/.github/workflows/run-clang-tidy.yml index f3314949..b8861be6 100644 --- a/.github/workflows/run-clang-tidy.yml +++ b/.github/workflows/run-clang-tidy.yml @@ -14,7 +14,7 @@ on: - "test/**" - ".clang-tidy" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -27,7 +27,7 @@ on: - "test/**" - ".clang-tidy" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" # https://stackoverflow.com/a/72408109 concurrency: @@ -64,7 +64,7 @@ jobs: - name: Generate cache key id: cache-key run: | - hash="${{ hashFiles('conanfile.txt', '.github/workflows/run-clang-tidy.yml') }}" + hash="${{ hashFiles('conanfile.py', '.github/workflows/run-clang-tidy.yml') }}" # This can be used by to always update a cache entry (useful e.g. for ccache) current_date="$(date '+%s')" diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml index 5be28435..2cd7886c 100644 --- a/.github/workflows/ubuntu-ci.yml +++ b/.github/workflows/ubuntu-ci.yml @@ -13,7 +13,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -25,7 +25,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" # https://stackoverflow.com/a/72408109 concurrency: @@ -187,9 +187,9 @@ jobs: build_type="${{ matrix.build_type }}" dev_mode="${{ matrix.developer_mode }}" - conanfile_hash="${{ hashFiles('conanfile.txt') }}" + conanfile_hash="${{ hashFiles('conanfile.py') }}" workflow_hash="${{ hashFiles('.github/workflows/ubuntu-ci.yml') }}" - combined_hash="${{ hashFiles('conanfile.txt', '.github/workflows/ubuntu-ci.yml') }}" + combined_hash="${{ hashFiles('conanfile.py', '.github/workflows/ubuntu-ci.yml') }}" # This can be used by to always update a cache entry (useful e.g. for ccache) current_date="$(date '+%s')" diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 3df06b51..594cb1d2 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -13,7 +13,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" tags: - 'v*.*.*' @@ -25,7 +25,7 @@ on: - "src/**" - "test/**" - "CMakeLists.txt" - - "conanfile.txt" + - "conanfile.py" # https://stackoverflow.com/a/72408109 concurrency: @@ -92,9 +92,9 @@ jobs: compiler="${{ matrix.compiler-name }}" build_type="${{ matrix.build_type }}" - conanfile_hash="${{ hashFiles('conanfile.txt') }}" + conanfile_hash="${{ hashFiles('conanfile.py') }}" workflow_hash="${{ hashFiles('.github/workflows/windows-ci.yml') }}" - combined_hash="${{ hashFiles('conanfile.txt', '.github/workflows/windows-ci.yml') }}" + combined_hash="${{ hashFiles('conanfile.py', '.github/workflows/windows-ci.yml') }}" # This can be used by to always update a cache entry (useful e.g. for ccache) current_date="$(date '+%s')" diff --git a/Dockerfile b/Dockerfile index 32baa9e2..10f2fc13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,8 +40,8 @@ RUN conan install /tmp/conanfile.txt \ # Build hictk deps using Conan RUN mkdir -p "$src_dir" -COPY conanfile.txt "$src_dir" -RUN conan install "$src_dir/conanfile.txt" \ +COPY conanfile.py "$src_dir" +RUN conan install "$src_dir/conanfile.py" \ --build=missing \ -pr:b="$CONAN_DEFAULT_PROFILE_PATH" \ -pr:h="$CONAN_DEFAULT_PROFILE_PATH" \ diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..fb3c08b1 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,74 @@ +# Copyright (C) 2023 Roberto Rossini +# +# SPDX-License-Identifier: MIT + +from conan import ConanFile +from conan.tools.build import check_min_cppstd + + +required_conan_version = ">=1.53.0" + + +class NCHGConan(ConanFile): + name = "hictk" + description = "Blazing fast toolkit to work with .hic and .cool files." + license = "MIT" + topics = ("hictk", "bioinformatics") + homepage = "/~https://github.com/paulsengroup/hictk" + url = "/~https://github.com/paulsengroup/hictk" + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False], + } + + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "CMakeDeps" + + @property + def _min_cppstd(self): + return 17 + + def requirements(self): + self.requires("bshoshany-thread-pool/4.1.0#be1802a8768416a6c9b1393cf0ce5e9c") + self.requires("catch2/3.5.4#d346ca291f8f62040fd9c1a891654711") + self.requires("cli11/2.4.1#afacffd31f631bbb8b7c7d6425fe7a66") + self.requires("concurrentqueue/1.0.4#1e48e1c712bcfd892087c9c622a51502") + self.requires("eigen/3.4.0#2e192482a8acff96fe34766adca2b24c") + self.requires("fast_float/6.1.1#e29acaa3d0543dee343abe3f6815346e") + self.requires("fmt/10.2.1#9199a7a0611866dea5c8849a77467b25") + self.requires("hdf5/1.14.3#31ccd8d4de83844f5db48471df1944a1") + self.requires("highfive/2.9.0#c57477beed8b0110fadeb6da8f48bcc5") + self.requires("libdeflate/1.19#3ea74a4549efc14d4b1202dc4bfbf602") + self.requires("parallel-hashmap/1.3.11#1e67f4855a3f7cdeb977cc472113baf7") + self.requires("readerwriterqueue/1.0.6#aaa5ff6fac60c2aee591e9e51b063b83") + self.requires("span-lite/0.11.0#519fd49fff711674cfed8cd17d4ed422") + self.requires("spdlog/1.13.0#8e88198fd5b9ee31d329431a6d0ccaa2") + self.requires("zstd/1.5.6#67383dae85d33f43823e7751a6745ea1") + + def validate(self): + if self.settings.get_safe("compiler.cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def configure(self): + if self.settings.compiler in ["clang", "gcc"]: + self.settings.compiler.libcxx = "libstdc++11" + + self.options["fmt"].header_only = True + self.options["hdf5"].enable_cxx = False + self.options["hdf5"].hl = False + self.options["hdf5"].threadsafe = False + self.options["hdf5"].parallel = False + self.options["hictk"].with_eigen = False + self.options["highfive"].with_boost = False + self.options["highfive"].with_eigen = False + self.options["highfive"].with_opencv = False + self.options["highfive"].with_xtensor = False + self.options["spdlog"].header_only = True + self.options["zstd"].build_programs = False diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index c76a83ae..00000000 --- a/conanfile.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2023 Roberto Rossini -# -# SPDX-License-Identifier: MIT - -[requires] -bshoshany-thread-pool/4.1.0#be1802a8768416a6c9b1393cf0ce5e9c -catch2/3.5.4#d346ca291f8f62040fd9c1a891654711 -cli11/2.4.1#afacffd31f631bbb8b7c7d6425fe7a66 -concurrentqueue/1.0.4#1e48e1c712bcfd892087c9c622a51502 -eigen/3.4.0#2e192482a8acff96fe34766adca2b24c -fast_float/6.1.1#e29acaa3d0543dee343abe3f6815346e -fmt/10.2.1#9199a7a0611866dea5c8849a77467b25 -hdf5/1.14.3#31ccd8d4de83844f5db48471df1944a1 -highfive/2.9.0#c57477beed8b0110fadeb6da8f48bcc5 -libdeflate/1.19#3ea74a4549efc14d4b1202dc4bfbf602 -parallel-hashmap/1.3.11#1e67f4855a3f7cdeb977cc472113baf7 -readerwriterqueue/1.0.6#aaa5ff6fac60c2aee591e9e51b063b83 -span-lite/0.11.0#519fd49fff711674cfed8cd17d4ed422 -spdlog/1.13.0#8e88198fd5b9ee31d329431a6d0ccaa2 -zstd/1.5.6#67383dae85d33f43823e7751a6745ea1 - -[generators] -CMakeDeps - -[options] -fmt*:header_only=True -hdf5*:enable_cxx=False -hdf5*:hl=False -hdf5*:threadsafe=False -hdf5*:parallel=False -highfive*:with_boost=False -highfive*:with_eigen=False -highfive*:with_opencv=False -highfive*:with_xtensor=False -spdlog*:header_only=True -zstd*:build_programs=False diff --git a/setup_conan_environments.sh b/setup_conan_environments.sh index bc951e8a..07e28328 100755 --- a/setup_conan_environments.sh +++ b/setup_conan_environments.sh @@ -12,7 +12,7 @@ trap "cd '$PWD'" EXIT git_root="$(readlink -f "$(git rev-parse --show-toplevel)")" wd="$git_root/conan-envs" -conanfile="$git_root/conanfile.txt" +conanfile="$git_root/conanfile.py" for compiler in gcc clang; do for build_type in Debug Release RelWithDebInfo; do diff --git a/test/packaging/test_find_package/README.md b/test/packaging/test_find_package/README.md index edc3e9eb..018934fc 100644 --- a/test/packaging/test_find_package/README.md +++ b/test/packaging/test_find_package/README.md @@ -4,7 +4,7 @@ Test to ensure hictk can be included in a project through `find_package()`. ```bash # Build and install hictk -conan install conanfile.txt --output-folder build/ +conan install conanfile.py --output-folder build/ cmake -DCMAKE_BUILD_TYPE=Release -S ../../../ -B hictk_build -DHICTK_ENABLE_TESTING=OFF -DHICTK_BUILD_TOOLS=OFF -DCMAKE_PREFIX_PATH="$PWD/build" -DCMAKE_INSTALL_PREFIX=hictk_install cmake --build hictk_build/ cmake --install hictk_build/