3
3
from setuptools import setup , find_packages
4
4
from setuptools .command .build_py import build_py
5
5
import os
6
- import pdb
7
6
import re
8
7
import sys
9
8
import platform
@@ -25,7 +24,7 @@ class _MatlabFinder(build_py):
25
24
MATLAB_REL = 'R2022b'
26
25
27
26
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
28
- MATLAB_VER = '9.13.3a8 '
27
+ MATLAB_VER = '9.13.3a9 '
29
28
30
29
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
31
30
SUPPORTED_PYTHON_VERSIONS = set (['3.8' , '3.9' , '3.10' ])
@@ -51,10 +50,11 @@ class _MatlabFinder(build_py):
51
50
found_matlab = ''
52
51
found_matlab_with_wrong_arch_in_default_install = ''
53
52
found_matlab_with_wrong_arch_in_path = ''
53
+ verbose = True
54
54
55
55
# ERROR MESSAGES
56
56
minimum_maximum = "No compatible version of MATLAB was found. " + \
57
- "This feature supports MATLAB {min_v:s} ({min_r:s}) through {max_v:s} ({max_r:s}), inclusive."
57
+ "Version {this_v:s} was found, but this feature only supports MATLAB {min_v:s} ({min_r:s}) through {max_v:s} ({max_r:s}), inclusive."
58
58
dir_not_found = "Directory not found: "
59
59
no_windows_install = "MATLAB installation not found in Windows Registry:"
60
60
unsupported_platform = "{platform:s} is not a supported platform."
@@ -72,6 +72,10 @@ class _MatlabFinder(build_py):
72
72
wrong_arch_in_default_install = "MATLAB installation in {path1:s} is {matlab_arch:s}, but Python interpreter is {python_arch:s}. {next_steps:s}."
73
73
wrong_arch_in_path = "MATLAB installation in {path1:s}, listed in DYLD_LIBRARY_PATH, is {matlab_arch:s}, but Python interpreter is {python_arch:s}. {next_steps:s}."
74
74
75
+ def _print_if_verbose (self , msg ):
76
+ if self .verbose :
77
+ print (msg )
78
+
75
79
def set_platform_and_arch (self ):
76
80
"""
77
81
Sets the platform and architecture.
@@ -150,7 +154,8 @@ def _create_path_list(self):
150
154
raise RuntimeError (self .install_or_set_path .format (
151
155
ver = self .MATLAB_REL , arch = self .arch ,
152
156
path = self .path_env_var_name ))
153
-
157
+
158
+ self ._print_if_verbose (f'_create_path_list returned: { path_dirs } ' )
154
159
return path_dirs
155
160
156
161
def _get_alternate_arch (self ):
@@ -191,7 +196,7 @@ def _get_matlab_root_from_unix_bin(self, dir):
191
196
found_matlab_with_wrong_arch_in_path = possible_root
192
197
else :
193
198
matlab_root = possible_root
194
-
199
+ self . _print_if_verbose ( f'_get_matlab_root_from_unix_bin returned: { matlab_root } ' )
195
200
return matlab_root
196
201
197
202
def get_matlab_root_from_windows_reg (self ):
@@ -205,7 +210,9 @@ def get_matlab_root_from_windows_reg(self):
205
210
raise RuntimeError (f"{ self .no_windows_install } { err } " )
206
211
207
212
matlab_ver_key = self ._find_matlab_key_from_windows_registry (key )
208
- return self ._get_root_from_version_key (reg , matlab_ver_key )
213
+ ret = self ._get_root_from_version_key (reg , matlab_ver_key )
214
+ self ._print_if_verbose (f'get_matlab_root_from_windows_reg returned: { ret } ' )
215
+ return ret
209
216
210
217
def _get_root_from_version_key (self , reg , ver_key ):
211
218
"""
@@ -218,6 +225,7 @@ def _get_root_from_version_key(self, reg, ver_key):
218
225
except (OSError , FileNotFoundError ) as err :
219
226
raise RuntimeError (f"{ self .no_windows_install } { err } " )
220
227
228
+ self ._print_if_verbose (f'_get_root_from_version_key returned: { matlab_root } ' )
221
229
return matlab_root
222
230
223
231
def _find_matlab_key_from_windows_registry (self , key ):
@@ -248,14 +256,17 @@ def _find_matlab_key_from_windows_registry(self, key):
248
256
else :
249
257
raise RuntimeError (f"{ self .no_matlab } " )
250
258
259
+ self ._print_if_verbose (f'_find_matlab_key_from_windows_registry returned: { key_value } ' )
251
260
return key_value
252
261
253
262
def _get_engine_ver_major_minor (self ):
254
263
re_major_minor = "^(\d+)\.(\d+)"
255
264
eng_match = re .match (re_major_minor , self .MATLAB_VER )
256
265
if not eng_match :
257
266
raise RuntimeError (f"{ self .invalid_version_from_eng .format (ver = self .MATLAB_VER )} " )
258
- return (eng_match .group (1 ), eng_match .group (2 ))
267
+ ret = (eng_match .group (1 ), eng_match .group (2 ))
268
+ self ._print_if_verbose (f'_get_engine_ver_major_minor returned: { ret } ' )
269
+ return ret
259
270
260
271
def _check_matlab_ver_against_engine (self , matlab_ver ):
261
272
re_major_minor = "^(\d+)\.(\d+)"
@@ -308,7 +319,7 @@ def search_path_for_directory_unix(self, arch, path_dirs):
308
319
matlab_root = self ._get_matlab_root_from_unix_bin (path )
309
320
ending_idx += 1
310
321
dir_idx += 1
311
-
322
+ self . _print_if_verbose ( f'search_path_for_directory_unix returned: { matlab_root } ' )
312
323
return matlab_root
313
324
314
325
def _err_msg_if_bad_matlab_root (self , matlab_root ):
@@ -324,7 +335,7 @@ def _err_msg_if_bad_matlab_root(self, matlab_root):
324
335
min_r = self .VER_TO_REL [min_v ]
325
336
max_v = v_to_r_keys [- 1 ]
326
337
max_r = self .VER_TO_REL [max_v ]
327
- return self .minimum_maximum .format (min_v = min_v , min_r = min_r , max_v = max_v , max_r = max_r )
338
+ 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 )
328
339
else :
329
340
# If we reach this line, we assume that the default location has already been checked for an
330
341
# appropriate MATLAB installation but none was found.
@@ -357,7 +368,6 @@ def run(self):
357
368
self .set_platform_and_arch ()
358
369
self .set_python_version ()
359
370
360
- pdb .set_trace ()
361
371
if self .platform == 'Windows' :
362
372
matlab_root = self .get_matlab_root_from_windows_reg ()
363
373
else :
@@ -396,7 +406,7 @@ def run(self):
396
406
setup (
397
407
name = "matlabengine" ,
398
408
# MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
399
- version = "9.13.3a8 " ,
409
+ version = "9.13.3a9 " ,
400
410
description = 'A module to call MATLAB from Python' ,
401
411
author = 'MathWorks' ,
402
412
license = "MathWorks XSLA License" ,
0 commit comments