Skip to content

Commit 04ffcac

Browse files
committed
9.13.5a1; ported fixes from 9.15.1a8
1 parent b1951dd commit 04ffcac

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
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.13.4
24+
$ python -m pip install matlabengine==9.13.5a1
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.13.4
49+
$ python -m pip install matlabengine==9.13.5a1
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.13.4
73+
$ python -m pip install matlabengine==9.13.5a1
7474
```
7575

7676
---

setup.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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.4'
27+
MATLAB_VER = '9.13.5a1'
2828

2929
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3030
SUPPORTED_PYTHON_VERSIONS = set(['3.8', '3.9', '3.10'])
@@ -47,7 +47,8 @@ class _MatlabFinder(build_py):
4747
path_env_var_name = ''
4848
python_ver = ''
4949
platform = ''
50-
found_matlab = ''
50+
found_matlab_release = ''
51+
found_matlab_version = ''
5152
found_matlab_with_wrong_arch_in_default_install = ''
5253
found_matlab_with_wrong_arch_in_path = ''
5354
verbose = False
@@ -64,8 +65,8 @@ class _MatlabFinder(build_py):
6465
no_compatible_matlab = "No compatible MATLAB installation found in Windows Registry. This release of " + \
6566
"MATLAB Engine API for Python is compatible with version {ver:s}. The found versions were"
6667
no_matlab = "No compatible MATLAB installation found in Windows Registry."
67-
incompatible_ver = "MATLAB version {ver:s} was found, but this release of MATLAB Engine API for Python is not compatible with it. " + \
68-
"To install a compatible version, call python -m pip install matlabengine=={found:s}."
68+
incompatible_ver = "MATLAB version {ver:s} ({rel: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=={ver:s}'."
6970
invalid_version_from_matlab_ver = "Format of MATLAB version '{ver:s}' is invalid."
7071
invalid_version_from_eng = "Format of MATLAB Engine API version '{ver:s}' is invalid."
7172
next_steps = "Reinstall MATLAB, use DYLD_LIBRARY_PATH to specify a different MATLAB installation, or use a different Python interpreter."
@@ -252,7 +253,7 @@ def _find_matlab_key_from_windows_registry(self, key):
252253
if not key_value:
253254
if found_vers:
254255
vers = ', '.join(found_vers)
255-
eng_ver_major_minor = self._get_engine_ver_major_minor()
256+
eng_ver_major_minor = self._get_engine_ver_major_minor(self.MATLAB_VER)
256257
eng_ver_major_minor_as_str = '{}.{}'.format(eng_ver_major_minor[0], eng_ver_major_minor[1])
257258
raise RuntimeError(f"{self.no_compatible_matlab.format(ver=eng_ver_major_minor_as_str)} {vers}.")
258259
else:
@@ -261,9 +262,9 @@ def _find_matlab_key_from_windows_registry(self, key):
261262
self._print_if_verbose(f'_find_matlab_key_from_windows_registry returned: {key_value}')
262263
return key_value
263264

264-
def _get_engine_ver_major_minor(self):
265+
def _get_engine_ver_major_minor(self, id):
265266
re_major_minor = "^(\d+)\.(\d+)"
266-
eng_match = re.match(re_major_minor, self.MATLAB_VER)
267+
eng_match = re.match(re_major_minor, id)
267268
if not eng_match:
268269
raise RuntimeError(f"{self.invalid_version_from_eng.format(ver=self.MATLAB_VER)}")
269270
ret = (eng_match.group(1), eng_match.group(2))
@@ -294,8 +295,10 @@ def verify_matlab_release(self, root):
294295
matlab_release = ''
295296
for child in tree_root:
296297
if child.tag == 'release':
297-
matlab_release = self.found_matlab = child.text
298-
break
298+
matlab_release = self.found_matlab_release = child.text
299+
elif child.tag == 'version':
300+
major, minor = self._get_engine_ver_major_minor(child.text)
301+
self.found_matlab_version = f'{major}.{minor}'
299302
return matlab_release == self.MATLAB_REL
300303

301304
def search_path_for_directory_unix(self, arch, path_dirs):
@@ -326,18 +329,20 @@ def search_path_for_directory_unix(self, arch, path_dirs):
326329

327330
def _err_msg_if_bad_matlab_root(self, matlab_root):
328331
if not matlab_root:
329-
if self.found_matlab:
330-
if self.found_matlab in self.VER_TO_REL:
331-
return self.incompatible_ver.format(ver=self.VER_TO_REL[self.found_matlab], found=self.found_matlab)
332+
if self.found_matlab_version:
333+
self._print_if_verbose(f'self.found_matlab_version: {self.found_matlab_version}; self.VER_TO_REL: {self.VER_TO_REL}')
334+
if self.found_matlab_version in self.VER_TO_REL:
335+
return self.incompatible_ver.format(ver=self.found_matlab_version, rel=self.found_matlab_release)
332336
# Found a MATLAB release but it is older than the oldest version supported,
333337
# or newer than the newest version supported.
334338
else:
335339
v_to_r_keys = list(self.VER_TO_REL.keys())
340+
self._print_if_verbose(f'v_to_r_keys: {v_to_r_keys}')
336341
min_v = v_to_r_keys[0]
337342
min_r = self.VER_TO_REL[min_v]
338343
max_v = v_to_r_keys[-1]
339344
max_r = self.VER_TO_REL[max_v]
340-
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)
345+
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)
341346
else:
342347
# If we reach this line, we assume that the default location has already been checked for an
343348
# appropriate MATLAB installation but none was found.
@@ -408,7 +413,7 @@ def run(self):
408413
setup(
409414
name="matlabengine",
410415
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
411-
version="9.13.4",
416+
version="9.13.5a1",
412417
description='A module to call MATLAB from Python',
413418
author='MathWorks',
414419
license="MathWorks XSLA License",

0 commit comments

Comments
 (0)