Commit 9877830f authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

refactor checks for MLD binary

parent 6d31c79b
Loading
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -357,17 +357,17 @@ def compare(
        if get_mld:
            mld_max = 0
            toolsdir = Path(__file__).parent.parent.joinpath("tools")
            if platform.system() == "Windows":
                mld = toolsdir.joinpath("Win32").joinpath("mld.exe")
            elif platform.system() in ["Linux", "Darwin"]:
                mld = toolsdir.joinpath(platform.system()).joinpath("mld")
            else:
                assert False, f"MLD tool not available for {platform.system()}"
            
            curr_platform = platform.system()
            if curr_platform not in {"Windows", "Linux", "Darwin"}:
                raise NotImplementedError(f"MLD tool not available for {curr_platform}")
            search_path = toolsdir.joinpath(curr_platform.replace("Windows", "Win32"))
            mld = search_path.joinpath("mld")

            if not mld.exists():
                mld = shutil.which("mld")
                search_path = toolsdir.joinpath(platform.system().replace("Windows", "Win32"))
                if mld is None:
                    assert False, f"MLD tool not found in {search_path} or PATH!"
                    raise FileNotFoundError(f"MLD tool not found in {search_path} or PATH!")
                warnings.warn(f"MLD binary not found in {search_path}! Falling back to {mld}!")

            with tempfile.TemporaryDirectory() as tmpdir: