diff --git a/Rom.py b/Rom.py index 57b81652..ecf26040 100644 --- a/Rom.py +++ b/Rom.py @@ -168,30 +168,29 @@ def check_enemizer(enemizercli): if not os.path.exists(enemizercli) and not os.path.exists(enemizercli + ".exe"): raise Exception(f"Enemizer not found at {enemizercli}, please install it." f"Such as https://github.com/Ijwu/Enemizer/releases") - if sys.platform == "win32": - # the win32api calls appear to not be threadsafe, which is the reason for the lock - with check_lock: - # some time may have passed since the lock was acquired, as such a quick re-check doesn't hurt - if getattr(check_enemizer, "done", None): - return - try: - import pythoncom - from win32com.client import Dispatch - pythoncom.CoInitialize() - except ImportError: - logging.info("Could not check Enemizer Version info as pywin32 bindings are missing.") - else: - # version info is saved on the lib, for some reason - library = os.path.join(os.path.dirname(enemizercli), "EnemizerLibrary.dll") - ver_parser = Dispatch('Scripting.FileSystemObject') - info = ver_parser.GetFileVersion(library) - if info != 'No Version Information Available': - version = tuple(int(part) for part in info.split(".")) - if version < (6, 1, 0, 222): - raise Exception( - f"Enemizer found at {enemizercli} is outdated ({info}), please update your Enemizer. " - f"Such as https://github.com/Ijwu/Enemizer/releases") + with check_lock: + # some time may have passed since the lock was acquired, as such a quick re-check doesn't hurt + if getattr(check_enemizer, "done", None): + return + + # version info is saved on the lib, for some reason + library_info = os.path.join(os.path.dirname(enemizercli), "EnemizerCLI.Core.deps.json") + with open(library_info) as f: + info = json.load(f) + + for lib in info["libraries"]: + if lib.startswith("EnemizerLibrary/"): + version = lib.split("/")[-1] + version = tuple(int(element) for element in version.split(".")) + logging.info(version) + if version < (6, 2, 0): + raise Exception( + f"Enemizer found at {enemizercli} is outdated ({info}), please update your Enemizer. " + f"Such as https://github.com/Ijwu/Enemizer/releases") + break + else: + raise Exception(f"Could not find Enemizer library version information in {library_info}") check_enemizer.done = True