USD Plugins and Root Path

In refining our schema build tools, I ran across a curious case that Plug didn’t like. As an example, consider I have the following plugin folder structure:

  • schemas
    • bin
      • schemaA.dll
      • schemaB.dll
    • SchemaA
      • init.py
    • SchemaB
      • init.py
    • plugins
      • SchemaA
      • resources
        • plugInfo.json
        • generatedSchema.usda
      • SchemaB
      • resources
        • plugInfo.json
        • generatedSchema.usda

The contents of the plugInfo.json file for SchemaA was setup such that:

  • Root = …/…/…
  • ResourcesPath = plugins/SchemaA/resources
  • LibraryPath = bin/SchemaA.dll

Similarly, the one for SchemaB was setup such that:

  • Root = …/…/…
  • ResourcesPath = plugins/SchemaB/resources
  • LibraryPath = bin/SchemaB.dll

To register the plugins, either PXR_PLUGINPATH_NAME contained the paths:

  • schemas/plugins/SchemaA/resources
  • schemas/plugins/SchemaB/resources

(or they were individually sent to RegisterPlugins to register explicitly).

It turns out Plug refused to load both plugins - only the first would be loaded because there was an early out when checking the “Root” path of the plugins, and because this was the same path for SchemaA and SchemaB, plug decided it was the same plugin. Clearly these plugins are in their own location (which can be deduced by combining the root path with the resources path where the actual plugInfo.json file resides), so it is curious why this would be a restriction from the point of view of Plug? I find it more intuitive to say a plugin being registered is the same if the path to the plugInfo.json path is the same (which is the path you have to pass to RegisterPlugins or put in PXR_PLUGINPATH_NAME anyway). Is there a specific reason why this is not the case (and would something be lost if this behavior was changed)?

Obviously, I can change this such that SchemaA had:

  • Root = “…”
  • LibraryPath = “…/…/bin/SchemaA.dll”
  • ResourcesPath = “resources”

and SchemaB had:

  • Root = “…”
  • LibraryPath = “…/…/bin/SchemaB.dll”
  • ResourcesPath = “resources”

and then it’s fine because Root resolves to two different locations on disk. But I’m curious as to why there is a restriction on the Root path rather than where the plugInfo.json file actually is.

At first blush this does seem like an oversight somewhere. Can you point me to the code in Plug that’s checking for the duplicated “Root” path? I did a quick look but couldn’t find anything like that.

sure, I believe it’s this block:

Huh, I haven’t looked too closely yet but naively I’d expect metadata.pluginPath to be the fully qualified path of the shared library, not just the root path. I’ll try to poke at this a little more, but if you could file an issue about it that’d be great too so I don’t lose track.