Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nanobind-bazel docs with latest developments #842

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

nicholasjng
Copy link
Contributor

nanobind_bazel v2.4.0 was released on the BCR on christmas. The MODULE.bazel code example is thus updated, as is tradition, along with two more user-facing changes:

  1. The minimum Bazel version was increased to Bazel 7, since we need to use a sufficiently new rules_python for free-threading support.
  2. The @nanobind_bazel//:free_threading flag was removed, since it was not that useful - you still needed to give rules_python's free-threading flag separately to request a free-threaded toolchain, and supplying it did not even guarantee a free-threading build. Now, we just use rules_python's free-threading flag value directly instead.

`nanobind_bazel` v2.4.0 was released on the BCR. The MODULE.bazel code example
was thus updated, as is tradition, along with two more user-facing changes:

1. The minimum Bazel version was increased to Bazel 7, since we need to use a
sufficiently new `rules_python` for free-threading support.
2. The `@nanobind_bazel//:free_threading` flag was removed, since it was not
that useful - you still needed to give `rules_python`'s free-threading flag
separately to request a free-threaded toolchain, and supplying it did not
even guarantee a free-threading build. Now, we just use `rules_python`'s
free-threading flag value directly instead.
@wjakob
Copy link
Owner

wjakob commented Jan 6, 2025

Actually, onecomment: it may be useful to keep the free-threading attribute to as an opt-in (similarly to how this is implemented in the CMake build system). Upgrading a package to correctly work in a free-threaded environment can be quite complex. One checkpoint along the way is just to run it as-is (not opted in), in which case the free-threaded features of the interpreter are turned off. Not very useful if your goal is parallelism, but helpful for bring-up of large multi-extension projects.

@nicholasjng
Copy link
Contributor Author

I agree - in fact, rules_python's free-threading flag means that a free-threaded toolchain will be used instead of a "classic" one whenever possible (i.e. CPython 3.13+), so passing @rules_python//config_settings:is_free_threaded=no (name slightly different) just means regular CPython 3.13 will be used, and -DNB_FREE_THREADED will not be given.

Also, no free-threading is the default, so we can build regular CPython 3.13 just fine (in fact, that's what I'm still doing in nanobind_bazel CI).

Does that match your expectation?

@wjakob
Copy link
Owner

wjakob commented Jan 6, 2025

That makes sense! Is this documented somewhere? Otherwise, it may not be easy to infer for users.

@nicholasjng
Copy link
Contributor Author

Afraid not. I can add a paragraph on free-threaded builds to the Bazel doc, either in this PR or a follow-up.

@wjakob
Copy link
Owner

wjakob commented Jan 6, 2025

Let's put it here, we can keep this PR open a little longer.

Presents the necessary toolchain setup in a code block, and mentions the
flag name that must be set for a free-threaded libnanobind build.
@nicholasjng
Copy link
Contributor Author

nicholasjng commented Jan 6, 2025

Done.

On a side note, the docs venv setup is broken at least on my MacOS machine: When pip-installing docs/requirements.txt with Python<3.13, I get an error from sphinx about missing pkg_resources:

$ sphinx-build docs docbuild -a
Running Sphinx v6.1.3

Extension error:
Could not import extension sphinxcontrib.moderncmakedomain (exception: No module named 'pkg_resources')

That one can be fixed by running pip install --upgrade setuptools. On Python 3.13, it's another module that errors out:

$ sphinx-build docs docbuild -a
Running Sphinx v6.1.3

Extension error:
Could not import extension sphinx.builders.epub3 (exception: No module named 'imghdr')

Just wanted to put this out there, since there are other people working on the documentation as well.

EDIT: The second one is about imghdr, deprecated in Python 3.11 and subsequently removed in Python 3.13. The removal in Sphinx came in version 6.2.0, which is just a bit newer than the pin in the requirements file, source: sphinx-doc/sphinx#10440

@wjakob
Copy link
Owner

wjakob commented Jan 7, 2025

Thank you! I'll make a note to transition to a newer version of Sphinx in the future.

@wjakob wjakob merged commit 3239284 into wjakob:master Jan 7, 2025
31 checks passed
@nicholasjng nicholasjng deleted the update-nanobind-bazel-docs branch January 8, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants