PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
6.15k stars 1.22k forks source link

USD providing built-in Boost.Python converters causes conflicts with other Boost.Python library converters #2067

Open ColinKennedy opened 2 years ago

ColinKennedy commented 2 years ago

Description of Issue

USD provides default Boost.Python converters for built-in types. This tends to cause confusion among developers because modules they are authoring may appear to work or fail to import, depending on import order

from pxr import Ar, Sdf, ...  # Defines a converter for std::map<std::string, std::string>
import my_custom_library  # Has a method that relies on the converter

Imports properly ^^^ but then if you do

import my_custom_library  # Has a method that relies on the converter
from pxr import Ar, Sdf, ...  # Defines a converter for std::map<std::string, std::string>

Then the import of my_custom_library would fail because the built-in converter.

my_custom_library could define its own converters but then those will conflict with what USD provides, causing warnings in the terminal and possibly unexpected behavior. Example warning:

Python boost to-Python converter for class std::map<...> already registered second conversion method ignored

I made note of this over at https://groups.google.com/g/usd-interest/c/3Z4JQL3Wnww and @gitamohr recommended that I create a ticket. In the meantime, I'm going to go with Sunya's suggestion, which is to define the converters directly per-method, to get around this issue.

System Information (OS, Hardware)

Package Versions

Build Flags

Default build_usd.py settings

tallytalwar commented 2 years ago

Filed as internal issue #USD-7721