Skip to content

Commit 1bd2776

Browse files
committed
Forgo the lengthly discovery process if we already have cached installs
1 parent 339eff2 commit 1bd2776

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

precommitmatlablint/find_matlab.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ def refresh(self) -> None:
182182

183183
@classmethod
184184
def construct_exe_path(cls, home_path: Path) -> Path:
185-
return home_path / "bin" / MatlabHandle.get_architecture_folder_name() / MatlabHandle.get_matlab_exe_name()
185+
return (
186+
home_path
187+
/ "bin"
188+
/ MatlabHandle.get_architecture_folder_name()
189+
/ MatlabHandle.get_matlab_exe_name()
190+
)
186191

187192
@classmethod
188193
def read_version_info(cls, version_info_path: Path) -> Tuple[str, str]:
@@ -229,10 +234,9 @@ def get_matlab_exe_name(cls) -> str:
229234
@classmethod
230235
def get_architecture_folder_name(cls) -> str:
231236
"""Return the architecture folder name used by Mathworks"""
232-
arch_folder_names = {'win32': 'win64',
233-
'darwin': 'maci64',
234-
'linux': 'glnxa64'}
235-
return arch_folder_names.get(sys.platform, '')
237+
arch_folder_names = {"win32": "win64", "darwin": "maci64", "linux": "glnxa64"}
238+
return arch_folder_names.get(sys.platform, "")
239+
236240

237241
class MatlabHandleList:
238242
handles: List[MatlabHandle]
@@ -534,7 +538,9 @@ def find_matlab(
534538

535539
handle_list: MatlabHandleList = MatlabHandleList(cache_file)
536540
handle_list.load()
537-
handle_list.update(get_matlab_installs())
541+
if len(handle_list) == 0:
542+
# If we haven't previously cached any installs, go find all that are present on the system
543+
handle_list.update(get_matlab_installs())
538544

539545
handle: Optional[MatlabHandle] = None
540546
if matlab_home_path is not None:

0 commit comments

Comments
 (0)