Skip to content

Commit

Permalink
pybind11 1.8.1 (new formula)
Browse files Browse the repository at this point in the history
Closes #4059.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
  • Loading branch information
ivan-krukov authored and MikeMcQuaid committed Aug 21, 2016
1 parent ff4a43f commit b17405c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Formula/pybind11.rb
@@ -0,0 +1,39 @@
class Pybind11 < Formula
desc "Seamless operability between C++11 and Python"
homepage "https://github.com/pybind/pybind11"
url "https://github.com/pybind/pybind11/archive/v1.8.1.tar.gz"
sha256 "321de8881ff0e113087b9e996d77777417b7db05bc4536b365f648b5fadc27b8"

depends_on "python3"
depends_on "cmake" => :build

def install
system "cmake", ".", *std_cmake_args
system "make", "install"
end

test do
(testpath/"example.cpp").write <<-EOS.undent
#include <pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
namespace py = pybind11;
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("add", &add, "A function which adds two numbers");
return m.ptr();
}
EOS

(testpath/"example.py").write <<-EOS.undent
import example
example.add(1,2)
EOS

python_flags = `python3-config --cflags --ldflags`.split(" ")
system ENV.cxx, "-O3", "-shared", "-std=c++11", *python_flags, "example.cpp", "-o", "example.so"
system "python3", "example.py"
end
end

0 comments on commit b17405c

Please sign in to comment.