@@ -24,7 +24,7 @@ class _MatlabFinder(build_py):
24
24
MATLAB_REL = 'R2022b'
25
25
26
26
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
27
- MATLAB_VER = '9.13.3a1 '
27
+ MATLAB_VER = '9.13.3a2 '
28
28
29
29
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
30
30
SUPPORTED_PYTHON_VERSIONS = set (['3.8' , '3.9' , '3.10' ])
@@ -61,7 +61,7 @@ class _MatlabFinder(build_py):
61
61
no_compatible_matlab = "No compatible MATLAB installation found in Windows Registry. This release of " + \
62
62
"MATLAB Engine API for Python is compatible with version {ver:s}. The found versions were"
63
63
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. " + \
65
65
"To install a compatible version, call python -m pip install matlabengine=={found:s}."
66
66
invalid_version_from_matlab_ver = "Format of MATLAB version '{ver:s}' is invalid."
67
67
invalid_version_from_eng = "Format of MATLAB Engine API version '{ver:s}' is invalid."
@@ -82,8 +82,6 @@ def set_platform_and_arch(self):
82
82
self .arch = 'glnxa64'
83
83
elif self .platform == 'Darwin' :
84
84
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.
87
85
self .arch = 'maca64'
88
86
else :
89
87
self .arch = 'maci64'
@@ -226,20 +224,15 @@ def verify_matlab_release(self, root):
226
224
break
227
225
return matlab_release == self .MATLAB_REL
228
226
229
- def search_path_for_directory_unix (self ):
227
+ def search_path_for_directory_unix (self , arch , path_dirs ):
230
228
"""
231
229
Used for finding MATLAB root in UNIX systems. Searches all paths ending in
232
230
/bin/<arch> for the presence of MATLAB file to ensure the path is within
233
231
the MATLAB tree.
234
232
"""
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 )
237
234
# directory could end with slashes
238
235
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 )
243
236
244
237
matlab_root = ''
245
238
dir_idx = 0
@@ -251,23 +244,17 @@ def search_path_for_directory_unix(self):
251
244
if path .endswith (ending ):
252
245
# _get_matlab_root_from_unix_bin will return an empty string if MATLAB is not found.
253
246
# 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'
263
247
matlab_root = self ._get_matlab_root_from_unix_bin (path )
264
248
ending_idx += 1
265
249
dir_idx += 1
266
-
250
+
251
+ return matlab_root
252
+
253
+ def _err_msg_if_bad_matlab_root (self , matlab_root ):
267
254
if not matlab_root :
268
255
if self .found_matlab :
269
256
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 )
271
258
# Found a MATLAB release but it is older than the oldest version supported,
272
259
# or newer than the newest version supported.
273
260
else :
@@ -276,14 +263,15 @@ def search_path_for_directory_unix(self):
276
263
min_r = self .VER_TO_REL [min_v ]
277
264
max_v = v_to_r_keys [- 1 ]
278
265
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 )
280
267
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 )
282
269
283
270
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
+
287
275
def write_text_file (self , matlab_root ):
288
276
"""
289
277
Writes root.txt for use at import time.
@@ -311,7 +299,12 @@ def run(self):
311
299
if self .unix_default_install_exists ():
312
300
matlab_root = self .DEFAULT_INSTALLS [self .platform ]
313
301
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
+
315
308
self .write_text_file (matlab_root )
316
309
build_py .run (self )
317
310
@@ -323,7 +316,7 @@ def run(self):
323
316
setup (
324
317
name = "matlabengine" ,
325
318
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
326
- version = "9.13.3a1 " ,
319
+ version = "9.13.3a2 " ,
327
320
description = 'A module to call MATLAB from Python' ,
328
321
author = 'MathWorks' ,
329
322
license = "MathWorks XSLA License" ,
0 commit comments