-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup: Refactor DLL loading and remove metadata from __init__.py
Simplified the DLL loading process for Windows platform by removing version-specific conditions. Also, removed unnecessary metadata such as status, author, email, license, and copyright from the file. All that stuff can be retrieved with importlib.metadata. Signed-off-by: Zach Lewis <[email protected]>
- Loading branch information
Showing
1 changed file
with
2 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,39 +21,19 @@ | |
# Python wheel module is dynamically linked to the OIIO DLL present in the bin folder. | ||
_bin_dir = os.path.join(_here, "bin") | ||
if os.path.exists(_bin_dir): | ||
if sys.version_info >= (3, 8): | ||
os.add_dll_directory(_bin_dir) | ||
else: | ||
os.environ['PATH'] = '{0};{1}'.format(_bin_dir, os.getenv('PATH', '')) | ||
|
||
#TODO: Remove. Python 3.8 stopped loading DLLs from PATH on Windows for security reasons. | ||
if sys.version_info >= (3, 8): | ||
os.add_dll_directory(_bin_dir) | ||
elif sys.version_info >= (3, 8): | ||
# This works around the python 3.8 change to stop loading DLLs from PATH on Windows. | ||
# We reproduce the old behavior by manually tokenizing PATH, checking that the | ||
# directories exist and are not ".", then add them to the DLL load path. | ||
# Set the environment variable "OIIO_LOAD_DLLS_FROM_PATH" to "0" to disable this behavior. | ||
if os.getenv("OIIO_LOAD_DLLS_FROM_PATH", "1") == "1": | ||
logger.warning( | ||
"Adding DLL directories to PATH. This behavior will be removed in " | ||
"a future version. Set the environment variable OIIO_LOAD_DLLS_FROM_PATH " | ||
"to 0 to disable this behavior." | ||
) | ||
for path in os.getenv("PATH", "").split(os.pathsep): | ||
if os.path.exists(path) and path != ".": | ||
os.add_dll_directory(path) | ||
|
||
from .OpenImageIO import * # type: ignore # noqa: F401, F403, E402 | ||
|
||
__status__ = "production" | ||
|
||
__author__ = "OpenImageIO Contributors" | ||
|
||
__email__ = "[email protected]" | ||
|
||
__license__ = "SPDX-License-Identifier: Apache-2.0" | ||
|
||
__copyright__ = "Copyright Contributors to the OpenImageIO Project" | ||
|
||
__doc__ = """ | ||
OpenImageIO is a toolset for reading, writing, and manipulating image files of | ||
any image file format relevant to VFX / animation via a format-agnostic API | ||
|