Skip to content

Conversation

@antond-weta
Copy link
Contributor

This adds all necessary code to start working on python bindings.

  • configures nanobind
  • adds a target rawtoaces_bindings
  • adds some minimal bindings for testing purposes

Note, I've only added minimal bindings necessary to convert an image. The stuff I've implemented:

  • ImageConverter.process_image() - an example of bindings for a class and a method. It is working, and is enough to get an image converted with the default settings
  • ImageConverter.settings.WB_method - an example of bindings of a nested class and an enum.

I have made sure that the code builds on all platforms on CI, but I have only tested the python code on my machine (Mac).
Here is how I tested:

  • go to the folder where the built bindings library is located, of add the path to PYTHON_PATH and/or DYLD_LIBRARY_PATH, this may be platform-dependent,
  • execute this python code:
% python
>>> import rawtoaces
>>> converter = rawtoaces.ImageConverter()
>>> converter.process_image("/path/to/a/raw/file")

Next steps from here:

  1. Set up python-based unit tests for future bindings. Ideally all bindings should have 100% test coverage.
  2. Implement bindings for all properties and file-based methods from rta::util::ImageConverter, which do not use any OpenImageIO types as parameters or return values. The bindings in OIIO are currently implemented with pybind, but there is a plan to rewrite them with nanobind.
  3. Implement bindings for rta::core::SpectralSolver and rta::core::MetadataSolver.
  4. If the work to convert OIIO to nanobind hasn't been done yet, implement bindings for the OIIO::ImageBuf-based API by converting the ImageBufs to/from numpy arrays.
  5. After OIIO has been converted to nanobind, finish up implementing the OIIO::ImageBuf-based API by exposing the OIIO types on the python side.

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.27%. Comparing base (184bbc4) to head (c3b8e05).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #205   +/-   ##
=======================================
  Coverage   72.27%   72.27%           
=======================================
  Files          10       10           
  Lines        2348     2348           
  Branches      311      311           
=======================================
  Hits         1697     1697           
  Misses        651      651           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 184bbc4...c3b8e05. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

OUTPUT_NAME "rawtoaces"
#EXPORT_NAME "rawtoaces"
#SOVERSION ${RAWTOACES_MAJOR_VERSION}.${RAWTOACES_MINOR_VERSION}.${RAWTOACES_PATCH_VERSION}
#VERSION ${RAWTOACES_VERSION}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments. needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I think the binary should be versioned, but uncommenting that makes configure fail.

Also I don't know if this whole 'export' thing is needed, I use it to change the library name, as the 'rawtoaces' target name is already taken. This also makes the library install with the rest of targets, I don't know if the destination should be different. This is good enough for now. We'll need somebody more familiar with python tools deployment to finalise this, I suppose.

ceres:x64-windows \
nlohmann-json:x64-windows \
openimageio:x64-windows
openimageio:x64-windows \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this builds and installs the OIIO python bindings by default. You may need some kind of modifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Will check. We don't need OIIO on the python side that right now.

@antond-weta antond-weta mentioned this pull request Sep 23, 2025
@antond-weta antond-weta merged commit bbb6200 into AcademySoftwareFoundation:main Sep 25, 2025
13 of 14 checks passed
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.

4 participants