Skip to content
Snippets Groups Projects
Commit 245d84c1 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Python/setup: Fixed matlab mexopts generation

parent f01e15b8
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ class DCTSetup(object): ...@@ -22,6 +22,7 @@ class DCTSetup(object):
self.repo_dir = "" self.repo_dir = ""
self.sf_username = "" self.sf_username = ""
self.matlab_ver = "2012a" self.matlab_ver = "2012a"
self.matlab_path = ""
self.gcc_version = "" self.gcc_version = ""
self.git_version = "" self.git_version = ""
...@@ -59,6 +60,12 @@ class DCTSetup(object): ...@@ -59,6 +60,12 @@ class DCTSetup(object):
self.matlab_ver = args[index+1] self.matlab_ver = args[index+1]
else: else:
raise ValueError("Not enough arguments to '-m' option") raise ValueError("Not enough arguments to '-m' option")
elif args[index] == "-mp":
skip_next = True
if len(args) > (index+1):
self.matlab_path = args[index+1]
else:
raise ValueError("Not enough arguments to '-mp' option")
elif args[index] == "--help" or args[index] == "-h": elif args[index] == "--help" or args[index] == "-h":
raise ValueError("") raise ValueError("")
else: else:
...@@ -102,6 +109,7 @@ class DCTSetup(object): ...@@ -102,6 +109,7 @@ class DCTSetup(object):
print(" -d <dir_name> : to specify directory name, where dct will be") print(" -d <dir_name> : to specify directory name, where dct will be")
print(" -u <user_name> : selects developer mode and specifies the developer sf_username") print(" -u <user_name> : selects developer mode and specifies the developer sf_username")
print(" -m <matlab_version> : selects the matlab version to be used") print(" -m <matlab_version> : selects the matlab version to be used")
print(" -mp <matlab_path> : selects the path to matlab (not needed at ESRF)")
def printRepoSummary(self): def printRepoSummary(self):
print("\nGit repository information:") print("\nGit repository information:")
...@@ -128,7 +136,8 @@ class DCTSetup(object): ...@@ -128,7 +136,8 @@ class DCTSetup(object):
self.git_version = platform_utils.checkGitVersion() self.git_version = platform_utils.checkGitVersion()
# platform_utils.checkSvnServers() # platform_utils.checkSvnServers()
self.gcc_version = platform_utils.checkGccVersion() self.gcc_version = platform_utils.checkGccVersion()
platform_utils.checkMatlabGccVersion(self.matlab_ver) platform_utils.checkMatlabGccVersion(matlabVersion = self.matlab_ver, \
matlabPath = self.matlab_path)
def prepareUserEnvironment(self, proxy = ""): def prepareUserEnvironment(self, proxy = ""):
if proxy is not "": if proxy is not "":
...@@ -153,10 +162,14 @@ if __name__ == '__main__': ...@@ -153,10 +162,14 @@ if __name__ == '__main__':
dct_sup.system_type = utils.getSystemDescription() dct_sup.system_type = utils.getSystemDescription()
DCTOutput.printJob("Checking system...") DCTOutput.printJob("Checking system...")
dct_sup.checkSystem(utils) try:
dct_sup.prepareUserEnvironment("proxy.esrf.fr:3128") # assuming ESRF dct_sup.checkSystem(utils)
if dct_sup.sf_username is not "": dct_sup.prepareUserEnvironment("proxy.esrf.fr:3128") # assuming ESRF
dct_sup.prepareDeveloperEnvironment(utils) if dct_sup.sf_username is not "":
dct_sup.prepareDeveloperEnvironment(utils)
except ValueError as ex:
DCTOutput.printError(ex.args)
sys.exit(1)
DCTOutput.printJob("Done.") DCTOutput.printJob("Done.")
dct_sup.printSystemSummary() dct_sup.printSystemSummary()
......
...@@ -62,8 +62,6 @@ class UtilsInterface(object): ...@@ -62,8 +62,6 @@ class UtilsInterface(object):
def checkSvnServers(self): def checkSvnServers(self):
import re
svnservers = self._getSvnServersPath() svnservers = self._getSvnServersPath()
try: try:
...@@ -113,14 +111,16 @@ class UtilsInterface(object): ...@@ -113,14 +111,16 @@ class UtilsInterface(object):
return version_txt return version_txt
def checkMatlabGccVersion(self, matlabVersion, searchPatterns): def checkMatlabGccVersion(self, searchPatterns, matlabVersion, \
import re matlabPath = ""):
import stat import stat
mexoptsfile = self._getMatlabMexoptsPath(matlabVersion) mexoptsfile = self._getMatlabMexoptsPath(matlabVersion)
if os.path.exists(mexoptsfile) is not True: if os.path.exists(mexoptsfile) is not True:
matlabPath = self._getMatlabPath(matlabVersion) if matlabPath is "":
# Try ESRF Paths
matlabPath = self._getMatlabPath(matlabVersion)
self._createMatlabMexopts(matlabPath) self._createMatlabMexopts(matlabPath)
stats = os.stat(mexoptsfile) stats = os.stat(mexoptsfile)
...@@ -177,14 +177,18 @@ class UtilsLinux(UtilsInterface): ...@@ -177,14 +177,18 @@ class UtilsLinux(UtilsInterface):
def _createMatlabMexopts(self, matlabPath): def _createMatlabMexopts(self, matlabPath):
cmd = [os.path.join(matlabPath, "bin", "mex"), "-setup"] cmd = [os.path.join(matlabPath, "bin", "mex"), "-setup"]
subobj = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) try:
subobj.stdin.write("1\n") subobj = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
subobj.wait() subobj.stdin.write("1\n")
subobj.wait()
except OSError as ex:
print(ex.args)
raise ValueError("Error with location: %s\nCheck if it exists!" % cmd[0])
def _getMatlabPath(self, matlabVersion): def _getMatlabPath(self, matlabVersion):
return os.path.join("/sware", "com", "matlab_%s" % matlabVersion) return os.path.join("/sware", "com", "matlab_%s" % matlabVersion)
def checkMatlabGccVersion(self, matlabVersion): def checkMatlabGccVersion(self, matlabVersion, matlabPath = ""):
searchPatterns = [("COPTIMFLAGS='-O -DNDEBUG'", "COPTIMFLAGS='-O -DNDEBUG -fopenmp'"), \ searchPatterns = [("COPTIMFLAGS='-O -DNDEBUG'", "COPTIMFLAGS='-O -DNDEBUG -fopenmp'"), \
("CXXOPTIMFLAGS='-O -DNDEBUG'", "CXXOPTIMFLAGS='-O -DNDEBUG -fopenmp'"), \ ("CXXOPTIMFLAGS='-O -DNDEBUG'", "CXXOPTIMFLAGS='-O -DNDEBUG -fopenmp'"), \
('(CLIBS="\$RPATH \$MLIBS -lm)"', '\g<1> -fopenmp"'), \ ('(CLIBS="\$RPATH \$MLIBS -lm)"', '\g<1> -fopenmp"'), \
...@@ -194,7 +198,10 @@ class UtilsLinux(UtilsInterface): ...@@ -194,7 +198,10 @@ class UtilsLinux(UtilsInterface):
searchPatterns.append(("CC='gcc'", "CC='gcc44'")) searchPatterns.append(("CC='gcc'", "CC='gcc44'"))
searchPatterns.append(("CXX='g\+\+'", "CXX='gcc44'")) searchPatterns.append(("CXX='g\+\+'", "CXX='gcc44'"))
UtilsInterface.checkMatlabGccVersion(self, matlabVersion, searchPatterns) UtilsInterface.checkMatlabGccVersion(self, \
searchPatterns = searchPatterns, \
matlabVersion = matlabVersion, \
matlabPath = matlabPath)
def guessUserRealName(self): def guessUserRealName(self):
username = os.getenv("USER") username = os.getenv("USER")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment