33from setuptools import setup , find_packages
44from setuptools .command .build_py import build_py
55import os
6- import pdb
76import re
87import sys
98import platform
@@ -25,7 +24,7 @@ class _MatlabFinder(build_py):
2524 MATLAB_REL = 'R2022b'
2625
2726 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
28- MATLAB_VER = '9.13.3a8 '
27+ MATLAB_VER = '9.13.3a9 '
2928
3029 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
3130 SUPPORTED_PYTHON_VERSIONS = set (['3.8' , '3.9' , '3.10' ])
@@ -51,10 +50,11 @@ class _MatlabFinder(build_py):
5150 found_matlab = ''
5251 found_matlab_with_wrong_arch_in_default_install = ''
5352 found_matlab_with_wrong_arch_in_path = ''
53+ verbose = True
5454
5555 # ERROR MESSAGES
5656 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."
5858 dir_not_found = "Directory not found: "
5959 no_windows_install = "MATLAB installation not found in Windows Registry:"
6060 unsupported_platform = "{platform:s} is not a supported platform."
@@ -72,6 +72,10 @@ class _MatlabFinder(build_py):
7272 wrong_arch_in_default_install = "MATLAB installation in {path1:s} is {matlab_arch:s}, but Python interpreter is {python_arch:s}. {next_steps:s}."
7373 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}."
7474
75+ def _print_if_verbose (self , msg ):
76+ if self .verbose :
77+ print (msg )
78+
7579 def set_platform_and_arch (self ):
7680 """
7781 Sets the platform and architecture.
@@ -150,7 +154,8 @@ def _create_path_list(self):
150154 raise RuntimeError (self .install_or_set_path .format (
151155 ver = self .MATLAB_REL , arch = self .arch ,
152156 path = self .path_env_var_name ))
153-
157+
158+ self ._print_if_verbose (f'_create_path_list returned: { path_dirs } ' )
154159 return path_dirs
155160
156161 def _get_alternate_arch (self ):
@@ -191,7 +196,7 @@ def _get_matlab_root_from_unix_bin(self, dir):
191196 found_matlab_with_wrong_arch_in_path = possible_root
192197 else :
193198 matlab_root = possible_root
194-
199+ self . _print_if_verbose ( f'_get_matlab_root_from_unix_bin returned: { matlab_root } ' )
195200 return matlab_root
196201
197202 def get_matlab_root_from_windows_reg (self ):
@@ -205,7 +210,9 @@ def get_matlab_root_from_windows_reg(self):
205210 raise RuntimeError (f"{ self .no_windows_install } { err } " )
206211
207212 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
209216
210217 def _get_root_from_version_key (self , reg , ver_key ):
211218 """
@@ -218,6 +225,7 @@ def _get_root_from_version_key(self, reg, ver_key):
218225 except (OSError , FileNotFoundError ) as err :
219226 raise RuntimeError (f"{ self .no_windows_install } { err } " )
220227
228+ self ._print_if_verbose (f'_get_root_from_version_key returned: { matlab_root } ' )
221229 return matlab_root
222230
223231 def _find_matlab_key_from_windows_registry (self , key ):
@@ -248,14 +256,17 @@ def _find_matlab_key_from_windows_registry(self, key):
248256 else :
249257 raise RuntimeError (f"{ self .no_matlab } " )
250258
259+ self ._print_if_verbose (f'_find_matlab_key_from_windows_registry returned: { key_value } ' )
251260 return key_value
252261
253262 def _get_engine_ver_major_minor (self ):
254263 re_major_minor = "^(\d+)\.(\d+)"
255264 eng_match = re .match (re_major_minor , self .MATLAB_VER )
256265 if not eng_match :
257266 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
259270
260271 def _check_matlab_ver_against_engine (self , matlab_ver ):
261272 re_major_minor = "^(\d+)\.(\d+)"
@@ -308,7 +319,7 @@ def search_path_for_directory_unix(self, arch, path_dirs):
308319 matlab_root = self ._get_matlab_root_from_unix_bin (path )
309320 ending_idx += 1
310321 dir_idx += 1
311-
322+ self . _print_if_verbose ( f'search_path_for_directory_unix returned: { matlab_root } ' )
312323 return matlab_root
313324
314325 def _err_msg_if_bad_matlab_root (self , matlab_root ):
@@ -324,7 +335,7 @@ def _err_msg_if_bad_matlab_root(self, matlab_root):
324335 min_r = self .VER_TO_REL [min_v ]
325336 max_v = v_to_r_keys [- 1 ]
326337 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 )
328339 else :
329340 # If we reach this line, we assume that the default location has already been checked for an
330341 # appropriate MATLAB installation but none was found.
@@ -357,7 +368,6 @@ def run(self):
357368 self .set_platform_and_arch ()
358369 self .set_python_version ()
359370
360- pdb .set_trace ()
361371 if self .platform == 'Windows' :
362372 matlab_root = self .get_matlab_root_from_windows_reg ()
363373 else :
@@ -396,7 +406,7 @@ def run(self):
396406 setup (
397407 name = "matlabengine" ,
398408 # MUST_BE_UPDATED_EACH_RELEASE (Search repo for this string)
399- version = "9.13.3a8 " ,
409+ version = "9.13.3a9 " ,
400410 description = 'A module to call MATLAB from Python' ,
401411 author = 'MathWorks' ,
402412 license = "MathWorks XSLA License" ,
0 commit comments