Skip to content

Commit 7eeb3bf

Browse files
committed
fixes
1 parent 2019b54 commit 7eeb3bf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ description = "An example minimal project that compiles bindings using nanobind
99
readme = "README.md"
1010
requires-python = ">=3.12"
1111
authors = [
12-
{ name = "M. Amin Safavi",
13-
email = "safavi.m.amin@gmail.com" }
12+
{ name = "M. Amin Safavi", email = "safavi.m.amin@gmail.com" }
1413
]
1514
classifiers = [
1615
"License :: OSI Approved :: MIT License"

src/custom_system.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#include <pybind11/pybind11.h>
1+
#include <nanobind/nanobind.h>
22
#include <drake/systems/framework/leaf_system.h>
33

4-
namespace py = pybind11;
4+
namespace nb = nanobind;
5+
using namespace nb::literals;
56

67
using drake::systems::BasicVector;
78
using drake::systems::Context;
@@ -30,14 +31,14 @@ class SimpleAdder : public LeafSystem<T> {
3031
const T add_{};
3132
};
3233

33-
PYBIND11_MODULE(custom_system, m) {
34+
NB_MODULE(custom_system, m) {
3435
m.doc() = "Example module interfacing with pydrake and Drake C++";
3536

36-
py::module::import("pydrake.systems.framework");
37+
nb::module_::import_("pydrake.systems.framework");
3738

3839
using T = double;
3940

40-
py::class_<SimpleAdder<T>, LeafSystem<T>>(m, "SimpleAdder")
41-
.def(py::init<T>(), py::arg("add"));
41+
nb::class_<SimpleAdder<T>, LeafSystem<T>>(m, "SimpleAdder")
42+
.def(nb::init<T>(), nb::arg("add"));
4243
}
4344
} // namespace drake_extension

0 commit comments

Comments
 (0)