@@ -24,7 +24,7 @@ class _MatlabFinder(build_py):
2424 MATLAB_REL = 'R2023a'
2525
2626 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
27- MATLAB_VER = '9.14.1a1 '
27+ MATLAB_VER = '9.14.1a2 '
2828
2929 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3030 SUPPORTED_PYTHON_VERSIONS = set (['3.8' , '3.9' , '3.10' ])
@@ -48,7 +48,8 @@ class _MatlabFinder(build_py):
4848 path_env_var_name = ''
4949 python_ver = ''
5050 platform = ''
51- found_matlab = ''
51+ found_matlab_release = ''
52+ found_matlab_version = ''
5253 found_matlab_with_wrong_arch_in_default_install = ''
5354 found_matlab_with_wrong_arch_in_path = ''
5455 verbose = False
@@ -65,8 +66,8 @@ class _MatlabFinder(build_py):
6566 no_compatible_matlab = "No compatible MATLAB installation found in Windows Registry. This release of " + \
6667 "MATLAB Engine API for Python is compatible with version {ver:s}. The found versions were"
6768 no_matlab = "No compatible MATLAB installation found in Windows Registry."
68- incompatible_ver = "MATLAB version {ver:s} was found, but this release of MATLAB Engine API for Python is not compatible with it. " + \
69- "To install a compatible version, call python -m pip install matlabengine=={found :s}."
69+ incompatible_ver = "MATLAB version {ver:s} ({rel:s}) was found, but this release of MATLAB Engine API for Python is not compatible with it. " + \
70+ "To install a compatible version, call ' python -m pip install matlabengine=={ver :s}' ."
7071 invalid_version_from_matlab_ver = "Format of MATLAB version '{ver:s}' is invalid."
7172 invalid_version_from_eng = "Format of MATLAB Engine API version '{ver:s}' is invalid."
7273 next_steps = "Reinstall MATLAB, use DYLD_LIBRARY_PATH to specify a different MATLAB installation, or use a different Python interpreter."
@@ -253,7 +254,7 @@ def _find_matlab_key_from_windows_registry(self, key):
253254 if not key_value :
254255 if found_vers :
255256 vers = ', ' .join (found_vers )
256- eng_ver_major_minor = self ._get_engine_ver_major_minor ()
257+ eng_ver_major_minor = self ._get_engine_ver_major_minor (self . MATLAB_VER )
257258 eng_ver_major_minor_as_str = '{}.{}' .format (eng_ver_major_minor [0 ], eng_ver_major_minor [1 ])
258259 raise RuntimeError (f"{ self .no_compatible_matlab .format (ver = eng_ver_major_minor_as_str )} { vers } ." )
259260 else :
@@ -262,9 +263,9 @@ def _find_matlab_key_from_windows_registry(self, key):
262263 self ._print_if_verbose (f'_find_matlab_key_from_windows_registry returned: { key_value } ' )
263264 return key_value
264265
265- def _get_engine_ver_major_minor (self ):
266+ def _get_engine_ver_major_minor (self , id ):
266267 re_major_minor = "^(\d+)\.(\d+)"
267- eng_match = re .match (re_major_minor , self . MATLAB_VER )
268+ eng_match = re .match (re_major_minor , id )
268269 if not eng_match :
269270 raise RuntimeError (f"{ self .invalid_version_from_eng .format (ver = self .MATLAB_VER )} " )
270271 ret = (eng_match .group (1 ), eng_match .group (2 ))
@@ -295,8 +296,10 @@ def verify_matlab_release(self, root):
295296 matlab_release = ''
296297 for child in tree_root :
297298 if child .tag == 'release' :
298- matlab_release = self .found_matlab = child .text
299- break
299+ matlab_release = self .found_matlab_release = child .text
300+ elif child .tag == 'version' :
301+ major , minor = self ._get_engine_ver_major_minor (child .text )
302+ self .found_matlab_version = f'{ major } .{ minor } '
300303 return matlab_release == self .MATLAB_REL
301304
302305 def search_path_for_directory_unix (self , arch , path_dirs ):
@@ -327,18 +330,20 @@ def search_path_for_directory_unix(self, arch, path_dirs):
327330
328331 def _err_msg_if_bad_matlab_root (self , matlab_root ):
329332 if not matlab_root :
330- if self .found_matlab :
331- if self .found_matlab in self .VER_TO_REL :
332- return self .incompatible_ver .format (ver = self .VER_TO_REL [self .found_matlab ], found = self .found_matlab )
333+ if self .found_matlab_version :
334+ self ._print_if_verbose (f'self.found_matlab_version: { self .found_matlab_version } ; self.VER_TO_REL: { self .VER_TO_REL } ' )
335+ if self .found_matlab_version in self .VER_TO_REL :
336+ return self .incompatible_ver .format (ver = self .found_matlab_version , rel = self .found_matlab_release )
333337 # Found a MATLAB release but it is older than the oldest version supported,
334338 # or newer than the newest version supported.
335339 else :
336340 v_to_r_keys = list (self .VER_TO_REL .keys ())
341+ self ._print_if_verbose (f'v_to_r_keys: { v_to_r_keys } ' )
337342 min_v = v_to_r_keys [0 ]
338343 min_r = self .VER_TO_REL [min_v ]
339344 max_v = v_to_r_keys [- 1 ]
340345 max_r = self .VER_TO_REL [max_v ]
341- return self .minimum_maximum .format (this_v = self .found_matlab , min_v = min_v , min_r = min_r , max_v = max_v , max_r = max_r )
346+ return self .minimum_maximum .format (this_v = self .found_matlab_release , min_v = min_v , min_r = min_r , max_v = max_v , max_r = max_r )
342347 else :
343348 # If we reach this line, we assume that the default location has already been checked for an
344349 # appropriate MATLAB installation but none was found.
@@ -409,7 +414,7 @@ def run(self):
409414 setup (
410415 name = "matlabengine" ,
411416 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
412- version = "9.14.1a1 " ,
417+ version = "9.14.1a2 " ,
413418 description = 'A module to call MATLAB from Python' ,
414419 author = 'MathWorks' ,
415420 license = "MathWorks XSLA License" ,
0 commit comments