Skip to content

Commit

Permalink
feat: Disable loading Python DLLs from PATH by default on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zachlewis committed Jan 8, 2025
1 parent 85ece69 commit b7fde08
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# This works around the python 3.8 change to stop loading DLLs from PATH on Windows.
# We reproduce the old behaviour by manually tokenizing PATH, checking that the directories exist and are not ".",
# then add them to the DLL load path.
# This behviour can be disabled by setting the environment variable "OIIO_LOAD_DLLS_FROM_PATH" to "0"
if sys.version_info >= (3, 8) and platform.system() == "Windows" and os.getenv("OIIO_LOAD_DLLS_FROM_PATH", "1") == "1":
# This behviour can be enabled by setting the environment variable "OIIO_PYTHON_LOAD_DLLS_FROM_PATH" to "1"
if sys.version_info >= (3, 8) and platform.system() == "Windows" and os.getenv("OIIO_PYTHON_LOAD_DLLS_FROM_PATH", "0") == "1":
for path in os.getenv("PATH", "").split(os.pathsep):
if os.path.exists(path) and path != ".":
os.add_dll_directory(path)
Expand Down

0 comments on commit b7fde08

Please sign in to comment.