pybind11_bazel icon indicating copy to clipboard operation
pybind11_bazel copied to clipboard

Enhancement: Add small example

Open sgasse opened this issue 4 years ago • 3 comments

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.

sgasse avatar Aug 09 '20 19:08 sgasse

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 if python_version is set to 3, it will automatically find the executable with which python3, but being new to bazel, I did not figure out yet how to set it there.
  • Right now, the name of the library in the BUILD file is example because bazel automatically adds the prefix lib. Could I somehow avoid this and then call the library libexample right away without ending up with liblibexample?

sgasse avatar Aug 09 '20 19:08 sgasse

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,

blais avatar Aug 10 '20 02:08 blais

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.

sschnug avatar Nov 14 '22 20:11 sschnug

https://github.com/pybind/pybind11_bazel/tree/master/examples/basic now exists.

junyer avatar Jun 25 '24 14:06 junyer