Skip to content

Commit 3537332

Browse files
authored
docs: Add doc on new nanobind_static_library macro, cp314 SABI option (#1022)
In particular, notes the experimental nature of the underlying `cc_static_library` rule. The `"cp314"` value for the stable ABI flag was added to the list of legal input values. Also removes linebreaks in some links to the Bazel docs, which were broken at least in VSCode.
1 parent 87be1a2 commit 3537332

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

docs/api_bazel.rst

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ rule.
6464
exclude_docstrings = False,
6565
recursive = False):
6666
67-
It generates a `py_binary <https://bazel.build/reference/be/
68-
python#py_binary>`__ rule with a corresponding runfiles distribution,
69-
which invokes nanobind's builtin stubgen script, outputs a stub file and,
70-
optionally, a typing marker file into ``output_directory`` (defaults to
67+
It generates a `py_binary <https://bazel.build/reference/be/python#py_binary>`__
68+
rule with a corresponding runfiles distribution, which invokes nanobind's
69+
builtin stubgen script, outputs a stub file and, optionally,
70+
a typing marker file into ``output_directory`` (defaults to
7171
the build output directory, commonly called "bindir" in Bazel terms).
7272

7373
All arguments (except the name, which is used only to refer to the target
@@ -115,12 +115,35 @@ To build a C++ shared library with nanobind as a dependency, use the
115115
**kwargs):
116116
117117
It corresponds directly to the builtin
118-
`cc_shared_library <https://bazel.build/reference/be/
119-
c-cpp#cc_shared_library>`__ rule, with all keyword arguments being directly
120-
forwarded to a ``cc_shared_library`` target.
118+
`cc_shared_library <https://bazel.build/reference/be/c-cpp#cc_shared_library>`__
119+
rule, with all keyword arguments being directly forwarded to a
120+
``cc_shared_library`` target.
121121

122122
*New in nanobind-bazel version 2.1.0.*
123123

124+
To build a C++ static library containing nanobind, use the
125+
``nanobind_static_library`` rule.
126+
127+
.. py:function:: nanobind_static_library
128+
129+
Declares a Bazel target representing a static library (or archive) containing
130+
nanobind.
131+
132+
.. code-block:: python
133+
134+
def nanobind_static_library(name, deps, **kwargs):
135+
136+
It corresponds directly to the builtin
137+
`cc_static_library <https://bazel.build/reference/be/c-cpp#cc_static_library>`__
138+
rule, with all keyword arguments being directly
139+
forwarded to a ``cc_static_library`` target.
140+
141+
NB: This macro requires Bazel 7.4.0 or greater to use, as well as setting the
142+
``--experimental_cc_static_library`` flag for the build, since the
143+
``cc_static_library`` rule is considered experimental.
144+
145+
*New in nanobind-bazel version 2.7.0.*
146+
124147
To build a C++ test target requiring nanobind, use the ``nanobind_test`` rule.
125148

126149
.. py:function:: nanobind_test
@@ -157,6 +180,6 @@ following flag settings.
157180
.. py:function:: @nanobind_bazel//:py-limited-api (string)
158181
159182
Build nanobind extensions against the stable ABI of the configured Python
160-
version. Allowed values are ``"cp312"``, ``"cp313"``, which target the
161-
stable ABI starting from Python 3.12 or 3.13, respectively. By default, all
162-
extensions are built without any ABI limitations.
183+
version. Allowed values are ``"cp312"``, ``"cp313"``, and ``"cp314"``, which
184+
target the stable ABI starting from CPython 3.12, 3.13, or 3.14 respectively.
185+
By default, all extensions are built without any ABI limitations.

docs/bazel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ in your MODULE.bazel file:
2727
# Place this in your MODULE.bazel file.
2828
# The major version of nanobind-bazel is equal to the version
2929
# of the internally used nanobind.
30-
# In this case, we are building bindings with nanobind v2.5.0.
31-
bazel_dep(name = "nanobind_bazel", version = "2.5.0")
30+
# In this case, we are building bindings with nanobind v2.7.0.
31+
bazel_dep(name = "nanobind_bazel", version = "2.7.0")
3232
3333
To instead use a development version from GitHub, you can declare the
3434
dependency as a ``git_override()`` in your MODULE.bazel:

0 commit comments

Comments
 (0)