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
WORKSPACEfile? I saw that ifpython_versionis 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
BUILDfile isexamplebecausebazelautomatically adds the prefixlib. Could I somehow avoid this and then call the librarylibexampleright 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.