| 31 | HARDMAX_PLUGIN_LIBRARY = [os.path.join(WORKING_DIR, "build", HARDMAX_PLUGIN_LIBRARY_NAME)] |
| 32 | |
| 33 | def load_plugin_lib(): |
| 34 | for plugin_lib in HARDMAX_PLUGIN_LIBRARY: |
| 35 | if os.path.isfile(plugin_lib): |
| 36 | try: |
| 37 | # Python specifies that winmode is 0 by default, but some implementations |
| 38 | # incorrectly default to None instead. See: |
| 39 | # https://docs.python.org/3.8/library/ctypes.html |
| 40 | # https://github.com/python/cpython/blob/3.10/Lib/ctypes/__init__.py#L343 |
| 41 | ctypes.CDLL(plugin_lib, winmode=0) |
| 42 | except TypeError: |
| 43 | # winmode only introduced in python 3.8 |
| 44 | ctypes.CDLL(plugin_lib) |
| 45 | return |
| 46 | |
| 47 | raise IOError( |
| 48 | "\n{}\n{}\n{}\n".format( |
| 49 | "Failed to load library ({}).".format(HARDMAX_PLUGIN_LIBRARY_NAME), |
| 50 | "Please build the Hardmax sample plugin.", |
| 51 | "For more information, see the included README.md", |
| 52 | ) |
| 53 | ) |