#! /usr/bin/env python
import os,subprocess,sys,re,datetime,shutil,glob
-
-install_base_directory=os.path.dirname(os.path.abspath(__file__))
-
-local_archives_path=os.path.join(install_base_directory,"archives")
-
-cmakeLoc=os.path.join(local_archives_path,"cmake-3.0.2.tar.gz")
-pythonLoc=os.path.join(local_archives_path,"Python-2.7.10.tgz")
-hdf5Loc=os.path.join(local_archives_path,"hdf5-1.8.14.tar.gz")
-swigLoc=os.path.join(local_archives_path,"swig-2.0.8.tar.gz")
-qtLoc=os.path.join(local_archives_path,"qt-everywhere-opensource-src-5.5.1.tar.gz")
-medLoc=os.path.join(local_archives_path,"med-3.2.0.tar.gz")
-
-salome_git_repo="https://git.salome-platform.org/gitpub"
-
-medcouplingLoc=(os.path.join(salome_git_repo,"tools","medcoupling.git","76601490"))
-paraviewLoc=("https://github.com/Kitware/ParaView.git","v5.0.0")
-kernelLoc=(os.path.join(salome_git_repo,"modules","kernel.git","49410ad3"))
-guiLoc=(os.path.join(salome_git_repo,"modules","gui.git","792a0f7d"))
-paravisLoc=(os.path.join(salome_git_repo,"modules","paravis.git","314918a6"))
-
-python_version_short="2.7"
-python_version_long="2.7.10"
-swig_version="2.0.8"
-paraview_version="5.0"
+import ConfigParser
+
+current_directory=os.path.dirname(os.path.abspath(__file__))
+
+# Read configuration
+config_filename="SalomeMiniConfig.cfg"
+config = ConfigParser.SafeConfigParser()
+config.optionxform = str # case sensitive
+config.read(os.path.join(current_directory, config_filename))
+# third argument of get: interpolation(0) or raw mode(1)
+cmake_archive=config.get('Prerequisites', 'cmake_archive', 0)
+python_archive=config.get('Prerequisites', 'python_archive', 0)
+hdf5_archive=config.get('Prerequisites', 'hdf5_archive', 0)
+swig_archive=config.get('Prerequisites', 'swig_archive', 0)
+qt_archive=config.get('Prerequisites', 'qt_archive', 0)
+med_archive=config.get('Prerequisites', 'med_archive', 0)
+python_version_short=config.get('Prerequisites', 'python_version_short', 0)
+python_version_long=config.get('Prerequisites', 'python_version_long', 0)
+swig_version=config.get('Prerequisites', 'swig_version', 0)
+paraview_git_repo=config.get('ParaView', 'paraview_git_repo', 0)
+paraview_git_version=config.get('ParaView', 'paraview_git_version', 0)
+paraview_version=config.get('ParaView', 'paraview_version', 0)
+salome_git_repo=config.get('SALOME', 'salome_git_repo', 0)
+medcoupling_version=config.get('SALOME', 'medcoupling_version', 0)
+kernel_version=config.get('SALOME', 'kernel_version', 0)
+gui_version=config.get('SALOME', 'gui_version', 0)
+paravis_version=config.get('SALOME', 'paravis_version', 0)
+make_nb_jobs=config.get('Build options', 'make_nb_jobs', 0)
+
+
+# Prepare build
+local_archives_path=os.path.join(current_directory,"archives")
+
+cmakeLoc=os.path.join(local_archives_path,cmake_archive)
+pythonLoc=os.path.join(local_archives_path,python_archive)
+hdf5Loc=os.path.join(local_archives_path,hdf5_archive)
+swigLoc=os.path.join(local_archives_path,swig_archive)
+qtLoc=os.path.join(local_archives_path,qt_archive)
+medLoc=os.path.join(local_archives_path,med_archive)
+
+paraviewLoc=(paraview_git_repo,paraview_git_version)
+
+medcouplingLoc=(os.path.join(salome_git_repo,"tools","medcoupling.git"),medcoupling_version)
+kernelLoc=(os.path.join(salome_git_repo,"modules","kernel.git"),kernel_version)
+guiLoc=(os.path.join(salome_git_repo,"modules","gui.git"),gui_version)
+paravisLoc=(os.path.join(salome_git_repo,"modules","paravis.git"),paravis_version)
rootDir="SalomeMini"
-#export INSTALL_BASE_DIRECTORY="/local00/home/H87074/TMP46/SalomeMiniForKW/install"
-#PATH=${INSTALL_BASE_DIRECTORY}/cmake-3.0.2/bin:${INSTALL_BASE_DIRECTORY}/Python-2.7.10/bin:${INSTALL_BASE_DIRECTORY}/hdf5-1.8.14/bin:${INSTALL_BASE_DIRECTORY}/swig-2.0.8/bin
-#SWIG_LIB=${INSTALL_BASE_DIRECTORY}/swig-2.0.8/share/swig/2.0.8
-#LD_LIBRARY_PATH=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/lib:${INSTALL_BASE_DIRECTORY}/hdf5-1.8.14/lib
-#PYTHON_VERSION=2.7
-#HDF5HOME=${INSTALL_BASE_DIRECTORY}/hdf5-1.8.14
-#SWIG_ROOT_DIR=${INSTALL_BASE_DIRECTORY}/swig-2.0.8
-#PYTHONSTARTUP=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/pythonrc.py
-#PYTHONHOME=${INSTALL_BASE_DIRECTORY}/Python-2.7.10
-#PYTHON_INCLUDE=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/include/python2.7
-#HDF5_DISABLE_VERSION_CHECK=1
-
-def generateRuntimeEnviron():
- file = open('runTimeEnviron.sh', 'w')
- file.write('export INSTALL_BASE_DIRECTORY="%s"\n'%os.path.join(install_base_directory,rootDir,"install"))
- file.write('export PATH=${INSTALL_BASE_DIRECTORY}/cmake-3.0.2/bin:${PATH}\n')
- file.write('export PATH=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/bin:${PATH}\n')
- file.write('export PATH=${INSTALL_BASE_DIRECTORY}/hdf5-1.8.14/bin:${PATH}\n')
- file.write('export PATH=${INSTALL_BASE_DIRECTORY}/swig-2.0.8/bin:${PATH}\n')
- file.write('export SWIG_LIB=${INSTALL_BASE_DIRECTORY}/swig-2.0.8/share/swig/2.0.8\n')
- file.write('export LD_LIBRARY_PATH=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/lib:${LD_LIBRARY_PATH}\n')
- file.write('export LD_LIBRARY_PATH=${INSTALL_BASE_DIRECTORY}/hdf5-1.8.14/lib:${LD_LIBRARY_PATH}\n')
- file.write('export PYTHON_VERSION=%s\n'%python_version_short)
- file.write('export HDF5HOME=${INSTALL_BASE_DIRECTORY}/hdf5-1.8.14\n')
- file.write('export SWIG_ROOT_DIR=${INSTALL_BASE_DIRECTORY}/swig-2.0.8\n')
- file.write('export PYTHONSTARTUP=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/pythonrc.py:${PYTHONSTARTUP}\n')
- file.write('export PYTHONHOME=${INSTALL_BASE_DIRECTORY}/Python-2.7.10\n')
- file.write('export PYTHON_INCLUDE=${INSTALL_BASE_DIRECTORY}/Python-2.7.10/include/python2.7\n')
- file.write('export HDF5_DISABLE_VERSION_CHECK=1\n')
- file.close()
- pass
-
-paraCompFlag="-j8"
-cfgOut="config_out.txt"
-cfgErr="config_err.txt"
-compOut="compile_out.txt"
-compErr="compile_err.txt"
+paraCompFlag="-j%s"%make_nb_jobs
+cfgOut="config_out.log"
+cfgErr="config_err.log"
+compOut="compile_out.log"
+compErr="compile_err.log"
okFlag=".install_ok"
def cmake_Environ(installDir,envAcc):
os.chdir("..")
def extractSrcFromArchive(srcLoc,srcDir,pattern):
+ print "Extracting archive: ", srcLoc
tmpDir="tmp"
zz=AutoChdir(srcDir)
if os.path.exists(tmpDir):
return ret
def extractSrcFromGit(gitLoc,srcDir,pattern):
+ print "Connecting to git repository: ", gitLoc[0]
zz=AutoChdir(srcDir)
assert(isinstance(gitLoc,tuple))
assert(len(gitLoc)==2)
ret=os.path.realpath(os.path.join(os.getcwd(),dirGitLoc))
if not os.path.exists(dirGitLoc):
print("Cloning %s..."%dirGitLoc)
- p=subprocess.Popen(["git","clone",gitLoc[0]],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
- p.communicate()
- assert(p.returncode==0)
+ def __connect():
+ p=subprocess.Popen(["git","clone",gitLoc[0]],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+ p_out,p_err=p.communicate()
+ return p.returncode, p_out, p_err
+ tries=0
+ while True:
+ _status,_out,_err = __connect()
+ if _status == 0 or tries > 1:
+ break
+ print _out
+ print _err
+ print "Try again"
+ tries = tries+1
+ pass
+ assert(_status==0)
else:
assert(os.path.exists(os.path.join(dirGitLoc,".git")))
p=subprocess.Popen(["git","checkout",gitLoc[1]],cwd=dirGitLoc,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
f=file(envFile,"w")
f.write(generateFileEnv(envAcc)) ; f.flush() ; del f
print("Env file generated : %s"%envFile)
-
-generateRuntimeEnviron()