@@ -24,7 +24,7 @@ class _MatlabFinder(build_py):
2424 MATLAB_REL = 'R2022b'
2525
2626 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
27- MATLAB_VER = '9.13.3a1 '
27+ MATLAB_VER = '9.13.3a2 '
2828
2929 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3030 SUPPORTED_PYTHON_VERSIONS = set (['3.8' , '3.9' , '3.10' ])
@@ -61,7 +61,7 @@ class _MatlabFinder(build_py):
6161 no_compatible_matlab = "No compatible MATLAB installation found in Windows Registry. This release of " + \
6262 "MATLAB Engine API for Python is compatible with version {ver:s}. The found versions were"
6363 no_matlab = "No compatible MATLAB installation found in Windows Registry."
64- incompatible_ver = "MATLAB version {ver:s} was found, but MATLAB Engine API for Python is not compatible with it. " + \
64+ incompatible_ver = "MATLAB version {ver:s} was found, but this release of MATLAB Engine API for Python is not compatible with it. " + \
6565 "To install a compatible version, call python -m pip install matlabengine=={found:s}."
6666 invalid_version_from_matlab_ver = "Format of MATLAB version '{ver:s}' is invalid."
6767 invalid_version_from_eng = "Format of MATLAB Engine API version '{ver:s}' is invalid."
@@ -82,8 +82,6 @@ def set_platform_and_arch(self):
8282 self .arch = 'glnxa64'
8383 elif self .platform == 'Darwin' :
8484 if platform .mac_ver ()[- 1 ] == 'arm64' :
85- # This value will be changed later in the script if a maci64 MATLAB
86- # installation, to be run under Rosetta, is encountered.
8785 self .arch = 'maca64'
8886 else :
8987 self .arch = 'maci64'
@@ -226,20 +224,15 @@ def verify_matlab_release(self, root):
226224 break
227225 return matlab_release == self .MATLAB_REL
228226
229- def search_path_for_directory_unix (self ):
227+ def search_path_for_directory_unix (self , arch , path_dirs ):
230228 """
231229 Used for finding MATLAB root in UNIX systems. Searches all paths ending in
232230 /bin/<arch> for the presence of MATLAB file to ensure the path is within
233231 the MATLAB tree.
234232 """
235- path_dirs = self ._create_path_list ()
236- dir_to_find = os .path .join ('bin' , self .arch )
233+ dir_to_find = os .path .join ('bin' , arch )
237234 # directory could end with slashes
238235 endings = [dir_to_find , dir_to_find + os .sep ]
239- if self .arch == 'maca64' :
240- addl_dir_to_find = 'maci64'
241- endings .append (addl_dir_to_find )
242- endings .append (addl_dir_to_find + os .sep )
243236
244237 matlab_root = ''
245238 dir_idx = 0
@@ -251,23 +244,17 @@ def search_path_for_directory_unix(self):
251244 if path .endswith (ending ):
252245 # _get_matlab_root_from_unix_bin will return an empty string if MATLAB is not found.
253246 # Non-empty string (MATLAB found) will break both loops.
254- if self .arch == 'maca64' and ending [:6 ] == 'maci64' :
255- # Found a maci64 installation to be used under Rosetta.
256- # To use maci64 on a maca64 machine, one of the following must be true:
257- # (1) there must be a maci64 installation in the default location
258- # (see DEFAULT_INSTALLS), or
259- # (2) there must be no Mac installation in the default location
260- # and the maci64 installation must be earlier on DYLD_LIBRARY_PATH
261- # than any maca64 installation.
262- self .arch = 'maci64'
263247 matlab_root = self ._get_matlab_root_from_unix_bin (path )
264248 ending_idx += 1
265249 dir_idx += 1
266-
250+
251+ return matlab_root
252+
253+ def _err_msg_if_bad_matlab_root (self , matlab_root ):
267254 if not matlab_root :
268255 if self .found_matlab :
269256 if self .found_matlab in self .VER_TO_REL :
270- raise RuntimeError ( self .incompatible_ver .format (ver = self .VER_TO_REL [self .found_matlab ], found = self .found_matlab ) )
257+ return self .incompatible_ver .format (ver = self .VER_TO_REL [self .found_matlab ], found = self .found_matlab )
271258 # Found a MATLAB release but it is older than the oldest version supported,
272259 # or newer than the newest version supported.
273260 else :
@@ -276,14 +263,15 @@ def search_path_for_directory_unix(self):
276263 min_r = self .VER_TO_REL [min_v ]
277264 max_v = v_to_r_keys [- 1 ]
278265 max_r = self .VER_TO_REL [max_v ]
279- raise RuntimeError ( self .minimum_maximum .format (min_v = min_v , min_r = min_r , max_v = max_v , max_r = max_r ) )
266+ return self .minimum_maximum .format (min_v = min_v , min_r = min_r , max_v = max_v , max_r = max_r )
280267 else :
281- raise RuntimeError ( self .set_path .format (path1 = self .path_name , arch = self . arch , path2 = self .path_name ) )
268+ return self .set_path .format (path1 = self .path_name , arch = arch , path2 = self .path_name )
282269
283270 if not os .path .isdir (matlab_root ):
284- raise RuntimeError (f"{ self .dir_not_found } { matlab_root } " )
285- return matlab_root
286-
271+ return f"{ self .dir_not_found } { matlab_root } "
272+
273+ return ''
274+
287275 def write_text_file (self , matlab_root ):
288276 """
289277 Writes root.txt for use at import time.
@@ -311,7 +299,12 @@ def run(self):
311299 if self .unix_default_install_exists ():
312300 matlab_root = self .DEFAULT_INSTALLS [self .platform ]
313301 else :
314- matlab_root = self .search_path_for_directory_unix ()
302+ path_dirs = self ._create_path_list ()
303+ matlab_root = self .search_path_for_directory_unix (self .arch , path_dirs )
304+ err_msg = self ._err_msg_if_bad_matlab_root (matlab_root )
305+ if err_msg :
306+ raise RuntimeError (err_msg )
307+
315308 self .write_text_file (matlab_root )
316309 build_py .run (self )
317310
@@ -323,7 +316,7 @@ def run(self):
323316 setup (
324317 name = "matlabengine" ,
325318 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
326- version = "9.13.3a1 " ,
319+ version = "9.13.3a2 " ,
327320 description = 'A module to call MATLAB from Python' ,
328321 author = 'MathWorks' ,
329322 license = "MathWorks XSLA License" ,
0 commit comments