Skip to content

Add Python typing stubs#2206

Open
scottdmilner wants to merge 1 commit into
AcademySoftwareFoundation:masterfrom
scottdmilner:typing-stubs
Open

Add Python typing stubs#2206
scottdmilner wants to merge 1 commit into
AcademySoftwareFoundation:masterfrom
scottdmilner:typing-stubs

Conversation

@scottdmilner
Copy link
Copy Markdown

@scottdmilner scottdmilner commented May 19, 2026

This PR uses nanobind's nanobind_add_stub() to add typing stubs to the Python module. The recommended nanobind version is raised to 2.9.2 to add support for the RECURSIVE flag.

Can be toggled by cmake flags OPENVDB_BUILD_PYTHON_STUBS / NANOVDB_BUILD_PYTHON_STUBS

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 19, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: scottdmilner / name: Scott Milner (02ab1c5)

PYTHON_PATH "."
MARKER_FILE py.typed
)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if someone pulls and is building with < 2.9.2, does the RECURSIVE flag silently do nothing? Would it be worth a nested branch here for if(nanobind_VERSION VERSION_LESS 2.9.2) which outputs a message(WARNING) that no python type info will be generated (as it requires 2.9.2)?

Same in the OpenVDB CMakeLists.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, the current behavior is to fail build configuration. I added some checks and warnings.

Copy link
Copy Markdown
Contributor

@Idclip Idclip left a comment

Choose a reason for hiding this comment

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

Thanks for this @scottdmilner, I haven't tested but looks good. Minor comment and the failing test can be ignored

Comment thread nanovdb/nanovdb/python/CMakeLists.txt Outdated
Comment thread openvdb/openvdb/python/CMakeLists.txt Outdated
Signed-off-by: Scott Milner <scottdmilner@gmail.com>
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