From d8b3a82c45d6d02d53bb52873159e55b45513357 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Fri, 23 Jan 2015 16:40:02 -0500 Subject: [PATCH 1/4] messenger/make.py: Changed if to elif in platform check for win32. If it's win32, it won't be one of the others. Closes #110. --- messenger/make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger/make.py b/messenger/make.py index fa686be..f0b8e77 100755 --- a/messenger/make.py +++ b/messenger/make.py @@ -14,7 +14,7 @@ messenger_dir = 'mexa64' elif platform.startswith('darwin'): messenger_dir = 'mexmaci64' -if platform.startswith('win32'): +elif platform.startswith('win32'): # We further need to differniate 32 from 64 bit: maxint = sys.maxint() if maxint == 9223372036854775807: From 3c7a8253f8d46a4d8362b50a0de762489bdab30c Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Fri, 23 Jan 2015 16:15:31 -0500 Subject: [PATCH 2/4] messenger/make.py: Corrected to decode str as opposed to trying to decode a file, which is not allowed. Closes #108. --- messenger/make.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/messenger/make.py b/messenger/make.py index f0b8e77..f42d9d1 100755 --- a/messenger/make.py +++ b/messenger/make.py @@ -25,7 +25,8 @@ # Open the configure file and start parsing config = open(os.path.join(messenger_dir, 'local.cfg'), 'r') -for line in config.decode('utf-8'): +for line in config: + line = line.decode('utf-8') path = line.split('=') if path[0] == "MATLAB_BIN": From 287d2fbfe62f982c38e1dd951bbd55bf56941b42 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Fri, 23 Jan 2015 16:34:25 -0500 Subject: [PATCH 3/4] messenger/make.py: In order to be able to move and replace an existing file, the full path to the file must be specified. Closes #109. --- messenger/make.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/messenger/make.py b/messenger/make.py index f42d9d1..5f90727 100755 --- a/messenger/make.py +++ b/messenger/make.py @@ -73,5 +73,8 @@ make_cmd = '"' + matlab_bin + mex + '"' + " -O -I" + header_path + " -L" + lib_path + " -lzmq ./src/messenger.c" os.system(make_cmd) -shutil.move('messenger.%s'%extension, messenger_dir) +messenger_exe = 'messenger.%s'%extension +messenger_loc = os.path.join(messenger_dir, messenger_exe) + +shutil.move(messenger_exe, messenger_loc) From c365c5374b6a7d2840348e8d1c91037cea641311 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Fri, 23 Jan 2015 18:08:31 -0500 Subject: [PATCH 4/4] messenger/make.py: Use with block instead of explicitly opening and closing the file. This is better for error handling should it be required. Closes #107. --- messenger/make.py | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/messenger/make.py b/messenger/make.py index 5f90727..c4a4456 100755 --- a/messenger/make.py +++ b/messenger/make.py @@ -23,35 +23,34 @@ messenger_dir = 'mexw32' # Open the configure file and start parsing -config = open(os.path.join(messenger_dir, 'local.cfg'), 'r') +with open(os.path.join(messenger_dir, 'local.cfg'), 'r') as config: + for line in config: + line = line.decode('utf-8') + path = line.split('=') -for line in config: - line = line.decode('utf-8') - path = line.split('=') + if path[0] == "MATLAB_BIN": + print("Searching for Matlab bin folder in local.cfg ...") + matlab_bin = path[1].rstrip('\r\n') + if matlab_bin == "": + raise ValueError("Could not find Matlab bin folder. Please add it to local.cfg") + print("Matlab found in " + matlab_bin) - if path[0] == "MATLAB_BIN": - print("Searching for Matlab bin folder in local.cfg ...") - matlab_bin = path[1].rstrip('\r\n') - if matlab_bin == "": - raise ValueError("Could not find Matlab bin folder. Please add it to local.cfg") - print("Matlab found in " + matlab_bin) + elif path[0] == "HEADER_PATH": + print("Searching for zmq.h in local.cfg ...") + header_path = path[1].rstrip('\r\n') + if header_path == "": + raise ValueError("Could not find zmq.h. Please add its path to local.cfg") + print("zmq.h found in " + header_path) - elif path[0] == "HEADER_PATH": - print("Searching for zmq.h in local.cfg ...") - header_path = path[1].rstrip('\r\n') - if header_path == "": - raise ValueError("Could not find zmq.h. Please add its path to local.cfg") - print("zmq.h found in " + header_path) + elif path[0] == "LIB_PATH": + print("Searching for zmq library in local.cfg ...") + lib_path = path[1].rstrip('\r\n') + if lib_path == "": + raise ValueError("Could not find zmq library. Please add its path to local.cfg") - elif path[0] == "LIB_PATH": - print("Searching for zmq library in local.cfg ...") - lib_path = path[1].rstrip('\r\n') - if lib_path == "": - raise ValueError("Could not find zmq library. Please add its path to local.cfg") + print("zmq library found in " + lib_path) - print("zmq library found in " + lib_path) -config.close() # Get the extension if platform == 'win32':