Nanobind migration POC#5084
Conversation
695dc8b to
576cb19
Compare
|
@soswow This is looking good! The only real concern I have at this stage is that rather than the logic for running the nanobind tests living in runtest.py, I would much rather that it all be in testing.cmake. You can see (circa testing.cmake:197) how for each of the texture tests, it actually adds them to the list a second time with different arguments to make the same test run again with in batch texturing mode (and modifying the name to append ".batch" to make it look like a separate test). I think this is how it should work for pybind11 vs nanobind as well. There should be minimal logic changes necessary in runtest.py. |
|
@soswow Ping. I proposed some changes to the testing strategy, but otherwise would like to merge what you have as a great first step to the nanobind transition. |
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
…tomatically when needed. Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
11448cc to
583aea9
Compare
Signed-off-by: Aleksandr Motsjonov <soswow@gmail.com>
|
|
||
| namespace { | ||
|
|
||
| OIIO_NAMESPACE_USING |
There was a problem hiding this comment.
We try not to use this macro any longer. Just do a using namespace OIIO; here and in the other files.
|
|
||
| nb::class_<ParamValueList>(m, "ParamValueList") | ||
| .def(nb::init<>()) | ||
| .def("__getitem__", |
There was a problem hiding this comment.
The __getitem__ calls in the old pybind11 use return_value_policy::reference_internal. Do we have to do something equivalent here in some form?
| return std::string(spec.serialize(fmt, verb)); | ||
| }, | ||
| "format"_a = "text", "verbose"_a = "detailed") | ||
| .def( |
There was a problem hiding this comment.
The old pybind11 has a few other functions right before this and right after serialize. Seems like the following 4 were somehow missed?
.def("to_xml",
[](const ImageSpec& spec) { return PY_STR(spec.to_xml()); })
.def("from_xml", &ImageSpec::from_xml)
.def(
"valid_tile_range",
[](ImageSpec& self, int xbegin, int xend, int ybegin, int yend,
int zbegin, int zend) {
return self.valid_tile_range(xbegin, xend, ybegin, yend, zbegin,
zend);
},
"xbegin"_a, "xend"_a, "ybegin"_a, "yend"_a, "zbegin"_a = 0,
"zend"_a = 1)
.def("copy_dimensions", &ImageSpec::copy_dimensions, "other"_a)
Draft PR where I am exploring migration from pybind11 to nanobind.
New env flag introduced
OIIO_PYTHON_BINDINGS_BACKEND=pybind11ornanobindorbothWhen it is nanobine one is build it is in
PyOpenImageIONanobindExperimentaltarget.Checklist:
behavior.
testsuite.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.