Skip to content

Commit

Permalink
Only update DLL path if not a PIP module
Browse files Browse the repository at this point in the history
  • Loading branch information
JGamache-autodesk committed Oct 25, 2023
1 parent bc93756 commit 0220de7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions python/MaterialX/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
# - https://docs.python.org/3.8/library/os.html#os.add_dll_directory
import os
import sys
import importlib
if sys.platform == "win32" and sys.version_info >= (3, 8):
# On a standard installation, this file is in %INSTALLDIR%\python\MaterialX
# We need to add %INSTALLDIR%\bin to the DLL path.
mxdir = os.path.dirname(__file__)
pydir = os.path.split(mxdir)[0]
installdir = os.path.split(pydir)[0]
bindir = os.path.join(installdir, "bin")
if os.path.exists(bindir):
os.add_dll_directory(bindir)
try:
importlib.metadata.version('MaterialX')
except importlib.metadata.PackageNotFoundError:
# On a non-pip installation, this file is in %INSTALLDIR%\python\MaterialX
# We need to add %INSTALLDIR%\bin to the DLL path.
mxdir = os.path.dirname(__file__)
pydir = os.path.split(mxdir)[0]
installdir = os.path.split(pydir)[0]
bindir = os.path.join(installdir, "bin")
if os.path.exists(bindir):
os.add_dll_directory(bindir)

from .main import *
from .colorspace import *
Expand Down

0 comments on commit 0220de7

Please sign in to comment.