From 643f962d8fcebbc44a7e47113e07c53d50c424ff Mon Sep 17 00:00:00 2001 From: Jakub Svoboda <132791205+rolledhand@users.noreply.github.com> Date: Sun, 31 May 2026 20:04:34 +0200 Subject: [PATCH] Houdini 20.5: expose MoonRay Sdr Python stubs Signed-off-by: Jakub Svoboda <132791205+rolledhand@users.noreply.github.com> --- CMakeLists.txt | 4 ++++ moonrayShaderDiscovery/CMakeLists.txt | 3 +++ moonrayShaderParser/CMakeLists.txt | 3 +++ sitecustomize.py | 19 +++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 sitecustomize.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 2af290a..961c5ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,3 +20,7 @@ find_package(Python REQUIRED COMPONENTS Development) add_subdirectory(moonrayShaderDiscovery) add_subdirectory(moonrayShaderParser) + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sitecustomize.py + DESTINATION lib/python +) diff --git a/moonrayShaderDiscovery/CMakeLists.txt b/moonrayShaderDiscovery/CMakeLists.txt index b262d79..91d4e57 100644 --- a/moonrayShaderDiscovery/CMakeLists.txt +++ b/moonrayShaderDiscovery/CMakeLists.txt @@ -72,3 +72,6 @@ install(FILES ${plugInfoFile} DESTINATION plugin/pxr/moonrayShaderDiscovery ) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py + DESTINATION lib/python/pxr/MoonrayShaderDiscovery +) diff --git a/moonrayShaderParser/CMakeLists.txt b/moonrayShaderParser/CMakeLists.txt index a5a2365..709a2f8 100644 --- a/moonrayShaderParser/CMakeLists.txt +++ b/moonrayShaderParser/CMakeLists.txt @@ -72,4 +72,7 @@ install(FILES ${plugInfoFile} DESTINATION plugin/pxr/moonrayShaderParser ) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py + DESTINATION lib/python/pxr/MoonrayShaderParser +) diff --git a/sitecustomize.py b/sitecustomize.py new file mode 100644 index 0000000..538df21 --- /dev/null +++ b/sitecustomize.py @@ -0,0 +1,19 @@ +"""Expose MoonRay's USD Python plugin stubs to Houdini's pxr package. + +Houdini ships pxr as a regular Python package instead of a namespace package, so +adding MoonRay's lib/python directory to PYTHONPATH is not enough for imports +such as pxr.MoonrayShaderParser. The Sdr plugins are native USD plugins; these +small Python stubs only prevent Plug from reporting missing Python modules when +the native parser/discovery plugins are loaded. +""" + +import os + +try: + import pxr + + moonray_pxr_path = os.path.join(os.path.dirname(__file__), "pxr") + if hasattr(pxr, "__path__") and moonray_pxr_path not in pxr.__path__: + pxr.__path__.append(moonray_pxr_path) +except Exception: + pass