Skip to content

Commit 1c1e561

Browse files
committed
error messages now only mention supported versions; changed version to 9.11.16a0
1 parent 4a2cd1c commit 1c1e561

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The MATLAB® Engine API for Python® provides a package to integrate MATLA
2121
MATLAB Engine API for Python can be installed directly from the Python Package Index.
2222
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
2323
```bash
24-
$ python -m pip install matlabengine==9.11
24+
$ python -m pip install matlabengine==9.11.16a0
2525
```
2626

2727

@@ -46,7 +46,7 @@ setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:matlabroot/bin/glnxa64
4646
MATLAB Engine API for Python can be installed directly from the Python Package Index.
4747
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
4848
```bash
49-
$ python -m pip install matlabengine==9.11
49+
$ python -m pip install matlabengine==9.11.16a0
5050
```
5151

5252
### macOS
@@ -70,7 +70,7 @@ setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:matlabroot/bin/maci64
7070
MATLAB Engine API for Python can be installed directly from the Python Package Index.
7171
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
7272
```bash
73-
$ python -m pip install matlabengine==9.11
73+
$ python -m pip install matlabengine==9.11.16a0
7474
```
7575

7676
---

setup.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class _MatlabFinder(build_py):
2424
MATLAB_REL = 'R2021b'
2525

2626
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
27-
MATLAB_VER = '9.11'
27+
MATLAB_VER = '9.11.16a0'
2828

2929
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3030
SUPPORTED_PYTHON_VERSIONS = set(['3.7', '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:"
@@ -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.11",
307+
version="9.11.16a0",
303308
description='A module to call MATLAB from Python',
304309
author='MathWorks',
305310
license="MathWorks XSLA License",

0 commit comments

Comments
 (0)