pybind11_bazel
pybind11_bazel copied to clipboard
Enhancement: Add small example
Today I was playing around with pybind11 and different build systems. Being new to bazel
, it took me a while to get started. Would it make sense to add a small self-contained example, e.g. on how to build a library? This could of course be extended with more examples along the way.
I'd also have two questions to enhance the example
- Can I somehow set the python version to 3 in the
WORKSPACE
file? I saw that ifpython_version
is set to3
, it will automatically find the executable withwhich python3
, but being new tobazel
, I did not figure out yet how to set it there. - Right now, the name of the library in the
BUILD
file isexample
becausebazel
automatically adds the prefixlib
. Could I somehow avoid this and then call the librarylibexample
right away without ending up withliblibexample
?
sgasse@: I have a small example at https://github.com/blais/oblique/blob/master/oblique/extmodule.cc and you can find my Bazel setup for a number of C++ and Python targets under https://github.com/blais/oblique/tree/master/third_party. I hope this saves you some time,
I had some success with https://github.com/Mizux/bazel-pybind11 (one of the or-tools maintainers)
While there are some custom patches and what not, i did use vanilla versions and just learned from his work.
https://github.com/pybind/pybind11_bazel/tree/master/examples/basic now exists.