nanobind_example icon indicating copy to clipboard operation
nanobind_example copied to clipboard

Break up Bazel example into a separate repo to actually show GitHub Actions working

Open joaospinto opened this issue 6 months ago • 7 comments
trafficstars

I think the Bazel example should be its own repository, not just a branch. The reason for this is that the GitHub Actions integration (https://github.com/wjakob/nanobind_example/blob/bazel/.github/workflows/pip.yml) on this branch doesn't actually run or do anything. I've been trying to get that setup working on my own project (http://github.com/joaospinto/sip_python), and it's taking several hours (due to very real issues, like https://github.com/pypa/cibuildwheel/issues/896).

joaospinto avatar Apr 30 '25 06:04 joaospinto

Hey, I saw you tagged me in that cibuildwheel issue. In the end, things improved when a) I upgraded to newer Bazel, which has more available architectures including Linux aarch64 and Windows ARM, so I could just download one of these executables directly from GitHub, and b) when GitHub added support for native runners of these platforms.

An example of a download script for current manylinux containers is here: https://github.com/google/benchmark/blob/main/.github/install_bazel.sh

And here is a PR for building Linux aarch64 natively (results in a 3x speedup over virtualization): https://github.com/google/benchmark/pull/1969

nicholasjng avatar Apr 30 '25 07:04 nicholasjng

Also, I do test the nanobind_example in CI, just not in this repo - see https://github.com/nicholasjng/nanobind-bazel/blob/master/.github/workflows/lint-and-test.yaml.

nicholasjng avatar Apr 30 '25 07:04 nicholasjng

Thanks for the pointers, @nicholasjng ! Very helpful.

joaospinto avatar Apr 30 '25 15:04 joaospinto

I got it to mostly work on https://github.com/joaospinto/sip_python. Got one strange error on Windows + Python 3.13 (https://github.com/pypa/cibuildwheel/issues/2378).

joaospinto avatar May 02 '25 06:05 joaospinto

I got it to mostly work on https://github.com/joaospinto/sip_python. Got one strange error on Windows + Python 3.13 (pypa/cibuildwheel#2378).

The issue might stem from bazel linking against python312.lib when generating the stable ABI extension module.

I inspected the sip_python_ext.pyd packaged in sip_python-0.0.1-cp312-abi3-win_amd64.whl using Dependencies and found that it depends on python312.dll for execution.

In contrast, if we use CMake to build the extension module, it links against python3.lib, allowing the module to run successfully with Python 3.13.
For reference:
https://github.com/wjakob/nanobind/blob/d4b245ad69f729c3d2095be4c1cb5b94810dae26/cmake/nanobind-config.cmake#L227-L233

Doekin avatar May 08 '25 07:05 Doekin

Huh, that's not good. Could I ask you to produce the list of libraries it depends on, preferably in an issue on nanobind-bazel?

nicholasjng avatar May 08 '25 08:05 nicholasjng

Huh, that's not good. Could I ask you to produce the list of libraries it depends on, preferably in an issue on nanobind-bazel?

OK

Doekin avatar May 08 '25 08:05 Doekin

I am closing this issue here, since it is not actionable for me.

wjakob avatar Oct 17 '25 09:10 wjakob