@@ -24,7 +24,7 @@ class _MatlabFinder(build_py):
2424 MATLAB_REL = 'R2022a'
2525
2626 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
27- MATLAB_VER = '9.12.10 '
27+ MATLAB_VER = '9.12.11 '
2828
2929 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3030 SUPPORTED_PYTHON_VERSIONS = set (['3.8' , '3.9' ])
@@ -52,7 +52,8 @@ class _MatlabFinder(build_py):
5252 found_matlab = ''
5353
5454 # ERROR MESSAGES
55- minimum_required = "No compatible version of MATLAB was found. This feature supports MATLAB R2019a and later."
55+ minimum_maximum = "No compatible version of MATLAB was found. " + \
56+ "This feature supports MATLAB {minimum:s} through {maximum:s}, inclusive."
5657 dir_not_found = "Directory not found: "
5758 install_compatible = "To install a compatible version, call python -m pip install matlabengine=="
5859 no_windows_install = "MATLAB installation not found in Windows Registry:"
@@ -61,7 +62,7 @@ class _MatlabFinder(build_py):
6162 set_path = "MATLAB installation not found in {path1:s}. Add matlabroot/bin/{arch:s} to {path2:s}."
6263 no_compatible_matlab = "No compatible MATLAB installation found in Windows Registry. This release of " + \
6364 "MATLAB Engine API for Python is compatible with version {ver:s}. The found versions were"
64- no_matlab = "No MATLAB installation found in Windows Registry."
65+ no_matlab = "No compatible MATLAB installation found in Windows Registry."
6566 incompatible_ver = "MATLAB version {ver:s} was found, but MATLAB Engine API for Python is not compatible with it. " + \
6667 "To install a compatible version, call python -m pip install matlabengine=={found:s}."
6768 invalid_version_from_matlab_ver = "Format of MATLAB version '{ver:s}' is invalid."
@@ -171,34 +172,37 @@ def _find_matlab_key_from_windows_registry(self, key):
171172 found_vers = []
172173 for idx in range (num_keys ):
173174 sub_key = winreg .EnumKey (key , idx )
174- found_vers .append (sub_key )
175- # Example: the version in the registry could be "9.13.1" whereas our version is "9.13"
176- # we still want to allow this
177- if self ._check_matlab_ver_against_engine (sub_key ):
178- key_value = sub_key
179- break
175+ if sub_key in self .VER_TO_REL :
176+ found_vers .append (sub_key )
177+ # Example: the version in the registry could be "9.12" whereas the version in this file is "9.12.1".
178+ # We want to allow this.
179+ if self ._check_matlab_ver_against_engine (sub_key ):
180+ key_value = sub_key
181+ break
180182
181183 if not key_value :
182184 if found_vers :
183185 vers = ', ' .join (found_vers )
184- raise RuntimeError (f"{ self .no_compatible_matlab .format (ver = self .MATLAB_VER )} { vers } . { self .install_compatible } { found_vers [- 1 ]} ." )
186+ raise RuntimeError (f"{ self .no_compatible_matlab .format (ver = self ._get_engine_ver_major_minor () )} { vers } . { self .install_compatible } { found_vers [- 1 ]} ." )
185187 else :
186188 raise RuntimeError (f"{ self .no_matlab } " )
187189
188190 return key_value
189191
190- def _check_matlab_ver_against_engine (self , matlab_ver ):
192+ def _get_engine_ver_major_minor (self ):
191193 re_major_minor = "^(\d+)\.(\d+)"
192- matlab_ver_match = re .match (re_major_minor , matlab_ver )
193- if not matlab_ver_match :
194- raise RuntimeError (f"{ self .invalid_version_from_matlab_ver .format (ver = matlab_ver )} " )
195194 eng_match = re .match (re_major_minor , self .MATLAB_VER )
196195 if not eng_match :
197196 raise RuntimeError (f"{ self .invalid_version_from_eng .format (ver = self .MATLAB_VER )} " )
197+ return (eng_match .group (1 ), eng_match .group (2 ))
198198
199+ def _check_matlab_ver_against_engine (self , matlab_ver ):
200+ re_major_minor = "^(\d+)\.(\d+)"
201+ matlab_ver_match = re .match (re_major_minor , matlab_ver )
202+ if not matlab_ver_match :
203+ raise RuntimeError (f"{ self .invalid_version_from_matlab_ver .format (ver = matlab_ver )} " )
204+ eng_major_minor = self ._get_engine_ver_major_minor ()
199205 matlab_ver_major_minor = (matlab_ver_match .group (1 ), matlab_ver_match .group (2 ))
200- eng_major_minor = (eng_match .group (1 ), eng_match .group (2 ))
201-
202206 return (matlab_ver_major_minor == eng_major_minor )
203207
204208 def verify_matlab_release (self , root ):
@@ -250,9 +254,10 @@ def search_path_for_directory_unix(self):
250254 if self .found_matlab :
251255 if self .found_matlab in self .VER_TO_REL :
252256 raise RuntimeError (self .incompatible_ver .format (ver = self .VER_TO_REL [self .found_matlab ], found = self .found_matlab ))
253- # we found a MATLAB release but it is older than R2019a
257+ # We found a MATLAB release but it is older than the oldest version we support,
258+ # or newer than the newest version we support.
254259 else :
255- raise RuntimeError (self .minimum_required )
260+ raise RuntimeError (self .minimum_maximum . format ( minimum = self . VER_TO_REL [ 0 ], maximum = self . VER_TO_REL [ - 1 ]) )
256261 else :
257262 raise RuntimeError (self .set_path .format (path1 = self .path_name , arch = self .arch , path2 = self .path_name ))
258263
@@ -299,7 +304,7 @@ def run(self):
299304 setup (
300305 name = "matlabengine" ,
301306 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
302- version = "9.12.10 " ,
307+ version = "9.12.11 " ,
303308 description = 'A module to call MATLAB from Python' ,
304309 author = 'MathWorks' ,
305310 license = "MathWorks XSLA License" ,
0 commit comments