-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(cmake_wrapper) | ||
|
||
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
2.4.3: | ||
url: https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz | ||
sha256: 1eed57bc6863190e35637290f97a20c81cfe4d9090ac0a24f3bbf08f265eb71d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"2.4.3": | ||
folder: all |