@@ -24,7 +24,7 @@ class _MatlabFinder(build_py):
24
24
MATLAB_REL = 'R2021b'
25
25
26
26
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
27
- MATLAB_VER = '9.11'
27
+ MATLAB_VER = '9.11.16a0 '
28
28
29
29
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
30
30
SUPPORTED_PYTHON_VERSIONS = set (['3.7' , '3.8' , '3.9' ])
@@ -52,7 +52,8 @@ class _MatlabFinder(build_py):
52
52
found_matlab = ''
53
53
54
54
# 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."
56
57
dir_not_found = "Directory not found: "
57
58
install_compatible = "To install a compatible version, call python -m pip install matlabengine=="
58
59
no_windows_install = "MATLAB installation not found in Windows Registry:"
@@ -171,34 +172,37 @@ def _find_matlab_key_from_windows_registry(self, key):
171
172
found_vers = []
172
173
for idx in range (num_keys ):
173
174
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
180
182
181
183
if not key_value :
182
184
if found_vers :
183
185
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 ]} ." )
185
187
else :
186
188
raise RuntimeError (f"{ self .no_matlab } " )
187
189
188
190
return key_value
189
191
190
- def _check_matlab_ver_against_engine (self , matlab_ver ):
192
+ def _get_engine_ver_major_minor (self ):
191
193
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 )} " )
195
194
eng_match = re .match (re_major_minor , self .MATLAB_VER )
196
195
if not eng_match :
197
196
raise RuntimeError (f"{ self .invalid_version_from_eng .format (ver = self .MATLAB_VER )} " )
197
+ return (eng_match .group (1 ), eng_match .group (2 ))
198
198
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 ()
199
205
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
-
202
206
return (matlab_ver_major_minor == eng_major_minor )
203
207
204
208
def verify_matlab_release (self , root ):
@@ -250,9 +254,10 @@ def search_path_for_directory_unix(self):
250
254
if self .found_matlab :
251
255
if self .found_matlab in self .VER_TO_REL :
252
256
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.
254
259
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 ]) )
256
261
else :
257
262
raise RuntimeError (self .set_path .format (path1 = self .path_name , arch = self .arch , path2 = self .path_name ))
258
263
@@ -299,7 +304,7 @@ def run(self):
299
304
setup (
300
305
name = "matlabengine" ,
301
306
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
302
- version = "9.11" ,
307
+ version = "9.11.16a0 " ,
303
308
description = 'A module to call MATLAB from Python' ,
304
309
author = 'MathWorks' ,
305
310
license = "MathWorks XSLA License" ,
0 commit comments