|
1 | | -import sys, os, sys, platform |
| 1 | +import sys, os, sys, platform, ctypes |
2 | 2 | from os import environ |
3 | 3 | import importlib, importlib.machinery, importlib.util |
4 | 4 |
|
@@ -60,8 +60,24 @@ def findmodule(): |
60 | 60 | else: |
61 | 61 | raise ValueError("Unsupported platform.") |
62 | 62 |
|
| 63 | +def findfixup(dir, libext): |
| 64 | + for fname in os.listdir(dir): |
| 65 | + if ('libFixup' in fname) and (fname.endswith(libext)): |
| 66 | + return os.path.join(dir, os.path.basename(fname)) |
| 67 | + |
63 | 68 | def new_import(): |
64 | 69 | modulefullpath = findmodule() |
| 70 | + |
| 71 | + #Look for a fixup lib |
| 72 | + base_path = os.path.basename(modulefullpath) |
| 73 | + if base_path: |
| 74 | + _, ext = os.path.splitext(modulefullpath) |
| 75 | + #Try to find the fixup lib based on the module path |
| 76 | + fixup_lib = findfixup(base_path, ext) |
| 77 | + if fixup_lib: |
| 78 | + #Loads the fixup lib |
| 79 | + ctypes.cdll.LoadLibrary(fixup_lib) |
| 80 | + |
65 | 81 | loader = importlib.machinery.ExtensionFileLoader("DelphiFMX", modulefullpath) |
66 | 82 | spec = importlib.util.spec_from_file_location("DelphiFMX", modulefullpath, |
67 | 83 | loader=loader, submodule_search_locations=None) |
|
0 commit comments