Repository: conan-io/conan-center-index

Issue:
[request] pybind/2.4.3
### Package Details
  * Package Name/Version: **pybind/2.4.3**
  * Changelog: **Not available**


The above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version.

**Note**: The last version of pybind in conan-center is 2.3.0. After that version, four other versions were released upstream: 2.4.0, 2.4.1, 2.4.2 and finally 2.4.3.



Discussion:
Hi @darcamo !

Thanks for your request, are you interested in helping us with this package? Pybind recipe is already available in Conan Community, so basically you need to copy from there a follow the Wiki rules.

https://github.com/conan-community/conan-pybind11

Resolving patch:
diff --git a/recipes/pybind11/all/conanfile.py b/recipes/pybind11/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/pybind11/all/conanfile.py
@@ -0,0 +1,51 @@
+from conans import ConanFile, tools, CMake
+import os
+
+
+class PyBind11Conan(ConanFile):
+    name = "pybind11"
+    description = "Seamless operability between C++11 and Python"
+    topics = "conan", "pybind11", "python", "binding"
+    homepage = "https://github.com/pybind/pybind11"
+    license = "BSD-3-Clause"
+    url = "https://github.com/conan-io/conan-center-index"
+    exports_sources = "CMakeLists.txt"
+    settings = "os", "arch", "compiler", "build_type"
+    generators = "cmake"
+    no_copy_source = True
+
+    _source_subfolder = "source_subfolder"
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        os.rename("{}-{}".format(self.name, self.version), self._source_subfolder)
+
+    def _configure_cmake(self):
+        cmake = CMake(self)
+        cmake.definitions["PYBIND11_INSTALL"] = True
+        cmake.definitions["PYBIND11_TEST"] = False
+        cmake.definitions["PYBIND11_CMAKECONFIG_INSTALL_DIR"] = "lib/cmake/pybind11"
+        cmake.configure()
+        return cmake
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
+        cmake = self._configure_cmake()
+        cmake.install()
+        os.unlink(os.path.join(self.package_folder, "lib", "cmake", "pybind11", "pybind11Config.cmake"))
+        os.unlink(os.path.join(self.package_folder, "lib", "cmake", "pybind11", "pybind11ConfigVersion.cmake"))
+
+    def package_id(self):
+        self.info.header_only()
+
+    def package_info(self):
+        self.cpp_info.includedirs.append(os.path.join(self.package_folder, "include", "pybind11"))
+
+        cmake_base_path = os.path.join("lib", "cmake", "pybind11")
+        self.cpp_info.builddirs = [cmake_base_path]
+        self.cpp_info.build_modules = [os.path.join(cmake_base_path, "FindPythonLibsNew.cmake"),
+                                       os.path.join(cmake_base_path, "pybind11Tools.cmake")]


Test patch:
diff --git a/recipes/pybind11/all/test_package/CMakeLists.txt b/recipes/pybind11/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/pybind11/all/test_package/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(test_package CXX)
+
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+
+find_package(PythonInterp REQUIRED)
+find_package(PythonLibs REQUIRED)
+
+find_package(pybind11 REQUIRED)
+include(pybind11Tools)
+
+include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
+conan_basic_setup()
+
+pybind11_add_module(test_package MODULE
+    test_package.cpp
+)
diff --git a/recipes/pybind11/all/test_package/conanfile.py b/recipes/pybind11/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/pybind11/all/test_package/conanfile.py
@@ -0,0 +1,18 @@
+from conans import ConanFile, CMake
+import os
+import sys
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        self.run("{} {} {}".format(sys.executable,
+                                   os.path.join(self.source_folder, "test.py"),
+                                   os.path.join(self.build_folder, "lib")), run_environment=True)
diff --git a/recipes/pybind11/all/test_package/test.py b/recipes/pybind11/all/test_package/test.py
new file mode 100644
--- /dev/null
+++ b/recipes/pybind11/all/test_package/test.py
@@ -0,0 +1,9 @@
+import sys
+
+sys.path.extend(sys.argv[1:])
+
+import test_package
+
+print("Adding 2 + 3 = {}".format(test_package.add(2, 3)))
+
+print("Message: '{}'".format(test_package.msg()))
diff --git a/recipes/pybind11/all/test_package/test_package.cpp b/recipes/pybind11/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/pybind11/all/test_package/test_package.cpp
@@ -0,0 +1,16 @@
+#include <pybind11/pybind11.h>
+
+static int add(int i, int j) {
+    return i + j;
+}
+
+static const char *hello() {
+    return "Hello from the C++ world!";
+}
+
+PYBIND11_MODULE(test_package, m) {
+    m.doc() = "pybind11 example plugin"; // optional module docstring
+
+    m.def("add", &add, "A function which adds two numbers");
+    m.def("msg", &hello, "A function returning a message");
+}