Skip to content
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

Python bindings not working on Windows with Python 3.8+ #1439

Open
JGamache-autodesk opened this issue Aug 4, 2023 · 0 comments · May be fixed by #1440
Open

Python bindings not working on Windows with Python 3.8+ #1439

JGamache-autodesk opened this issue Aug 4, 2023 · 0 comments · May be fixed by #1440

Comments

@JGamache-autodesk
Copy link
Contributor

There was an important change in how paths are searched on the Windows platform, and it requires adding the following code (or something similar):

# Python 3.8+ on Windows: DLL search paths for dependent
# shared libraries
# Refs.:
# - https://github.com/python/cpython/issues/80266
# - https://docs.python.org/3.8/library/os.html#os.add_dll_directory
import os
import sys
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)

to the top of the init.py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant