Repository: conan-io/conan-center-index

Issue:
[request] frugally-deep/v0.15.1-p0
### Package Details
  * Package Name/Version: **frugally-deep/v0.15.1-p0**
  * Website: none
  * Source code: **https://github.com/Dobiasd/frugally-deep/**


### Description Of The Library / Tool
Use Keras models in C++ with ease

---

Pull request: https://github.com/conan-io/conan-center-index/pull/3993


Discussion:

Resolving patch:
diff --git a/recipes/frugally-deep/all/conanfile.py b/recipes/frugally-deep/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/frugally-deep/all/conanfile.py
@@ -0,0 +1,73 @@
+import os
+
+from conans import ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
+
+required_conan_version = ">=1.32.0"
+
+
+class FrugallyDeepConan(ConanFile):
+    name = "frugally-deep"
+    description = "Use Keras models in C++ with ease."
+    license = "MIT"
+    topics = ("keras", "tensorflow")
+    homepage = "https://github.com/Dobiasd/frugally-deep"
+    url = "https://github.com/conan-io/conan-center-index"
+    settings = "os", "compiler", "build_type", "arch"
+    no_copy_source = True
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _compilers_minimum_version(self):
+        return {
+            "gcc": "4.9",
+            "Visual Studio": "14",
+            "clang": "3.7",
+            "apple-clang": "9",
+        }
+
+    def validate(self):
+        if self.settings.compiler.cppstd:
+            tools.check_min_cppstd(self, 14)
+
+        def lazy_lt_semver(v1, v2):
+            lv1 = [int(v) for v in v1.split(".")]
+            lv2 = [int(v) for v in v2.split(".")]
+            min_length = min(len(lv1), len(lv2))
+            return lv1[:min_length] < lv2[:min_length]
+
+        minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
+        if not minimum_version:
+            self.output.warn("frugally-deep requires C++14. Your compiler is unknown. Assuming it supports C++14.")
+        elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version):
+            raise ConanInvalidConfiguration("frugally-deep requires C++14, which your compiler does not support.")
+
+    def requirements(self):
+        self.requires("eigen/3.3.9")
+        self.requires("functionalplus/0.2.13-p0")
+        self.requires("nlohmann_json/3.9.1")
+
+    def package_id(self):
+        self.info.header_only()
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        os.rename("frugally-deep-" + self.version, self._source_subfolder)
+
+    def package(self):
+        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
+        self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include"))
+
+    def package_info(self):
+        self.cpp_info.names["cmake_find_package"] = "frugally-deep"
+        self.cpp_info.names["cmake_find_package_multi"] = "frugally-deep"
+        self.cpp_info.components["fdeep"].names["cmake_find_package"] = "fdeep"
+        self.cpp_info.components["fdeep"].names["cmake_find_package_multi"] = "fdeep"
+        self.cpp_info.components["fdeep"].requires = ["eigen::eigen",
+                                                      "functionalplus::functionalplus",
+                                                      "nlohmann_json::nlohmann_json"]
+        if self.settings.os in ["Linux", "FreeBSD"]:
+            self.cpp_info.components["fdeep"].system_libs = ["pthread"]


Test patch:
diff --git a/recipes/frugally-deep/all/test_package/CMakeLists.txt b/recipes/frugally-deep/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/frugally-deep/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(frugally-deep REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} frugally-deep::fdeep)
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
diff --git a/recipes/frugally-deep/all/test_package/conanfile.py b/recipes/frugally-deep/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/frugally-deep/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "arch", "compiler", "build_type"
+    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/frugally-deep/all/test_package/test_package.cpp b/recipes/frugally-deep/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/frugally-deep/all/test_package/test_package.cpp
@@ -0,0 +1,10 @@
+#include <fdeep/fdeep.hpp>
+#include <iostream>
+
+int main()
+{
+    const fdeep::tensor t(
+        fdeep::tensor_shape(static_cast<std::size_t>(4)),
+        fdeep::float_vec{1, 2, 3, 4});
+    std::cout << fdeep::show_tensor(t) << std::endl;
+}