-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQUEST] Turn off OIIO_LOAD_DLLS_FROM_PATH by default #4519
Comments
Just noting that the equivalent change for OpenColorIO has been made for v2.4.1; and I'd like to keep OIIO's behavior in sync with OCIO. 🎣 🎣 🎣 |
I'm not enough of a Python expert to really have an opinion here, though I'm inclined to accept "OCIO already hashed through this, let's match what they do" as a reasonable default. Can anybody else chime in here with thumbs up/down, or preferably turn this suggestion into a PR that can be reviewed and easily merged? |
Users can set `OIIO_PYTHON_LOAD_DLLS_FROM_PATH=1` to opt in to the legacy behavior. This commit matches the changes made by AcademySoftwareFoundation#4590 to address issue AcademySoftwareFoundation#4519. Signed-off-by: Zach Lewis <[email protected]>
) Users can enable the legacy behavior by setting env var `OIIO_PYTHON_LOAD_DLLS_FROM_PATH=1`. This commit also changes the environment variable name from `OIIO_LOAD_DLLS_FROM_PATH` to `OIIO_PYTHON_LOAD_DLLS_FROM_PATH` to match the convention used by OCIO. This PR addresses issue #4519 --------- Signed-off-by: Zach Lewis <[email protected]>
…ademySoftwareFoundation#4590) Users can enable the legacy behavior by setting env var `OIIO_PYTHON_LOAD_DLLS_FROM_PATH=1`. This commit also changes the environment variable name from `OIIO_LOAD_DLLS_FROM_PATH` to `OIIO_PYTHON_LOAD_DLLS_FROM_PATH` to match the convention used by OCIO. This PR addresses issue AcademySoftwareFoundation#4519 --------- Signed-off-by: Zach Lewis <[email protected]>
This regards behavior introduced by @anderslanglands in #3470 pertaining to Windows / Python 3.8+ DLL loading, and mirrors an identical issue with the OpenColorIO Python API:
(Anecdotally, in the OCIO #helpdesk Slack channel, we've recently encountered Windows users experiencing segfaults when trying to import pip-installed PyOpenColorIO unless they set OCIO_PYTHON_LOAD_DLLS_FROM_PATH=1.)
Currently, users can "opt out" of this behavior by setting
OIIO_LOAD_DLLS_FROM_PATH=0
.Instead, I would rather have users "opt in", and only load DLLs from $PATH
if os.getenv("OIIO_LOAD_DLLS_FROM_PATH", "0") == "1"
.Looking back in the commentary, it looks like #3470 originally intended for opt-in-style behavior, but was later changed to opt-out-style, to inflict the least amount of surprise on Windows Python-3.8+ users expecting Python-3.7 behavior:
Originally posted by @lgritz in #3470 (comment)
I propose that we flip the behavior for OIIO-3.0, and/or find a more discerning method of adding paths to the DLL search path.
Describe the solution you'd like
This is what src/python/__init __.py looks like now:
I'm suggesting that we change the first if-statement to:
Describe alternatives you've considered
One thing we could do is wrap this behavior in a try / except block, only loading DLLs from PATH if
import OpenImageIO
raises a ModuleNotFound exception.We could also find a way to be a bit more selective with the paths we add -- perhaps by recursing through the contents of each directory in PATH, and only adding paths that contain a file whose name ends with "OpenImageIO.dll" or something.
Additional context
USD is also doing something similar, although I'd be lying if I claimed to understand exactly what's going on. Maybe by wrapping the module loading procedure in a context manager, they're able to inoculate against the sorts of segfaults we're experiencing.
The text was updated successfully, but these errors were encountered: