Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8724141
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
22 KB
Subscribers
None
View Options
diff --git a/herwig-bootstrap b/herwig-bootstrap
--- a/herwig-bootstrap
+++ b/herwig-bootstrap
@@ -1,644 +1,643 @@
#! /usr/bin/env python
import subprocess
import os, errno, platform
import urllib2, ssl
import tarfile
from optparse import OptionParser, OptionValueError
from time import sleep
default_cc = os.getenv('CC','gcc')
default_cxx = os.getenv('CXX','g++')
default_fc = os.getenv('FC','gfortran')
print """
*********************************************************
* Using CC=%s CXX=%s FC=%s.
* Set environment variables to change compilers.
*********************************************************
""" % (default_cc,default_cxx,default_fc)
sleep(1)
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="https://yoda.hepforge.org/hg/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="https://rivet.hepforge.org/hg/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="https://thepeg.hepforge.org/hg/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="https://herwig.hepforge.org/hg/herwig",
dest='herwig_repo',
help='The location of the mercurial repository for Herwig')
# no of cores
try:
from multiprocessing import cpu_count
ncore=max(cpu_count()-1, 1)
del cpu_count
except:
ncore=1
parser.add_option("-j","--ncore",
type='int',
default=ncore,
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' ) :
directory=base
if version:
directory += "-"+version
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","-vif"])
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 checkout from hg,svn or bzr'
exit()
def download_only(url_base,tar_name,distinct=False) :
if os.access(tar_name, os.R_OK):
print 'Found existing %s' % tar_name
return
if distinct:
program_url = url_base
else:
program_url = '%s/%s' % (url_base,tar_name)
print "Download %s as %s" % (program_url,tar_name)
req_headers = {
'User-Agent' : 'herwig-bootstrap',
'Accept' : '*/*'
}
request = urllib2.Request(program_url, headers=req_headers)
try:
context = ssl._create_unverified_context()
response = urllib2.urlopen(request, context=context)
except:
response = urllib2.urlopen(request)
with open(tar_name,'w') as f:
f.write(response.read())
-def download(url_base,tar_name,args=[]) :
- download_only(url_base,tar_name)
- with tarfile.open(tar_name,'r') as tar:
- lastfile = tar.getnames()[-1]
- if os.access(lastfile, os.R_OK):
- print 'Extracted %s exists already' % lastfile.split('/')[0]
- else:
- print "Extract %s" % tar_name
- tar.extractall()
+def download(url_base,tar_name,args=[],distinct=False) :
+ download_only(url_base,tar_name,distinct)
+ tar = tarfile.open(tar_name,'r')
+ lastfile = tar.getnames()[-1]
+ if os.access(lastfile, os.R_OK):
+ print 'Extracted %s exists already' % lastfile.split('/')[0]
+ else:
+ print "Extract %s" % tar_name
+ tar.extractall()
+ tar.close()
def compile(config_flags=[]) :
if os.access('Makefile',os.R_OK):
print 'Makefile exists, skipping configure'
else:
flags = ["./configure","--prefix="+base_dir]
flags += config_flags
subprocess.check_call(flags)
subprocess.check_call(["make","-j%s" % opts.ncore])
# TODO ?? skip here if some file already exists in /lib or /bin ??
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() :
for directory in ["lib","lib64","lib32"] :
full_path = os.path.join(base_dir,directory)
if os.path.isdir(full_path) :
subprocess.check_call(["find",full_path,"-name","*.la","-delete"])
def buildgcc() :
# build gmp with --enable-fat to allow portability
# --enable-fat currently broken on Mac, see
# https://gmplib.org/repo/gmp/raw-rev/1fab0adc5ff7
gmp_fatoption = ['--enable-fat']
if platform.system() == 'Darwin':
gmp_fatoption = []
if(opts.gmp_ver.endswith("a")) :
ver2=opts.gmp_ver[:-1]
program_url="https://gmplib.org/download/gmp/gmp-"+opts.gmp_ver+".tar.bz2"
- download_only(program_url, "gmp-"+ver2+".tar.bz2",distinct=True)
- with tarfile.open("gmp-"+ver2+".tar.bz2",'r') as tar:
- tar.extractall()
+ download(program_url, "gmp-"+ver2+".tar.bz2",distinct=True)
os.chdir(os.path.join(base_dir,"gmp-"+ver2))
compile(gmp_fatoption)
else :
downloadAndCompile("https://gmplib.org/download/gmp","gmp-"+opts.gmp_ver,".tar.bz2",gmp_fatoption)
# build mpfr
downloadAndCompile("http://mpfr.loria.fr/mpfr-"+opts.mpfr_ver,"mpfr-"+opts.mpfr_ver,".tar.bz2",["--with-gmp="+base_dir])
# build mpc
downloadAndCompile("http://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) :
tmp_ncore=opts.ncore
opts.ncore=1
downloadAndCompile("ftp://ftp.gnu.org/gnu/gengetopt/",
"gengetopt-"+opts.gengetopt_ver,".tar.gz",[])
opts.ncore=tmp_ncore
# 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("http://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("http://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("http://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("http://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("http://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("http://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="+default_fc,
"F77="+default_fc])
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')
with open('openloops.cfg','w') as f:
f.write("[OpenLoops]\nfortran_compiler = %s\n" % default_fc)
subprocess.check_call(["./scons",
"auto=%s" % opts.openloops_processes,
"gjobs=%s" % 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")
try:
os.mkdir(gosam_dir)
except OSError as e:
# ignore if directory exists already
if e.errno != errno.EEXIST: raise
os.chdir(gosam_dir)
download_only("http://gosam.hepforge.org","gosam_installer.py")
os.chmod("./gosam_installer.py",0755)
subprocess.check_call(["./gosam_installer.py",
"-b",
"-v",
"--prefix="+base_dir,
"--fc="+default_fc,
"--cc="+default_cc,
"--cxx="+default_cxx])
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%s"%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("http://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)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Jan 20, 10:32 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242688
Default Alt Text
(22 KB)
Attached To
rHERWIGBOOTHG herwigboothg
Event Timeline
Log In to Comment