forked from AcademySoftwareFoundation/OpenColorIO
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adsk Contrib - Allow PyOpenColorIO module to load DLLs from Windows P…
…ATH environment variable (AcademySoftwareFoundation#1759) * Allow PyOpenColorIO module to load DLLs from Windows PATH environment variable with an opt-out option in case the user want the default behavior of Python 3.8+. Signed-off-by: Cédrik Fuoco <[email protected]> * Fixing typos in comments Signed-off-by: Cédrik Fuoco <[email protected]> --------- Signed-off-by: Cédrik Fuoco <[email protected]> Co-authored-by: Doug Walker <[email protected]> Signed-off-by: Cédrik Fuoco <[email protected]>
- Loading branch information
1 parent
0221599
commit caa2fce
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright Contributors to the OpenColorIO Project. | ||
|
||
import os, sys, platform | ||
|
||
# | ||
# Python 3.8+ has stopped loading DLLs from PATH environment variable on Windows. | ||
# | ||
# This code reproduce the old behavior (loading DLLs from PATH) by doing the following: | ||
# 1 - Tokenizing PATH | ||
# 2 - Checking that the directories exist and are not "." | ||
# 3 - Add them to the DLL load path. | ||
# | ||
# The behavior described above is opt-out which means that it is activated by default. | ||
# A user can opt-out and use the default behavior of Python 3.8+ by setting OCIO_PYTHON_LOAD_DLLS_FROM_PATH | ||
# environment variable to 0. | ||
# | ||
|
||
if sys.version_info >= (3, 8) and platform.system() == "Windows" and os.getenv("OCIO_PYTHON_LOAD_DLLS_FROM_PATH", "1") == "1": | ||
for path in os.getenv("PATH", "").split(os.pathsep): | ||
if os.path.exists(path) and path != ".": | ||
os.add_dll_directory(path) | ||
|
||
from .PyOpenColorIO import * |