diff --git a/herwig-bootstrap b/herwig-bootstrap --- a/herwig-bootstrap +++ b/herwig-bootstrap @@ -1,445 +1,444 @@ #! /usr/bin/env python import subprocess import os import urllib import tarfile from optparse import OptionParser, OptionValueError parser = OptionParser(usage='Usage: %prog [options] DIR') # function to set up the standard flags for a program def setUpFlags(program,version,build=True) : parser.add_option("--with-"+program , action='store_true' , dest=program,default=build, help="Install "+program) parser.add_option("--without-"+program, action='store_false', dest=program,default=build, help="Don\'t install "+program) parser.add_option("--"+program+"-location", type='string', default="", dest=program+"_loc", help="Location of "+program+" if not installed") if(version!="") : parser.add_option("--"+program+"-version", type='string', default=version, dest=program+"_ver", help="Version of "+program+" to be installed") # compiler building parser.add_option("--with-gcc", action='store_true' , dest="gcc",default=False, help="Install the gcc compilers") parser.add_option("--gcc-version", type='string', default="4.9.2", dest="gcc_ver", help="Version of gcc to be installed") parser.add_option("--gmp-version", type='string', default="6.0.0a", dest="gmp_ver", help="Version of gmp to be installed") parser.add_option("--mpfr-version", type='string', default="3.1.2", dest="mpfr_ver", help="Version of mpfr to be installed") parser.add_option("--mpc-version", type='string', default="1.0.3", dest="mpc_ver", help="Version of mpc to be installed") parser.add_option("--add-lib64", action='store_true', default='store_false', dest="add_lib64", help="Add lib64 to the path, needed on SLC systems") # gengetopt if needed setUpFlags("gengetopt","2.22.6",False) # flags for boost setUpFlags("boost","1.57.0") # flags for gsl setUpFlags("gsl","1.15") # flags for fastjet setUpFlags("fastjet","3.1.1") # flags for hepmc setUpFlags("hepmc","2.06.09") # flags for lhapdf setUpFlags("lhapdf","6.1.5") # flags for yoda setUpFlags("yoda","1.3.0") parser.add_option("--yoda-hg", action='store_true', dest="yoda_hg",default=False, help='Get yoda from mercurial') parser.add_option("--yoda-tar", action='store_false', dest="yoda_hg",default=False, help='Get yoda from tar ball') parser.add_option("--yoda-repo", type='string', default="ssh://login.hepforge.org//hepforge/hg/yoda/public/yoda", dest='yoda_repo', help='The location of the mercurial repository for Yoda') # flags for rivet setUpFlags("rivet","2.2.0") parser.add_option("--rivet-hg", action='store_true', dest="rivet_hg",default=False, help='Get rivet from mercurial') parser.add_option("--rivet-tar", action='store_false', dest="rivet_hg",default=False, help='Get rivet from tar ball') parser.add_option("--rivet-repo", type='string', default="ssh://login.hepforge.org//hepforge/hg/rivet/public/rivet", dest='rivet_repo', help='The location of the mercurial repository for Rivet') # flags for thepeg setUpFlags("thepeg","1.9.2") parser.add_option("--thepeg-hg", action='store_true', dest="thepeg_hg",default=False, help='Get thepeg from mercurial') parser.add_option("--thepeg-tar", action='store_false', dest="thepeg_hg",default=False, help='Get thepeg from tar ball') parser.add_option("--thepeg-repo", type='string', default="ssh://login.hepforge.org//hepforge/hg/thepeg/public/ThePEG", dest='thepeg_repo', help='The location of the mercurial repository for ThePEG') # madgraph setUpFlags("madgraph","2.3.0.beta") parser.add_option("--madgraph-bzr", action='store_true', dest="madgraph_bzr",default=False, help='Get madgraph from mercurial') parser.add_option("--madgraph-tar", action='store_false', dest="madgraph_bzr",default=False, help='Get madgraph from tar ball') parser.add_option("--madgraph-repo", type='string', default="lp:~matchboxteam/mg5amcnlo/matchbox_output", dest='madgraph_repo', help='The location of the mercurial repository for Madgraph') # flags for njet setUpFlags("njet","2.0.0") # flags for vbfnlo setUpFlags("vbfnlo","2.8.0beta0") # flags for GoSam setUpFlags("gosam","") # flags for OpenLoops setUpFlags("openloops","public") parser.add_option("--openloops-repo", type='string', default="http://openloops.hepforge.org/svn/OpenLoops/branches", dest='openloops_repo', help='The location of the mercurial repository for OpenLoops') parser.add_option("--openloops-processes", type='string', default="all/", dest='openloops_processes', help='The processes for OpenLoops') # flags for herwig setUpFlags("herwig","2.7.1") parser.add_option("--herwig-hg", action='store_true', dest="herwig_hg",default=False, help='Get herwig from mercurial') parser.add_option("--herwig-tar", action='store_false', dest="herwig_hg",default=False, help='Get herwig from tar ball') parser.add_option("--herwig-repo", type='string', default="ssh://login.hepforge.org//hepforge/hg/herwig/public/herwig", dest='herwig_repo', help='The location of the mercurial repository for Herwig') # no of cores parser.add_option("--ncore",type='int', default="1", dest="ncore", help="Number of cores to use with make -j to speed up compilation") # get the options and locations opts, install_loc = parser.parse_args() if(len(install_loc) != 1 ) : print 'Must specify a build location' exit() install_loc = install_loc[0] # set the base directory current_dir=os.getcwd() base_dir=os.path.join(current_dir,install_loc) if ( not os.path.isdir(base_dir)) : os.mkdir(base_dir) os.chdir(base_dir) # set the environment variables if ( 'PATH' in os.environ ) : os.environ['PATH'] = base_dir+"/bin:"+os.environ['PATH'] else : os.environ['PATH'] = base_dir+"/bin" if ( 'LD_LIBRARY_PATH' in os.environ ) : if( not opts.add_lib64) : os.environ['LD_LIBRARY_PATH'] = base_dir+"/lib:"+os.environ['LD_LIBRARY_PATH'] else : os.environ['LD_LIBRARY_PATH'] = base_dir+"/lib:"+base_dir+"/lib64:"+os.environ['LD_LIBRARY_PATH'] else : if( not opts.add_lib64) : os.environ['LD_LIBRARY_PATH'] = base_dir+"/lib" else : os.environ['LD_LIBRARY_PATH'] = base_dir+"/lib:"+base_dir+"/lib64" # checkout def checkout( base, version, repo,branch, repo_type='hg') : if( repo_type == 'hg' ) : if(version !="") : directory=base + "-"+version else : directory=base subprocess.check_call(["hg","clone",repo,directory]) os.chdir(os.path.join(base_dir,directory)) subprocess.check_call(["hg","up",branch]) subprocess.check_call(["autoreconf","-vi","--force"]) elif(repo_type == "bzr" ) : subprocess.check_call(["bzr","co",repo,base]) elif(repo_type == "svn" ) : subprocess.check_call(["svn","checkout",repo+"/"+branch,base]) os.chdir(os.path.join(base_dir,base)) else : print 'Only supports checout from hg,svn or bzr' exit() def download(url_base,tar_name,args=[]) : - program_url='{}/{}'.format(url_base,tar_name) + program_url = '%s/%s' % (url_base,tar_name) urllib.urlretrieve(program_url,tar_name) with tarfile.open(tar_name,'r') as tar: tar.extractall() -def compile(config_flags) : - flags=["./configure","--prefix="+base_dir] - for flag in config_flags: - flags.append(flag) +def compile(config_flags=[]) : + flags = ["./configure","--prefix="+base_dir] + flags += config_flags subprocess.check_call(flags) - subprocess.check_call(["make","-j"+str(opts.ncore)]) + subprocess.check_call(["make","-j %s" % opts.ncore]) subprocess.check_call(["make","install"]) os.chdir(base_dir) def downloadAndCompile(url_base,base_name,suffix,config_flags) : download(url_base,base_name+suffix) os.chdir(os.path.join(base_dir,base_name)) compile(config_flags) def deletelibtool() : las=[] for directory in ["lib","lib64","lib32"] : full_path = os.path.join(base_dir,directory) if os.path.isdir(full_path) : p = subprocess.Popen(["find",full_path,"-name","*.la"],stderr=subprocess.PIPE,stdout=subprocess.PIPE) las_temp = p.communicate()[0].split() for i in las_temp : las.append(i) for libtool_lib in las: os.remove(libtool_lib) def buildgcc() : # build gmp if(opts.gmp_ver.endswith("a")) : ver2=opts.gmp_ver[:-1] program_url="https://gmplib.org/download/gmp/gmp-"+opts.gmp_ver+".tar.bz2" urllib.urlretrieve(program_url, "gmp-"+ver2+".tar.bz2") with tarfile.open("gmp-"+ver2+".tar.bz2",'r') as tar: tar.extractall() os.chdir(os.path.join(base_dir,"gmp-"+ver2)) compile(["--enable-fat"]) else : downloadAndCompile("https://gmplib.org/download/gmp","gmp-"+opts.gmp_ver,".tar.bz2",["--enable-fat"]) # build mpfr downloadAndCompile("http://mpfr.loria.fr/mpfr-"+opts.mpfr_ver,"mpfr-"+opts.mpfr_ver,".tar.bz2",["--with-gmp="+base_dir]) # build mpc downloadAndCompile("www.multiprecision.org/mpc/download/","mpc-"+opts.mpc_ver,".tar.gz",["--with-gmp="+base_dir,"--with-mpfr="+base_dir]) # gcc download("ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-"+opts.gcc_ver, "gcc-"+opts.gcc_ver+".tar.bz2") os.mkdir(os.path.join(base_dir,"obj")) os.chdir(os.path.join(base_dir,"obj")) gcc_version=opts.gcc_ver.split(".") flags=["../gcc-"+opts.gcc_ver+"/configure","--prefix="+base_dir] if (int(gcc_version[0]) == 3) : flags.append("--enable-languages=c,c++,f77") elif (int(gcc_version[0]) >= 4) : if(int(gcc_version[0]) == 4 and int(gcc_version[1])==0) : flags.append("--enable-languages=c,c++,f95") else : flags.append("--enable-languages=c,c++,fortran") flags.append("--with-gmp="+base_dir) flags.append("--with-mpfr="+base_dir) if(int(gcc_version[0]) > 4 or (int(gcc_version[0]) == 4 and int(gcc_version[1])>=4 )) : flags.append("--with-mpc="+base_dir) subprocess.check_call(flags) subprocess.check_call(["make","-j"+str(opts.ncore)]) subprocess.check_call(["make","install"]) os.chdir(base_dir) deletelibtool() # download and compile gcc if(opts.gcc) : buildgcc() if(opts.gengetopt) : downloadAndCompile("ftp://ftp.gnu.org/gnu/gengetopt/", "gengetopt-"+opts.gengetopt_ver,".tar.gz",[]) # install boost if required if (opts.boost) : boost_ver2=opts.boost_ver.replace(".","_") boost_base = "boost_"+ boost_ver2 download("http://sourceforge.net/projects/boost/files/boost/"+ opts.boost_ver, boost_base+".tar.bz2") os.chdir(os.path.join(base_dir,boost_base)) subprocess.check_call(["./bootstrap.sh","--prefix="+base_dir,'threading=multi']) subprocess.check_call(["./b2","--layout=tagged","install","-j"+str(opts.ncore)]) os.chdir(base_dir) boost_loc=base_dir else : boost_loc=opts.boost_loc # install gsl if required if(opts.gsl) : downloadAndCompile("http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gsl", "gsl-"+opts.gsl_ver,".tar.gz",[]) gsl_loc=base_dir else : gsl_loc=opts.gsl_loc # install fastjet if required if( opts.fastjet) : downloadAndCompile("fastjet.fr/repo","fastjet-"+opts.fastjet_ver,".tar.gz",["--enable-allplugins"]) fastjet_loc=base_dir else : fastjet_loc=opts.fastjet_loc # install hepmc if needed if( opts.hepmc) : downloadAndCompile("lcgapp.cern.ch/project/simu/HepMC/download","HepMC-"+opts.hepmc_ver,".tar.gz",["--with-momentum=GEV","--with-length=MM"]) hepmc_loc=base_dir else : hepmc_loc=opts.hepmc_loc # install lhapdf if needed if( opts.lhapdf) : args=[] if(boost_loc != "" ) : args.append("--with-boost="+boost_loc) downloadAndCompile("www.hepforge.org/archive/lhapdf","LHAPDF-"+opts.lhapdf_ver,".tar.gz",args) # ./configure --prefix=$root_dir -enable-pdfsets=all lhapdf_loc=base_dir else : lhapdf_loc=opts.lhapdf_loc # install yoda if needed if( opts.yoda) : # from tar ball if(not opts.yoda_hg) : download("www.hepforge.org/archive/yoda","YODA-"+opts.yoda_ver+".tar.bz2") os.chdir(os.path.join(base_dir,"YODA-"+opts.yoda_ver)) else : if(opts.yoda_ver !="") : branch="yoda-"+opts.yoda_ver else : branch="" checkout("YODA",opts.yoda_ver,opts.yoda_repo,branch) args=[] if(boost_loc != "" ) : args.append("--with-boost="+boost_loc) compile(args) yoda_loc=base_dir else : yoda_loc=opts.yoda_loc # install rivet if needed if( opts.rivet) : # from tar ball if(not opts.rivet_hg) : download("www.hepforge.org/archive/rivet","Rivet-"+opts.rivet_ver+".tar.bz2") os.chdir(os.path.join(base_dir,"Rivet-"+opts.rivet_ver)) else : if(len(opts.rivet_ver)==5) : branch="rivet-"+opts.rivet_ver else : branch=opts.rivet_ver checkout("Rivet",opts.rivet_ver,opts.rivet_repo,branch) args=["--enable-unvalidated"] if(boost_loc != "" ) : args.append("--with-boost="+boost_loc) if(gsl_loc != "" ) : args.append("--with-gsl="+gsl_loc) if(yoda_loc != "" ) : args.append("--with-yoda="+yoda_loc) if(hepmc_loc != "" ) : args.append("--with-hepmc="+hepmc_loc) if(fastjet_loc != "" ) : args.append("--with-fastjet="+fastjet_loc) compile(args) rivet_loc=base_dir else : rivet_loc=opts.rivet_loc # install thepeg if needed if( opts.thepeg) : # from tar ball if(not opts.thepeg_hg) : download("www.hepforge.org/archive/thepeg","ThePEG-"+opts.thepeg_ver+".tar.bz2") os.chdir(os.path.join(base_dir,"ThePEG-"+opts.thepeg_ver)) else : if(len(opts.thepeg_ver)==5) : branch="release-"+opts.thepeg_ver.replace(".","-") else : branch=opts.thepeg_ver checkout("ThePEG",opts.thepeg_ver,opts.thepeg_repo,branch) args=[] if(fastjet_loc != "" ) : args.append("--with-fastjet="+fastjet_loc) if(gsl_loc != "" ) : args.append("--with-gsl="+gsl_loc) if(rivet_loc != "" ) : args.append("--with-rivet="+rivet_loc) if(hepmc_loc != "" ) : args.append("--with-hepmc="+hepmc_loc) if(lhapdf_loc != "" ) : args.append("--with-lhapdf="+lhapdf_loc) compile(args) thepeg_loc=base_dir else : thepeg_loc=opts.thepeg_loc # install madgraph if( opts.madgraph ) : # from tar ball if(not opts.madgraph_bzr) : download("https://launchpad.net/mg5amcnlo/2.0/2.2.0/+download","MG5_aMC_v"+opts.madgraph_ver+".tar.gz") madgraph_loc=os.path.join(base_dir,"MG5_aMC_v"+opts.madgraph_ver.replace(".","_")) else : checkout("madgraph",opts.madgraph_ver,opts.madgraph_repo,"",'bzr') madgraph_loc=os.path.join(base_dir,"madgraph") else : madgraph_loc=opts.madgraph_loc # install the NLO codes if needed # install njet if required if( opts.njet) : downloadAndCompile("https://bitbucket.org/njet/njet/downloads","njet-"+opts.njet_ver,".tar.gz",["--disable-autoflags","FC=gfortran","F77=gfortran"]) njet_loc=base_dir else : njet_loc=opts.njet_loc # install openloops if needed if(opts.openloops) : checkout("OpenLoops",opts.openloops_ver,opts.openloops_repo,opts.openloops_ver,'svn') subprocess.check_call(["./scons","auto="+opts.openloops_processes,"gjobs="+str(opts.ncore)]) os.chdir(base_dir) openloops_loc=base_dir+"/OpenLoops" else : openloops_loc=opts.openloops_loc # install gosam if needed if( opts.gosam ) : gosam_dir=os.path.join(base_dir,"GoSam") os.mkdir(gosam_dir) os.chdir(gosam_dir) urllib.urlretrieve("http://gosam.hepforge.org/gosam_installer.py", "gosam_installer.py") os.chmod("./gosam_installer.py",0755) subprocess.check_call(["./gosam_installer.py","-b"]) os.chdir(base_dir) gosam_loc=base_dir else : gosam_loc=opts.gosam_loc # install vbfnlo if required if( opts.vbfnlo) : download("https://www.itp.kit.edu/~vbfnloweb/wiki/lib/exe/fetch.php?media=download:", "vbfnlo-"+opts.vbfnlo_ver+".tgz",["--no-check-certificate"]) os.chdir(os.path.join(base_dir,"VBFNLO-"+opts.vbfnlo_ver)) subprocess.check_call(["./configure","--prefix="+base_dir]) subprocess.check_call(["make","-j"+str(opts.ncore)]) subprocess.check_call(["make","install"]) os.chdir(base_dir) vbfnlo_loc=base_dir else : vbfnlo_loc=opts.vbfnlo_loc # install herwig if needed if( opts.herwig) : # from tar ball if(not opts.herwig_hg) : download("www.hepforge.org/archive/herwig","Herwig++-"+opts.herwig_ver+".tar.bz2") os.chdir(os.path.join(base_dir,"Herwig++-"+opts.herwig_ver)) else : if(len(opts.herwig_ver)==5) : branch = "release-"+opts.herwig_ver.replace(".","-") else : branch = opts.herwig_ver checkout("Herwig++",opts.herwig_ver,opts.herwig_repo,branch) args=[] if(gsl_loc != "" ) : args.append("--with-gsl="+gsl_loc) if(fastjet_loc != "" ) : args.append("--with-fastjet="+fastjet_loc) if(thepeg_loc != "" ) : args.append("--with-thepeg="+thepeg_loc) if(boost_loc != "" ) : args.append("--with-boost="+boost_loc) if(madgraph_loc != "" ) : args.append("--with-madgraph="+madgraph_loc) if(njet_loc != "" ) : args.append("--with-njet="+njet_loc) if(openloops_loc != "" ) : args.append("--with-openloops="+openloops_loc) # args.append("LD_LIBRARY_PATH="+openloops_loc+"/OpenLoops/lib:$LD_LIBRARY_PATH") if(gosam_loc != "" ) : args.append("--with-gosam="+gosam_loc) if(vbfnlo_loc != "" ) : args.append("--with-vbfnlo="+vbfnlo_loc) compile(args) herwig_loc=base_dir else : herwig_loc=opts.herwig_loc # back to the original directory os.chdir(current_dir)