Python Module: Bundle VFX library python bindings

When calling bpy.utils.expose_bundled_modules(), these modules are
added to sys.path.

This provides a solution/workaround to two problems:
* Using bpy together with packages like usd-core is problematic. Besides
  crashing due to C++ symbol conflicts, it's just impossible to import
  different versions of the same module, or to have distinct environment
  variables for both. (#127132)
* Blender add-ons using these VFX modules do not currently work with
  the bpy module.

This adds about 15MB to the bpy package.

Pull Request: https://projects.blender.org/blender/blender/pulls/133082
This commit is contained in:
Brecht Van Lommel
2025-01-17 10:13:31 +01:00
committed by Brecht Van Lommel
parent ae6b47f346
commit a6b293daac
7 changed files with 201 additions and 116 deletions

View File

@@ -22,6 +22,9 @@ class CustomHydraRenderEngine(bpy.types.HydraRenderEngine):
# Register path to plugin.
@classmethod
def register(cls):
# Make pxr module available, for running as bpy pip package.
bpy.utils.expose_bundled_modules()
import pxr.Plug
pxr.Plug.Registry().RegisterPlugins(['/path/to/plugin'])

View File

@@ -185,11 +185,15 @@ bl_info = {
import bpy
import bpy.types
import textwrap
# Make pxr module available, for running as bpy pip package.
bpy.utils.expose_bundled_modules()
import pxr.Gf as Gf
import pxr.Sdf as Sdf
import pxr.Usd as Usd
import pxr.UsdShade as UsdShade
import textwrap
class USDHookExample(bpy.types.USDHook):