Skip to content

Commit c0f860e

Browse files
committed
IECore : Force RTLD_GLOBAL for imath
We still need to use RTLD_GLOBAL when importing imath to avoid the following error: `TypeError: No to_python (by-value) converter found for C++ type: Imath_2_2::Vec2<float>`
1 parent 8033e22 commit c0f860e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

python/IECore/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,22 @@
5353
__import__( "sys" ).getdlopenflags() | __import__( "ctypes" ).RTLD_GLOBAL
5454
)
5555

56-
__import__( "imath" )
56+
try :
57+
58+
# Make sure we import imath _with_ RTLD_GLOBAL. This avoids
59+
# boost to_python (by-value) converter issues for imath types.
60+
61+
import sys
62+
import ctypes
63+
originalDLOpenFlags = sys.getdlopenflags()
64+
sys.setdlopenflags( originalDLOpenFlags | ctypes.RTLD_GLOBAL )
65+
66+
__import__( "imath" )
67+
68+
finally :
69+
70+
sys.setdlopenflags( originalDLOpenFlags )
71+
del sys, ctypes, originalDLOpenFlags
5772

5873
from _IECore import *
5974

0 commit comments

Comments
 (0)