From 05a3638b44cfd058a0053ab6474dbb3646e74da0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 3 Feb 2016 18:16:19 +0100 Subject: [PATCH] no hard-coded absolute path --- scripts/BuildSalomeMini.py | 117 +++++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 36 deletions(-) diff --git a/scripts/BuildSalomeMini.py b/scripts/BuildSalomeMini.py index 3621ba3..c594f7d 100755 --- a/scripts/BuildSalomeMini.py +++ b/scripts/BuildSalomeMini.py @@ -2,20 +2,63 @@ import os,subprocess,sys,re,datetime,shutil,glob -rootDir="SalomeMini" -cmakeLoc="/home/H87074/salome/archives/cmake-3.0.2.tar.gz" -pythonLoc="/home/H87074/salome/archives/Python-2.7.10.tgz" -hdf5Loc="/home/H87074/salome/archives/hdf5-1.8.14.tar.gz" -swigLoc="/home/H87074/salome/archives/swig-2.0.8.tar.gz" -qtLoc="/home/H87074/salome/archives/qt-everywhere-opensource-src-5.5.1.tar.gz" -medLoc="/home/H87074/salome/archives/med-3.2.0rc1.tar.bz2" -medcouplingLoc=("https://git.salome-platform.org/gitpub/tools/medcoupling.git","0b7cacaa925") +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=("https://git.salome-platform.org/gitpub/modules/kernel.git","f64e49d2e163b9de96ea0") -guiLoc=("https://git.salome-platform.org/gitpub/modules/gui.git","7397622d22624ab84dd52c68a2") -paravisLoc=("https://git.salome-platform.org/gitpub/modules/paravis.git","574ac287ed7022000") +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" -#env PATH=/local00/home/H87074/TMP46/SalomeMiniForKW/install/cmake-3.0.2/bin:/local00/home/H87074/TMP46/SalomeMiniForKW/install/Python-2.7.10/bin:/local00/home/H87074/TMP46/SalomeMiniForKW/install/hdf5-1.8.14/bin:/local00/home/H87074/TMP46/SalomeMiniForKW/install/swig-2.0.8/bin:/local00/home/H87074/Tools/git_2.0.1_install/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games SWIG_LIB=/local00/home/H87074/TMP46/SalomeMiniForKW/install/swig-2.0.8/share/swig/2.0.8 LD_LIBRARY_PATH=/local00/home/H87074/TMP46/SalomeMiniForKW/install/Python-2.7.10/lib:/local00/home/H87074/TMP46/SalomeMiniForKW/install/hdf5-1.8.14/lib PYTHON_VERSION=2.7 HDF5HOME=/local00/home/H87074/TMP46/SalomeMiniForKW/install/hdf5-1.8.14 SWIG_ROOT_DIR=/local00/home/H87074/TMP46/SalomeMiniForKW/install/swig-2.0.8 PYTHONSTARTUP=/local00/home/H87074/TMP46/SalomeMiniForKW/install/Python-2.7.10/pythonrc.py:/netdata/H87074/.pythonrc PYTHONHOME=/local00/home/H87074/TMP46/SalomeMiniForKW/install/Python-2.7.10 PYTHON_INCLUDE=/local00/home/H87074/TMP46/SalomeMiniForKW/install/Python-2.7.10/include/python2.7 HDF5_DISABLE_VERSION_CHECK=1 +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" @@ -36,7 +79,7 @@ def python_Environ(installDir,envAcc): addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) envAcc["PYTHONHOME"]=installDir envAcc["PYTHONSTARTUP"]=os.path.join(installDir,"pythonrc.py") - envAcc["PYTHON_VERSION"]="2.7" + envAcc["PYTHON_VERSION"]=python_version_short envAcc["PYTHON_INCLUDE"]=os.path.join(installDir,"include","python%s"%envAcc["PYTHON_VERSION"]) pass @@ -53,7 +96,7 @@ def swig_Environ(installDir,envAcc): pathAdd=[os.path.join(installDir,"bin")] addEnv(envAcc,"PATH",pathAdd) envAcc["SWIG_ROOT_DIR"]=installDir - envAcc["SWIG_LIB"]=os.path.join(installDir,"share","swig","2.0.8") + envAcc["SWIG_LIB"]=os.path.join(installDir,"share","swig",swig_version) pass def qt_Environ(installDir,envAcc): @@ -68,7 +111,7 @@ def qt_Environ(installDir,envAcc): def med_Environ(installDir,envAcc): pathAdd=[os.path.join(installDir,"bin")] ldPathAdd=[os.path.join(installDir,"lib")] - pyPathAdd=[os.path.join(installDir,"lib","python2.7","site-packages")] + pyPathAdd=[os.path.join(installDir,"lib","python%s"%python_version_short,"site-packages")] addEnv(envAcc,"PATH",pathAdd) addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) addEnv(envAcc,"PYTHONPATH",pyPathAdd) @@ -78,7 +121,7 @@ def med_Environ(installDir,envAcc): def medcoupling_Environ(installDir,envAcc): pathAdd=[os.path.join(installDir,"bin")] ldPathAdd=[os.path.join(installDir,"lib")] - pyPathAdd=[os.path.join(installDir,"lib","python2.7","site-packages")] + pyPathAdd=[os.path.join(installDir,"lib","python%s"%python_version_short,"site-packages")] addEnv(envAcc,"PATH",pathAdd) addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) addEnv(envAcc,"PYTHONPATH",pyPathAdd) @@ -89,18 +132,17 @@ def medcoupling_Environ(installDir,envAcc): pass def paraview_Environ(installDir,envAcc): - pvversion="5.0" envAcc["PVHOME"]=installDir - envAcc["PVVERSION"]=pvversion + envAcc["PVVERSION"]=paraview_version pathAdd=[os.path.join(installDir,"bin")] addEnv(envAcc,"PATH",pathAdd) - ldPathAdd=[os.path.join(installDir,"lib","paraview-%s"%pvversion)] + ldPathAdd=[os.path.join(installDir,"lib","paraview-%s"%paraview_version)] addEnv(envAcc,"LD_LIBRARY_PATH",ldPathAdd) - pyPathAdd =[os.path.join(installDir,"lib","paraview-%s"%pvversion,"site-packages")] - pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%pvversion,"site-packages","vtk")] - pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%pvversion,"site-packages","paraview","vtk")] + pyPathAdd =[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages")] + pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages","vtk")] + pyPathAdd+=[os.path.join(installDir,"lib","paraview-%s"%paraview_version,"site-packages","paraview","vtk")] addEnv(envAcc,"PYTHONPATH",pyPathAdd) - pvPlgPathAdd=[os.path.join(installDir,"lib","paraview-%s"%pvversion)] + pvPlgPathAdd=[os.path.join(installDir,"lib","paraview-%s"%paraview_version)] addEnv(envAcc,"PV_PLUGIN_PATH",pvPlgPathAdd) pass @@ -139,6 +181,7 @@ def extractSrcFromArchive(srcLoc,srcDir,pattern): myCmd=["tar","xfz",srcLoc] else: myCmd=["tar","xfj",srcLoc] + print "Command: ", " ".join(myCmd) p=subprocess.Popen(myCmd,cwd=tmpDir,stdout=subprocess.PIPE,stderr=subprocess.PIPE) p.communicate() assert(p.returncode==0) @@ -164,7 +207,7 @@ def extractSrcFromArchive(srcLoc,srcDir,pattern): # print datetime.date.fromtimestamp(os.stat(elt).st_ctime) # pass return ret - + def extractSrcFromGit(gitLoc,srcDir,pattern): zz=AutoChdir(srcDir) assert(isinstance(gitLoc,tuple)) @@ -186,8 +229,8 @@ def extractSrcFromGit(gitLoc,srcDir,pattern): p.communicate() assert(p.returncode==0) return ret - - + + def extractSrc(srcDir,pattern): srcLoc=eval("%sLoc"%pattern) if isinstance(srcLoc,str): @@ -241,13 +284,13 @@ def compilePart0(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuil else: os.mkdir(myBuildDir) return myBuildDir,myInstallDir,True - + def compilePart1(p,buildDir): a,b=p.communicate() f=file(os.path.join(buildDir,cfgOut),"w") ; f.write(a) ; f.flush() f=file(os.path.join(buildDir,cfgErr),"w") ; f.write(b) ; f.flush() assert(p.returncode==0) - + def compilePart2(envAcc,buildDir,splitInstall): print("make in %s"%(buildDir)) if not splitInstall: @@ -270,24 +313,24 @@ def compilePart2(envAcc,buildDir,splitInstall): pass f=file(os.path.join(buildDir,okFlag),"w") ; f.write(str(datetime.datetime.now())) ; f.flush() pass - + def compileOldCommon(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,splitInstall): myBuildDir,myInstallDir,shouldContinue=compilePart0(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) if not shouldContinue: return myInstallDir myCmd=[os.path.join(srcDir,"configure"),"--prefix=%s"%(myInstallDir)]+addCfgParam - print(myCmd) + print "Command: ", " ".join(myCmd) p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE) compilePart1(p,myBuildDir) compilePart2(envAcc,myBuildDir,splitInstall) return myInstallDir - + def compileOld(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): return compileOldCommon(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,False) - + def compileVeryOld(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): return compileOldCommon(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild,True) - + def compileNew(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild): myBuildDir,myInstallDir,shouldContinue=compilePart0(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) if not shouldContinue: @@ -298,7 +341,7 @@ def compileNew(envAcc,srcDir,topBuildDir,topInstallDir,addCfgParam,forceRebuild) compilePart1(p,myBuildDir) compilePart2(envAcc,myBuildDir,False) return myInstallDir - + def accumulateEnv(installDir,pattern,envAcc): """ envAcc out parameter""" zeAccumulator=eval("%s_Environ"%pattern) @@ -308,7 +351,7 @@ def accumulateEnv(installDir,pattern,envAcc): def generateInlineEnv(envAcc): d=computeEnv(envAcc) return "env "+" ".join(["%s=%s"%(k,d[k]) for k in d.keys()]) - + def generateFileEnv(envAcc): d=computeEnv(envAcc) @@ -324,7 +367,7 @@ def bidouilleForCMake(topSrcDir,guiSrcDir): os.mkdir(distDir) shutil.copytree(os.path.join(guiSrcDir,"adm_local","cmake_files"),os.path.join(distDir,"cmake_files")) return os.path.abspath(zeKernelFake) - + def copyCMakeFromSrcToInstall(srcDir,installDir): zeSrcDir=os.path.join(srcDir,"cmake_files") zeInstDir=os.path.join(installDir,"cmake_files") @@ -457,3 +500,5 @@ envFile=os.path.abspath(os.path.join(topInstallDir,"environment.sh")) f=file(envFile,"w") f.write(generateFileEnv(envAcc)) ; f.flush() ; del f print("Env file generated : %s"%envFile) + +generateRuntimeEnviron() -- 2.39.2