From da7a30cbfc92a73e181046f5d1883b9cf24235ce Mon Sep 17 00:00:00 2001 From: Mayeul d'Avezac <2745737+mdavezac@users.noreply.github.com> Date: Tue, 18 May 2021 09:18:50 +0100 Subject: [PATCH 1/4] add s2let/2.2.3 --- recipes/s2let/all/CMakeLists.txt | 7 +++ recipes/s2let/all/conandata.yml | 4 ++ recipes/s2let/all/conanfile.py | 63 +++++++++++++++++++ recipes/s2let/all/test_package/CMakeLists.txt | 11 ++++ recipes/s2let/all/test_package/conanfile.py | 17 +++++ recipes/s2let/all/test_package/example.c | 9 +++ recipes/s2let/config.yml | 3 + 7 files changed, 114 insertions(+) create mode 100644 recipes/s2let/all/CMakeLists.txt create mode 100644 recipes/s2let/all/conandata.yml create mode 100644 recipes/s2let/all/conanfile.py create mode 100644 recipes/s2let/all/test_package/CMakeLists.txt create mode 100644 recipes/s2let/all/test_package/conanfile.py create mode 100644 recipes/s2let/all/test_package/example.c create mode 100644 recipes/s2let/config.yml diff --git a/recipes/s2let/all/CMakeLists.txt b/recipes/s2let/all/CMakeLists.txt new file mode 100644 index 0000000000000..0496b29838549 --- /dev/null +++ b/recipes/s2let/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/s2let/all/conandata.yml b/recipes/s2let/all/conandata.yml new file mode 100644 index 0000000000000..fff2fe27be76b --- /dev/null +++ b/recipes/s2let/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.2.3": + url: "https://github.com/astro-informatics/s2let/archive/refs/tags/v2.2.3rc1.zip" + sha256: "fef6c3ac8c9c8413f3e8ee02f0744ebae5fb01287cb53c31e32cb79f27c90c68" diff --git a/recipes/s2let/all/conanfile.py b/recipes/s2let/all/conanfile.py new file mode 100644 index 0000000000000..17cef9274b8a2 --- /dev/null +++ b/recipes/s2let/all/conanfile.py @@ -0,0 +1,63 @@ +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration +from glob import glob +import os + + +class S2let(ConanFile): + name = "s2let" + license = "GPL-3.0-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/astro-informatics/s2let" + description = "Fast wavelets on the sphere" + settings = "os", "arch", "compiler", "build_type" + topics = ("physics", "astrophysics", "radio interferometry") + options = {"fPIC": [True, False]} + default_options = {"fPIC": True} + requires = "astro-informatics-so3/[>=1.3.4]", "cfitsio/[>=3.490]" + generators = "cmake", "cmake_find_package" + exports_sources = ["CMakeLists.txt"] + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def configure(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def config_options(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration( + "SO3 requires C99 support for complex numbers." + ) + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = glob("s2let-*/")[0] + os.rename(extracted_dir, self._source_subfolder) + + @property + def cmake(self): + if not hasattr(self, "_cmake"): + self._cmake = CMake(self) + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.definitions["cfitsio"] = True + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + self.cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + self.cmake.install() + + def package_info(self): + self.cpp_info.libs = ["s2let"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m"] diff --git a/recipes/s2let/all/test_package/CMakeLists.txt b/recipes/s2let/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1fe8c42364647 --- /dev/null +++ b/recipes/s2let/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(s2let REQUIRED NO_MODULE) + +add_executable(${PROJECT_NAME} example.c) +target_compile_features(${PROJECT_NAME} PUBLIC c_std_99) +target_link_libraries(${PROJECT_NAME} s2let::s2let) diff --git a/recipes/s2let/all/test_package/conanfile.py b/recipes/s2let/all/test_package/conanfile.py new file mode 100644 index 0000000000000..abcaeed3f89b6 --- /dev/null +++ b/recipes/s2let/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/s2let/all/test_package/example.c b/recipes/s2let/all/test_package/example.c new file mode 100644 index 0000000000000..727c8b1d866f7 --- /dev/null +++ b/recipes/s2let/all/test_package/example.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, char *argv[]) +{ + complex double *buffer; + s2let_allocate_lm(&buffer, 5); + free(buffer); + return 0; +} diff --git a/recipes/s2let/config.yml b/recipes/s2let/config.yml new file mode 100644 index 0000000000000..a0d8538280848 --- /dev/null +++ b/recipes/s2let/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.3": + folder: all From 3b64870df2ec15cfe673eb9b0e1c55a6eca41416 Mon Sep 17 00:00:00 2001 From: Mayeul d'Avezac <2745737+mdavezac@users.noreply.github.com> Date: Tue, 8 Jun 2021 21:58:08 +0100 Subject: [PATCH 2/4] Apply changes from code review comments --- recipes/s2let/all/conandata.yml | 4 ++-- recipes/s2let/all/conanfile.py | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/recipes/s2let/all/conandata.yml b/recipes/s2let/all/conandata.yml index fff2fe27be76b..a774612611002 100644 --- a/recipes/s2let/all/conandata.yml +++ b/recipes/s2let/all/conandata.yml @@ -1,4 +1,4 @@ sources: "2.2.3": - url: "https://github.com/astro-informatics/s2let/archive/refs/tags/v2.2.3rc1.zip" - sha256: "fef6c3ac8c9c8413f3e8ee02f0744ebae5fb01287cb53c31e32cb79f27c90c68" + url: "https://github.com/astro-informatics/s2let/archive/refs/tags/v2.2.3rc1.tar.gz" + sha256: "73869e17b5c53536ef74fbc194e4259a9a5cc77244d6988f0197bca9465e5372" diff --git a/recipes/s2let/all/conanfile.py b/recipes/s2let/all/conanfile.py index 17cef9274b8a2..6bddb231d3eac 100644 --- a/recipes/s2let/all/conanfile.py +++ b/recipes/s2let/all/conanfile.py @@ -1,7 +1,5 @@ from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration -from glob import glob -import os class S2let(ConanFile): @@ -14,7 +12,7 @@ class S2let(ConanFile): topics = ("physics", "astrophysics", "radio interferometry") options = {"fPIC": [True, False]} default_options = {"fPIC": True} - requires = "astro-informatics-so3/[>=1.3.4]", "cfitsio/[>=3.490]" + requires = "astro-informatics-so3/1.3.4", "cfitsio/3.490" generators = "cmake", "cmake_find_package" exports_sources = ["CMakeLists.txt"] @@ -33,29 +31,31 @@ def configure(self): def config_options(self): if self.settings.compiler == "Visual Studio": raise ConanInvalidConfiguration( - "SO3 requires C99 support for complex numbers." + "S2LET requires C99 support for complex numbers." ) def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob("s2let-*/")[0] - os.rename(extracted_dir, self._source_subfolder) + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder + ) @property - def cmake(self): - if not hasattr(self, "_cmake"): - self._cmake = CMake(self) - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["cfitsio"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def _cmake(self): + if not hasattr(self, "_cmake_instance"): + self._cmake_instance = CMake(self) + self._cmake_instance.definitions["BUILD_TESTING"] = False + self._cmake_instance.definitions["cfitsio"] = True + self._cmake_instance.configure(build_folder=self._build_subfolder) + return self._cmake_instance def build(self): - self.cmake.build() + self._cmake.build() def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.cmake.install() + self._cmake.install() def package_info(self): self.cpp_info.libs = ["s2let"] From 144742f385ee96e4b951be2e1bee948b8f1c4055 Mon Sep 17 00:00:00 2001 From: Mayeul d'Avezac <2745737+mdavezac@users.noreply.github.com> Date: Wed, 9 Jun 2021 21:25:57 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/s2let/all/conanfile.py | 28 +++++++++++++++---- recipes/s2let/all/test_package/CMakeLists.txt | 4 +-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/recipes/s2let/all/conanfile.py b/recipes/s2let/all/conanfile.py index 6bddb231d3eac..1fc2aa8dc0cd5 100644 --- a/recipes/s2let/all/conanfile.py +++ b/recipes/s2let/all/conanfile.py @@ -1,6 +1,8 @@ from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration +required_conan_version = ">=1.33.0" + class S2let(ConanFile): name = "s2let" @@ -10,9 +12,14 @@ class S2let(ConanFile): description = "Fast wavelets on the sphere" settings = "os", "arch", "compiler", "build_type" topics = ("physics", "astrophysics", "radio interferometry") - options = {"fPIC": [True, False]} - default_options = {"fPIC": True} - requires = "astro-informatics-so3/1.3.4", "cfitsio/3.490" + options = { + "fPIC": [True, False], + "with_cfitsio": [True, False], + } + default_options = { + "fPIC": True, + "with_cfitsio": False, + } generators = "cmake", "cmake_find_package" exports_sources = ["CMakeLists.txt"] @@ -24,11 +31,20 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + def configure(self): del self.settings.compiler.cppstd del self.settings.compiler.libcxx - def config_options(self): + def requirements(self): + self.requires("astro-informatics-so3/1.3.4") + if self.options.with_cfitsio: + self.requires("cfitsio/3.490") + + def validate(self): if self.settings.compiler == "Visual Studio": raise ConanInvalidConfiguration( "S2LET requires C99 support for complex numbers." @@ -46,7 +62,7 @@ def _cmake(self): if not hasattr(self, "_cmake_instance"): self._cmake_instance = CMake(self) self._cmake_instance.definitions["BUILD_TESTING"] = False - self._cmake_instance.definitions["cfitsio"] = True + self._cmake_instance.definitions["cfitsio"] = self.options.with_cfitsio self._cmake_instance.configure(build_folder=self._build_subfolder) return self._cmake_instance @@ -58,6 +74,8 @@ def package(self): self._cmake.install() def package_info(self): + self.cpp_info.names["cmake_find_package"] = "s2let" + self.cpp_info.names["cmake_find_package_multi"] = "s2let" self.cpp_info.libs = ["s2let"] if self.settings.os == "Linux": self.cpp_info.system_libs = ["m"] diff --git a/recipes/s2let/all/test_package/CMakeLists.txt b/recipes/s2let/all/test_package/CMakeLists.txt index 1fe8c42364647..87839a22ea4e7 100644 --- a/recipes/s2let/all/test_package/CMakeLists.txt +++ b/recipes/s2let/all/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(s2let REQUIRED NO_MODULE) From d56263b803ab2f0f60fe3adb36b81cc55ceb7388 Mon Sep 17 00:00:00 2001 From: Mayeul d'Avezac <2745737+mdavezac@users.noreply.github.com> Date: Fri, 11 Jun 2021 17:30:49 +0100 Subject: [PATCH 4/4] Update URL and SHA for upstream release --- recipes/s2let/all/conandata.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/s2let/all/conandata.yml b/recipes/s2let/all/conandata.yml index a774612611002..93e1e80ecc199 100644 --- a/recipes/s2let/all/conandata.yml +++ b/recipes/s2let/all/conandata.yml @@ -1,4 +1,4 @@ sources: "2.2.3": - url: "https://github.com/astro-informatics/s2let/archive/refs/tags/v2.2.3rc1.tar.gz" - sha256: "73869e17b5c53536ef74fbc194e4259a9a5cc77244d6988f0197bca9465e5372" + url: "https://github.com/astro-informatics/s2let/archive/refs/tags/v2.2.3.tar.gz" + sha256: "1321e1bc96ba200e4cd4056843cd4075de1c05be20e64185f065f48b9cefe3f8"