Skip to content

Commit 0360616

Browse files
committed
R2021a 9.10.1a0
1 parent 3330082 commit 0360616

4 files changed

Lines changed: 28 additions & 171 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ The MATLAB® Engine API for Python® provides a package to integrate MATLA
66
## Requirements
77
### Required MathWorks Products
88
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
9-
* MATLAB release R2021b
9+
* MATLAB release R2021a
1010

1111
### Required 3rd Party Products
1212
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
13-
* Python 3.7, 3.8, or 3.9
13+
* Python 3.7 or 3.8
1414
* Supported Python versions by MATLAB release can be found [here](https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/python-compatibility.pdf).
1515

1616
---
@@ -21,15 +21,15 @@ The MATLAB&reg; Engine API for Python&reg; 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.19a5
24+
$ python -m pip install matlabengine==9.10.1a0
2525
```
2626

2727

2828

2929
### Linux&reg;
3030
Prior to installation, check the default install location of MATLAB by calling ```matlabroot``` in a MATLAB Command Window. By default, Linux installs MATLAB at:<br>
3131
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
32-
```/usr/local/MATLAB/R2021b```
32+
```/usr/local/MATLAB/R2021a```
3333

3434
When MATLAB is not installed in the default location, the bin/*architecture* directory within the MATLAB root directory must be added to an environment variable. The path can be added to the environment variable within the shell startup configuration file (for example, .bashrc for bash shell or .tcshrc for tcsh).
3535

@@ -46,14 +46,14 @@ 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.19a5
49+
$ python -m pip install matlabengine==9.10.1a0
5050
```
5151

5252
### macOS
5353
Prior to installation, check the default install location of MATLAB by calling ```matlabroot``` in a MATLAB Command Window. By default, macOS installs MATLAB at:<br>
5454

5555
<!-- MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string) -->
56-
```/Applications/MATLAB_R2021b.app```
56+
```/Applications/MATLAB_R2021a.app```
5757

5858
When MATLAB is not installed in the default location, the bin/*architecture* directory within the MATLAB root directory must be added to an environment variable. The path can be added to the environment variable within the shell startup configuration file (for example, .bashrc for bash shell or .tcshrc for tcsh).
5959

@@ -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.19a5
73+
$ python -m pip install matlabengine==9.10.1a0
7474
```
7575

7676
---

setup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ 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.19a5'
27+
MATLAB_VER = '9.10.1a0'
2828

2929
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
30-
SUPPORTED_PYTHON_VERSIONS = set(['3.7', '3.8', '3.9'])
30+
SUPPORTED_PYTHON_VERSIONS = set(['3.7', '3.8'])
3131

3232
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3333
VER_TO_REL = {
@@ -61,7 +61,8 @@ 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 MATLAB Engine API for Python is not compatible with it. " + \
65+
"To install a compatible version, call python -m pip install matlabengine=={found:s}."
6566
invalid_version_from_matlab_ver = "Format of MATLAB version '{ver:s}' is invalid."
6667
invalid_version_from_eng = "Format of MATLAB Engine API version '{ver:s}' is invalid."
6768

@@ -308,7 +309,7 @@ def run(self):
308309
setup(
309310
name="matlabengine",
310311
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
311-
version="9.11.19a5",
312+
version="9.10.1a0",
312313
description='A module to call MATLAB from Python',
313314
author='MathWorks',
314315
license="MathWorks XSLA License",
@@ -334,9 +335,8 @@ def run(self):
334335
"Intended Audience :: Developers",
335336
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
336337
"Programming Language :: Python :: 3.7",
337-
"Programming Language :: Python :: 3.8",
338-
"Programming Language :: Python :: 3.9"
338+
"Programming Language :: Python :: 3.8"
339339
],
340340
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
341-
python_requires=">=3.7, <3.10"
341+
python_requires=">=3.7, <3.9"
342342
)

src/matlab/__init__.py

Lines changed: 7 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 MathWorks, Inc.
1+
# Copyright 2014-2015 MathWorks, Inc.
22
"""
33
Array interface between Python and MATLAB.
44
@@ -9,152 +9,19 @@
99
Modules
1010
-------
1111
* mlarray - type-specific multidimensional array classes for working
12-
with MATLAB, implemented in Python
13-
* mcpyarray - type-specific multidimensional array classes for working
14-
with MATLAB, implemented in C++
15-
* mlexceptions - exceptions raised when manipulating mlarray objects
12+
with MATLAB
13+
* mlexceptions - exceptions raised manipulating mlarray objects
1614
"""
1715

1816
import os
1917
import sys
20-
21-
# These can be removed once we no longer use _MiniPathInitializer.
22-
import platform
23-
import re
24-
2518
from pkgutil import extend_path
2619
__path__ = extend_path(__path__, '__name__')
2720

2821
_package_folder = os.path.dirname(os.path.realpath(__file__))
2922
sys.path.append(_package_folder)
3023

31-
# This code allows us to:
32-
# (1) switch from a pure Python ("mlarray") to a C++ extension ("mcpyarray")
33-
# implementation by setting the environment variable USE_MCPYARRAY to 1
34-
# (2) put the proper extern/bin/<arch> directory on the Python path to avoid
35-
# a situation in which some shared libraries are loaded from a MATLAB while
36-
# others are loaded from a runtime. The first directory on the path that contains
37-
# the string "bin/<arch>" (with the proper directory separator)
38-
# will be checked. If it is "extern/bin/<arch>", it will be used as the
39-
# extern/bin/<arch> directory. Otherwise, we'll go up two directories and down
40-
# to extern/bin/<arch>.
41-
class _MiniPathInitializer(object):
42-
PLATFORM_DICT = {'Windows': 'PATH', 'Linux': 'LD_LIBRARY_PATH', 'Darwin': 'DYLD_LIBRARY_PATH'}
43-
44-
def __init__(self):
45-
self.arch = ''
46-
self.extern_bin_dir = ''
47-
self.path_var = ''
48-
self.system = ''
49-
self.use_mcpyarray = False
50-
if os.environ.get('USE_MCPYARRAY') and os.environ['USE_MCPYARRAY'] == '1':
51-
self.use_mcpyarray = True
52-
53-
def get_platform_info(self):
54-
"""Ask Python for the platform and architecture."""
55-
# This will return 'Windows', 'Linux', or 'Darwin' (for Mac).
56-
self.system = platform.system()
57-
if not self.system in _MiniPathInitializer.PLATFORM_DICT:
58-
raise RuntimeError('{0} is not a supported platform.'.format(self.system))
59-
else:
60-
# path_var is the OS-dependent name of the path variable ('PATH', 'LD_LIBRARY_PATH', "DYLD_LIBRARY_PATH')
61-
self.path_var = _MiniPathInitializer.PLATFORM_DICT[self.system]
62-
63-
if self.system == 'Windows':
64-
self.arch = 'win64'
65-
elif self.system == 'Linux':
66-
self.arch = 'glnxa64'
67-
elif self.system == 'Darwin':
68-
self.arch = 'maci64'
69-
else:
70-
raise RuntimeError('Operating system {0} is not supported.'.format(self.system))
71-
72-
def is_extern_bin_on_py_sys_path(self):
73-
#Retrieve Python sys.path as a single string, and search for the substring "extern/bin/<arch>" (with
74-
#the proper directory separator). If it's already present, assume it's the one we want.
75-
substr_to_find = os.path.join('extern', 'bin', self.arch)
76-
for item in sys.path:
77-
if item.find(substr_to_find) != -1:
78-
return True
79-
return False
80-
81-
def put_extern_bin_on_py_sys_path(self):
82-
"""
83-
Look through the system path for the first directory ending with "runtime/<arch>" or
84-
"bin/<arch>" (with/without trailing slash). Use this to construct a new path ending
85-
with "extern/bin/<arch>".
86-
"""
87-
88-
path_elements = []
89-
if self.path_var in os.environ:
90-
path_elements_orig = os.environ[self.path_var]
91-
# On Windows, some elements of the path may use forward slashes while others use backslashes.
92-
# Make them all backslashes.
93-
if self.system == 'Windows':
94-
path_elements_orig = path_elements_orig.replace('/', '\\')
95-
path_elements = path_elements_orig.split(os.pathsep)
96-
if not path_elements:
97-
if self.system == 'Darwin':
98-
raise RuntimeError('On the Mac, you must run mwpython rather than python ' +
99-
'to start a session or script that imports your package. ' +
100-
'For more details, execute "mwpython -help" or see the package documentation.')
101-
else:
102-
raise RuntimeError('On {0}, you must set the environment variable "{1}" to a non-empty string. {2}'.format(
103-
self.system, self.path_var,
104-
'For more details, see the package documentation.'))
105-
106-
dir_to_search = os.path.join('runtime', self.arch)
107-
trailing_substrings_to_find = [dir_to_search, dir_to_search + os.sep]
108-
109-
dir_found = ''
110-
for elem in path_elements:
111-
for trailing_substring in trailing_substrings_to_find:
112-
if elem.endswith(trailing_substring):
113-
dir_found = elem
114-
break
115-
if dir_found:
116-
break
117-
118-
if not dir_found:
119-
raise RuntimeError('Could not find an appropriate directory in {0} from which to read binaries.'.format(
120-
self.path_var))
121-
122-
path_components = dir_found.split(os.sep)
123-
124-
if path_components[-1]:
125-
last_path_component = path_components[-1]
126-
possible_extern = -3
127-
else:
128-
# The directory name ended with a slash, so the last item in the list was an empty string. Go back one more.
129-
last_path_component = path_components[-2]
130-
possible_extern = -4
131-
132-
if last_path_component != self.arch:
133-
output_str = ''.join(('To call deployed MATLAB code on a {0} machine, you must run a {0} version of Python, ',
134-
'and your {1} variable must contain an element pointing to "<MR>{2}runtime{2}{0}", ',
135-
'where "<MR>" indicates a MATLAB or MATLAB Runtime root. ',
136-
'Instead, the value found was as follows: {3}'))
137-
raise RuntimeError(output_str.format(self.arch, self.path_var, os.sep, dir_found))
138-
139-
if (len(path_components) + possible_extern) >= 0 and path_components[possible_extern] == 'extern':
140-
extern_bin_dir = dir_found
141-
else:
142-
mroot = os.path.dirname(os.path.dirname(os.path.normpath(dir_found)))
143-
extern_bin_dir = os.path.join(mroot, 'extern', 'bin', self.arch)
144-
if not os.path.isdir(extern_bin_dir):
145-
raise RuntimeError('Could not find the directory {0}'.format(extern_bin_dir))
146-
self.extern_bin_dir = extern_bin_dir
147-
sys.path.insert(0, self.extern_bin_dir)
148-
149-
_mpi = _MiniPathInitializer()
150-
if _mpi.use_mcpyarray:
151-
_mpi.get_platform_info()
152-
if not _mpi.is_extern_bin_on_py_sys_path():
153-
_mpi.put_extern_bin_on_py_sys_path()
154-
from matlabmultidimarrayforpython import double, single, uint8, int8, uint16, \
155-
int16, uint32, int32, uint64, int64, logical, ShapeError, SizeError
156-
else:
157-
from mlarray import double, single, uint8, int8, uint16, \
158-
int16, uint32, int32, uint64, int64, logical
159-
from mlexceptions import ShapeError as ShapeError
160-
from mlexceptions import SizeError as SizeError
24+
from mlarray import double, single, uint8, int8, uint16, \
25+
int16, uint32, int32, uint64, int64, logical
26+
from mlexceptions import ShapeError as ShapeError
27+
from mlexceptions import SizeError as SizeError

src/matlab/engine/__init__.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Copyright 2014-2021 MathWorks, Inc.
1+
#Copyright 2014-2020 MathWorks, Inc.
22

33
"""
44
The MATLAB Engine enables you to call any MATLAB statement either synchronously
@@ -28,7 +28,7 @@
2828

2929
# UPDATE_IF_PYTHON_VERSION_ADDED_OR_REMOVED : search for this string in codebase
3030
# when support for a Python version must be added or removed
31-
_supported_versions = ['2_7', '3_7', '3_8', '3_9']
31+
_supported_versions = ['2_7', '3_7', '3_8']
3232
_ver = sys.version_info
3333
_version = '{0}_{1}'.format(_ver[0], _ver[1])
3434
_PYTHONVERSION = None
@@ -40,15 +40,10 @@
4040

4141
_module_folder = os.path.dirname(os.path.realpath(__file__))
4242
_arch_filename = os.path.join(_module_folder, "_arch.txt")
43-
success = False
44-
firstExceptionMessage = ''
45-
secondExceptionMessage = ''
43+
4644
try:
4745
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
48-
except Exception as firstE:
49-
firstExceptionMessage = str(firstE)
50-
51-
if firstExceptionMessage:
46+
except:
5247
try:
5348
_arch_file = open(_arch_filename,'r')
5449
_lines = _arch_file.readlines()
@@ -67,14 +62,9 @@
6762
if sys.version_info.major >= 3 and sys.version_info.minor >= 8:
6863
os.add_dll_directory(_bin_dir)
6964
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
70-
except Exception as secondE:
71-
str1 = 'Please reinstall MATLAB Engine for Python or contact '
72-
str2 = 'MathWorks Technical Support for assistance:\nFirst issue: {}\nSecond issue: {}'.format(
73-
firstExceptionMessage, secondE)
74-
secondExceptionMessage = str1 + str2
75-
76-
if secondExceptionMessage:
77-
raise EnvironmentError(secondExceptionMessage)
65+
except Exception as e:
66+
raise EnvironmentError('Please reinstall MATLAB Engine for Python or contact '
67+
'MathWorks Technical Support for assistance: %s' % e)
7868

7969

8070
"""

0 commit comments

Comments
 (0)