Documentation on creating a kit-extension with USD plugin is very poor. When creating a kit-extension, there is no useful documentation on how to verify if my USD plugin python and C++ modules are loaded and how to use them. I am on week 3 trying to make this work!
I’ll break down my steps and the issues I came accross:
-
Create USD plugin
Used the usd-plugin-samples (kit106 branch) to create and build a USD plugin containing a custom schema library. The built plugin contains C++ header files, .dll, as well as a python .pyd file. -
Make kit-extension
Created a kit app and kit extension (python template) with kit-app-template repo, then I’ve built them both. -
Add USD plugin to kit-extension
Copied the USD plugin build files in the ext’s build folder ( _build/windows-x86_64/exts/{kit-extension}/ ).
The folders marked inside the kit-extension are copied from the built USD plugin folders created in usd-plugin-sample repo.
- bin/lib - C++ libraries for Win/Linux
- include - C++ header files for each USD plugin
- plugins - folder containing plugin info and generated schema files
- NeuronSimSchema & UsdExampleSchema - init.py and plugin .pyd file
- Update extension config
The config/extension.toml is setup to load early, add native libraries, add extension python module and add USD plugin python module:
[core]
reloadable = false
# Load at the start, load all schemas with order -100 (with order -1000 the USD libs are loaded)
order = -100
[package]
title = "Neuron Simulation Schema"
version = "0.1.0" # Semantic Versionning is used: https://semver.org/
description = "Extension that adds Neuron schemas."
category = "..." # How to categorize this in the Extension Manager
changelog = "docs/CHANGELOG.md"
icon = "data/icon.png" # Icon to show in the Extension Manager
keywords = ["neuron", "sim"] # Search keywords for the Extension Manager
preview_image = "data/preview.png" # Preview to show in the Extension Manager
readme = "docs/README.md" # Path (relative to the root) or content of readme markdown file for UI
repository = "https://github.com/NVIDIA-Omniverse/kit-app-template" # URL of the extension source repository
[settings]
[dependencies]
"omni.usd.libs" = {}
[[native.library]]
"filter:platform"."windows-x86_64"."path" = "bin/${lib_prefix}neuronSimSchema${lib_ext}"
"filter:platform"."windows-x86_64"."path" = "bin/${lib_prefix}usdExampleSchema${lib_ext}"
"filter:platform"."linux-x86_64"."path" = "lib/${lib_prefix}neuronSimSchema${lib_ext}"
"filter:platform"."linux-x86_64"."path" = "lib/${lib_prefix}usdExampleSchema${lib_ext}"
# [[native.plugin]]
# path = "bin/*.plugin"
# recursive = false
[[python.module]] # Main python module this extension provides, it will be publicly available as "import acn.neuron.schema.sim"
name = "acn.neuron.schema.sim"
[[python.module]]
name = "NeuronSimSchema"
path = "./NeuronSimSchema"
[[python.module]]
name = "UsdExampleSchema"
path = "./UsdExampleSchema"
[documentation]
pages = [
"docs/Overview.md",
"docs/CHANGELOG.md",
]
[[test]]
dependencies = [
]
args = [
]
In acn.neuron.schema/acn.neuron.schema/init.py
from .extension import *
from pxr import Plug
import os
pluginsRoot = os.path.join(os.path.dirname(__file__), '../../../../plugins')
neuronSimSchemaPath = os.path.join(pluginsRoot, "neuronSimSchema", "resources")
usdExampleSchemaPath = os.path.join(pluginsRoot, "usdExampleSchema", "resources")
Plug.Registry().RegisterPlugins(neuronSimSchemaPath)
Plug.Registry().RegisterPlugins(usdExampleSchemaPath)
When launching my kit-app and my kit-extension set to autoload or if I manually turn it on, I get this error messages:
[Error] [omni.ext._impl.custom_importer] Failed to import python module NeuronSimSchema. Error: No module named 'NeuronSimSchema'. Traceback:
[Error] [omni.ext._impl.custom_importer] Traceback (most recent call last):
[Error] [omni.ext._impl.custom_importer] File "d:\dev/usdenv/kit-app-template/_build/windows-x86_64/release/kit/kernel/py\omni\ext\_impl\custom_importer.py", line 76, in import_module
[Error] [omni.ext._impl.custom_importer] return importlib.import_module(name)
[Error] [omni.ext._impl.custom_importer] File "d:\dev\usdenv\kit-app-template\_build\windows-x86_64\release\kit\python\lib\importlib\__init__.py", line 126, in import_module
[Error] [omni.ext._impl.custom_importer] return _bootstrap._gcd_import(name[level:], package, level)
[Error] [omni.ext._impl.custom_importer] File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
[Error] [omni.ext._impl.custom_importer] File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
[Error] [omni.ext._impl.custom_importer] File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
[Error] [omni.ext._impl.custom_importer] ModuleNotFoundError: No module named 'NeuronSimSchema'
[Error] [omni.ext._impl.custom_importer]
[Error] [carb.scripting-python.plugin] Exception: Extension python module: 'NeuronSimSchema' in 'd:\dev\usdenv\kit-app-template\_build\windows-x86_64\release\exts\acn.neuron.schema.sim\NeuronSimSchema' failed to load.
[Error] [carb.scripting-python.plugin]
[Error] [carb.scripting-python.plugin] At:
[Error] [carb.scripting-python.plugin] d:\dev/usdenv/kit-app-template/_build/windows-x86_64/release/kit/kernel/py\omni\ext\_impl\_internal.py(213): startup
[Error] [carb.scripting-python.plugin] d:\dev/usdenv/kit-app-template/_build/windows-x86_64/release/kit/kernel/py\omni\ext\_impl\_internal.py(328): startup_extension
[Error] [carb.scripting-python.plugin] PythonExtension.cpp::startup()(2): <module>
[Error] [carb.scripting-python.plugin] c:/users/fanicic/appdata/local/ov/data/kit/composer test app/0.1/exts/3/omni.kit.window.extensions-1.4.25+d02c707b/omni/kit/window/extensions/ext_commands.py(33): do
[Error] [carb.scripting-python.plugin] d:/dev/usdenv/kit-app-template/_build/windows-x86_64/release/extscache/omni.kit.commands-1.4.9+d02c707b.wx64.r.cp310/omni/kit/undo/undo.py(81): execute
[Error] [carb.scripting-python.plugin] d:/dev/usdenv/kit-app-template/_build/windows-x86_64/release/extscache/omni.kit.commands-1.4.9+d02c707b.wx64.r.cp310/omni/kit/commands/command.py(463): execute
[Error] [carb.scripting-python.plugin] c:/users/fanicic/appdata/local/ov/data/kit/composer test app/0.1/exts/3/omni.kit.window.extensions-1.4.25+d02c707b/omni/kit/window/extensions/common.py(509): toggle_self
[Error] [carb.scripting-python.plugin] d:\dev\usdenv\kit-app-template\_build\windows-x86_64\release\kit\python\lib\asyncio\events.py(80): _run
[Error] [carb.scripting-python.plugin] d:\dev\usdenv\kit-app-template\_build\windows-x86_64\release\kit\python\lib\asyncio\base_events.py(1909): _run_once
[Error] [carb.scripting-python.plugin] d:/dev/usdenv/kit-app-template/_build/windows-x86_64/release/kit/extscore/omni.kit.async_engine/omni/kit/async_engine/async_engine.py(197): run_once
[Error] [carb.scripting-python.plugin] d:/dev/usdenv/kit-app-template/_build/windows-x86_64/release/kit/extscore/omni.kit.async_engine/omni/kit/async_engine/async_engine.py(263): <lambda>
[Error] [carb.scripting-python.plugin]
[Error] [omni.ext.plugin] [ext: acn.neuron.schema.sim-0.1.0] Failed to startup python extension.
Making a python script to import acn.neuron.schema.sim works, but it doesn’t load MyPlugin schema classes. Importing NeuronSimSchema causes as error because it can’t find the python module