diff --git a/messenger/make.py b/messenger/make.py index fa686be..c4a4456 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: @@ -23,34 +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.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': @@ -72,5 +72,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)