Page MenuHomeHEPForge

No OneTemporary

diff --git a/herwig-bootstrap b/herwig-bootstrap
--- a/herwig-bootstrap
+++ b/herwig-bootstrap
@@ -1,1155 +1,1156 @@
#!/usr/bin/env python
import subprocess
import sys, os, errno, platform, shutil
import urllib2, ssl
import tarfile
from optparse import OptionParser, OptionGroup
from optparse import SUPPRESS_HELP as NOHELP
from time import sleep
if platform.system() == 'Darwin':
default_cc = os.getenv('CC', '/usr/bin/clang')
default_cxx = os.getenv('CXX', '/usr/bin/clang++')
default_fc = os.getenv('FC', None)
else:
default_cc = os.getenv('CC', 'gcc')
default_cxx = os.getenv('CXX', 'g++')
default_fc = os.getenv('FC', 'gfortran')
# from http://stackoverflow.com/a/377028
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
parser = OptionParser(usage='Usage: %prog [options] DEST_DIR\n'
' %prog --help')
without_helptext = """
can optionally be satisfied with pre-existing installations. Specifying the PATH to an
existing installation will prevent a local build.
Each --with-FOO option has a corresponding --without-FOO,
to disable that package completely.
We can't help with build errors arising from use of --with and --without!
"""
parser_core = OptionGroup(parser,"Override main dependencies",
"The main dependencies for Herwig"+without_helptext)
parser_nlo = OptionGroup(parser,"Override NLO dependencies",
"The dependencies on NLO providers."+without_helptext)
parser_scm = OptionGroup(parser,"Source code repositories (for developers)",
"Some dependencies are also available as "
"direct source code checkouts. "
"Default repo URLs are already provided, you only "
"need to use the --foo-repo= options to change the defaults.")
parser_versions = OptionGroup(parser, "Code versions",
"Change the default version of the installation.")
parser_misc = OptionGroup(parser,"Miscellaneous options",
"Options for special use cases, not required for a regular build.")
parser.add_option_group(parser_core)
parser.add_option_group(parser_nlo)
parser.add_option_group(parser_versions)
parser.add_option_group(parser_scm)
parser.add_option_group(parser_misc)
# src directory
parser_misc.add_option("--src-dir",
metavar='PATH',
type='string',
default="",
dest='src_dir',
help='Separate the source/build directory. Default is DEST_DIR/src.')
# function to set up the standard flags for a program
def setUpFlags(parser,program,version) :
parser.add_option("--with-"+program ,
dest=program+'_loc',
metavar='PATH',
default=None,
help="")
parser.add_option("--without-"+program,
action='store_false',
dest=program,
default=True,
help=NOHELP)
if version:
parser_versions.add_option("--"+program+"-version",
metavar='VER',
type='string',
default=version,
dest=program+"_ver",
help="[%default]")
# compiler building
parser.add_option("--build-gcc",
action='store_true' ,
dest="gcc",
default=False,
help="Build a local copy of the gcc compilers to use for the rest of bootstrap.")
parser_versions.add_option("--gcc-version",
metavar='VER',
type='string',
default="4.9.3",
dest="gcc_ver",
help="[%default]")
# gengetopt
parser_misc.add_option("--build-gengetopt",
action='store_true' ,
dest='gengetopt',
default=False,
help="Always build a local version of gengetopt instead of automatic detection.")
# flags for boost
setUpFlags(parser_core,"boost","1.58.0")
parser_misc.add_option("--boost-all",
action='store_false',
dest="boost_minimal",
default=True,
help='Install all the boost libaries, including those not required by Herwig.')
# flags for gsl
setUpFlags(parser_core,"gsl","1.15")
# flags for fastjet
setUpFlags(parser_core,"fastjet","3.1.3")
# flags for hepmc
setUpFlags(parser_core,"hepmc","2.06.09")
# flags for lhapdf
setUpFlags(parser_core,"lhapdf","6.1.5")
parser_misc.add_option("--add-pdf",
metavar='PDF',
action='append',
dest="pdfs",
default=["MMHT2014lo68cl","MMHT2014nlo68cl"],
help='Add a PDF to the defaults %default')
# flags for yoda
setUpFlags(parser_core,"yoda","1.5.5")
parser_scm.add_option("--yoda-hg",
action='store_true',
dest="yoda_hg",
default=False,
help='')
parser_scm.add_option("--yoda-repo",
metavar='URL',
type='string',
default="https://yoda.hepforge.org/hg/yoda",
dest='yoda_repo',
help='[%default]')
# flags for rivet
setUpFlags(parser_core,"rivet","2.4.0")
parser_scm.add_option("--rivet-hg",
action='store_true',
dest="rivet_hg",
default=False,
help='')
parser_scm.add_option("--rivet-repo",
metavar='URL',
type='string',
default="https://rivet.hepforge.org/hg/rivet",
dest='rivet_repo',
help='[%default]')
# flags for thepeg
setUpFlags(parser_core,"thepeg","2.0.0")
parser_scm.add_option("--thepeg-hg",
action='store_true',
dest="thepeg_hg",
default=False,
help='')
parser_scm.add_option("--thepeg-repo",
metavar='URL',
type='string',
default="https://thepeg.hepforge.org/hg/ThePEG",
dest='thepeg_repo',
help='[%default]')
# flags for herwig
setUpFlags(parser_core,"herwig","7.0.0")
parser_scm.add_option("--herwig-hg",
action='store_true',
dest="herwig_hg",
default=False,
help='')
parser_scm.add_option("--herwig-repo",
metavar='URL',
type='string',
default="https://herwig.hepforge.org/hg/herwig",
dest='herwig_repo',
help=' [%default]')
# madgraph
setUpFlags(parser_nlo,"madgraph","2.3.0.beta")
parser_scm.add_option("--madgraph-bzr",
action='store_true',
dest="madgraph_bzr",
default=False,
help='')
parser_scm.add_option("--madgraph-repo",
metavar='URL',
type='string',
default="lp:~matchboxteam/mg5amcnlo/matchbox_output",
dest='madgraph_repo',
help='[%default]')
# flags for njet
setUpFlags(parser_nlo,"njet","2.0.0")
# flags for vbfnlo
setUpFlags(parser_nlo,"vbfnlo","3.0.0beta2")
parser_misc.add_option("--vbfnlo-processes",
metavar='PROCS',
type='string',
default="vbf,hjjj",
dest='vbfnlo_processes',
help='The processes for VBFNLO [%default]')
# flags for GoSam
setUpFlags(parser_nlo,"gosam","")
# flags for OpenLoops
setUpFlags(parser_nlo,"openloops","public")
parser_scm.add_option("--openloops-repo",
metavar='URL',
type='string',
default="http://openloops.hepforge.org/svn/OpenLoops/branches",
dest='openloops_repo',
help='[%default]')
parser_misc.add_option("--openloops-processes",
metavar='PROCS',
type='string',
default="ppll",
dest='openloops_processes',
help='The processes for OpenLoops [%default]')
# flags for HJets++
setUpFlags(parser_nlo,"hjets","")
# 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",
type='int',
metavar='N',
default=ncore,
dest="ncore",
help="Use N cores in make -j to speed up compilation. [%default]")
del ncore
# get the options and locations
opts, install_dir = parser.parse_args()
if len(install_dir) != 1:
parser.print_usage(sys.stderr)
exit(1)
install_dir = install_dir[0]
# gengetopt is always needed for Herwig hg build
if opts.herwig_hg and which('gengetopt') is None:
opts.gengetopt = True
if platform.system() == 'Darwin':
opts.njet = False
sys.stderr.write("* OS X: disabling NJet *\n")
if opts.gcc:
sys.stderr.write("""
*********************************************************
*
* Self-building the compilers is not supported on OS X.
*
* Set FC to a Fortran compiler you have installed from
* another source (e.g. MacPorts, Fink or Homebrew) and
* rerun bootstrap without '--build-gcc'.
*
*********************************************************
""")
exit(1)
if default_fc is None:
sys.stderr.write("""
*********************************************************
*
* Set FC to a Fortran compiler you have installed from
* another source (e.g. MacPorts, Fink or Homebrew).
*
*********************************************************
""")
if not opts.gcc:
print """
*********************************************************
* Using CC=%s CXX=%s FC=%s.
* Set these environment variables to change compilers.
*********************************************************
""" % (default_cc,default_cxx,default_fc)
else:
print """
*********************************************************************
* Using self-installed CC, CXX and FC. To use other compilers,
* unset --with-gcc and optionally set these 3 environment variables.
*********************************************************************
"""
sleep(1)
# set the base directory
current_dir=os.getcwd()
base_dir=os.path.join(current_dir,install_dir)
if not os.path.isdir(base_dir):
os.mkdir(base_dir)
opt_dir = os.path.join(base_dir,'opt')
if not os.path.isdir(opt_dir):
os.mkdir(opt_dir)
if not opts.src_dir:
src_dir = os.path.join(base_dir,'src')
else:
src_dir = os.path.join(current_dir,opts.src_dir)
if not os.path.isdir(src_dir):
os.mkdir(src_dir)
os.chdir(src_dir)
# set the environment variables
bin_dir = os.path.join(base_dir,'bin')
try:
os.environ['PATH'] = os.pathsep.join([bin_dir, os.environ['PATH']])
except KeyError:
os.environ['PATH'] = bin_dir
ld_env_name = 'LD_LIBRARY_PATH' if platform.system() != 'Darwin' else 'DYLD_LIBRARY_PATH'
libpaths = [os.path.join(base_dir,'lib')]
if platform.system() != 'Darwin':
libpaths.append(os.path.join(base_dir,'lib64'))
lib_dirs = os.pathsep.join(libpaths)
try:
os.environ[ld_env_name] = os.pathsep.join([lib_dirs, os.environ[ld_env_name]])
except KeyError:
os.environ[ld_env_name] = lib_dirs
python_path = os.pathsep.join([os.path.join(base_dir,'lib64','python'+sys.version[:3],'site-packages'),
os.path.join(base_dir,'lib', 'python'+sys.version[:3],'site-packages')])
try:
os.environ['PYTHONPATH'] = os.pathsep.join([python_path, os.environ['PYTHONPATH']])
except KeyError:
os.environ['PYTHONPATH'] = python_path
# storage of prefix info for individual packages
class Prefixes(dict):
# return None instead of raising KeyError for unknown package name
def __missing__(self, key):
return None
prefix = Prefixes()
def check_call(arglist):
print ' '.join(arglist)
subprocess.check_call(arglist)
# checkout
def checkout( location, base, version, repo, branch, repo_type='hg', revision=None) :
os.chdir(location)
if repo_type == 'hg':
directory=base
if version:
directory += "-"+version
if not os.path.isdir(directory):
check_call(["hg","clone",repo,directory])
else:
check_call(["hg","pull","-R",directory,repo])
os.chdir(os.path.join(location,directory))
if revision:
check_call(["hg","up","-r",revision])
else:
check_call(["hg","up",branch])
check_call(["autoreconf","-vi"])
elif repo_type == "bzr":
check_call(["bzr","co",repo,base])
elif repo_type == "svn":
if revision:
check_call(["svn","checkout",repo+"/"+branch,base,"-r",revision])
else:
check_call(["svn","checkout",repo+"/"+branch,base])
os.chdir(os.path.join(location,base))
else:
sys.stderr.write('Only supports checkout from hg,svn or bzr\n')
exit(1)
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:
try:
context = ssl._create_unverified_context()
response = urllib2.urlopen(request, context=context)
except AttributeError:
response = urllib2.urlopen(request)
except urllib2.HTTPError as e:
sys.stderr.write('Remote server returned error code %s: %s\n' % (e.code, e.reason))
exit(1)
except urllib2.URLError as e:
sys.stderr.write('Could not reach server: %s\n' % e.reason)
exit(1)
with open(tar_name,'w') as f:
f.write(response.read())
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
check_call(flags)
check_call(["make","-s","-j%s" % opts.ncore])
# TODO ?? skip here if some file already exists in /lib or /bin ??
check_call(["make","-s","install"])
os.chdir(src_dir)
def downloadAndCompile(url_base,base_name,suffix,config_flags) :
download(url_base,base_name+suffix)
os.chdir(os.path.join(src_dir,base_name))
compile(config_flags)
def deletelibtool() :
os.chdir(base_dir)
for directory in ["lib","lib64","lib32"] :
full_path = os.path.join(base_dir,directory)
if os.path.isdir(full_path) :
check_call(["find",full_path,"-name","*.la","-delete"])
GCC_SUFFIX = '-hwbst-%s' % opts.gcc_ver
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
gcc_patch_225158 = """\
Index: trunk/gcc/configure
===================================================================
--- trunk/gcc/configure (revision 225157)
+++ trunk/gcc/configure (revision 225158)
@@ -25048,7 +25048,7 @@
else
gcc_cv_as_ix86_filds=no
if test x$gcc_cv_as != x; then
- $as_echo 'filds mem; fists mem' > conftest.s
+ $as_echo 'filds (%ebp); fists (%ebp)' > conftest.s
if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
@@ -25079,7 +25079,7 @@
else
gcc_cv_as_ix86_fildq=no
if test x$gcc_cv_as != x; then
- $as_echo 'fildq mem; fistpq mem' > conftest.s
+ $as_echo 'fildq (%ebp); fistpq (%ebp)' > conftest.s
if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
"""
gmp_fatoption = ['--enable-fat']
if platform.system() == 'Darwin':
gmp_fatoption = []
# build gmp
if marker_is_missing('gmp'):
downloadAndCompile('https://gmplib.org/download/gmp',"gmp-6.0.0",".tar.bz2",gmp_fatoption)
prefix['gmp']=base_dir
mark_as_done('gmp')
# build mpfr
if marker_is_missing('mpfr'):
downloadAndCompile('http://www.mpfr.org/mpfr-current',"mpfr-3.1.3",".tar.bz2",["--with-gmp="+base_dir])
prefix['mpfr']=base_dir
mark_as_done('mpfr')
# build mpc
if marker_is_missing('mpc'):
downloadAndCompile("http://www.multiprecision.org/mpc/download","mpc-1.0.3",".tar.gz",["--with-gmp="+base_dir,"--with-mpfr="+base_dir])
prefix['mpc']=base_dir
mark_as_done('mpc')
# gcc
download('ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-'+opts.gcc_ver,
"gcc-"+opts.gcc_ver+".tar.bz2")
os.chdir("gcc-%s" % opts.gcc_ver)
print 'patching gcc configure in', os.getcwd()
p = subprocess.Popen(['patch','-p1'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
stdout_data, stderr_data = p.communicate(input=gcc_patch_225158)
print stdout_data
print stderr_data
if p.returncode != 0:
sys.stderr.write('patch failed\n')
del p
obj_path=os.path.join(src_dir,"gcc-build")
if not os.access(obj_path, os.R_OK):
os.mkdir(obj_path)
os.chdir(obj_path)
else:
os.chdir(obj_path)
# don't use check_call here, the command may not always complete OK
subprocess.call(["make","distclean"])
try:
gcc_version = map(int,opts.gcc_ver.split(".")[:2])
except:
sys.stderr.write('Unknown gcc version format. Expecting "N.N.N".\n')
exit(1)
flags=["../gcc-"+opts.gcc_ver+"/configure",
"--prefix="+base_dir,
"--program-suffix="+GCC_SUFFIX,
"--disable-multilib"]
if gcc_version[0] == 3:
flags.append("--enable-languages=c,c++,f77")
elif gcc_version[0] >= 4:
if gcc_version[0] == 4 and 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 gcc_version[0] > 4 or (gcc_version[0] == 4 and gcc_version[1]>=4 ):
flags.append("--with-mpc="+base_dir)
if gcc_version[0] == 4 and gcc_version[1] == 9 and platform.system() == 'Darwin':
flags.append('--with-build-config=bootstrap-debug')
check_call(flags)
check_call(["make","-s","-j"+str(opts.ncore)])
check_call(["make","-s","install"])
deletelibtool()
os.chdir(src_dir)
def mark_as_done(name):
path = os.path.join(src_dir,'herwig_bootstrap_%s_done' % name)
with open(path, 'w') as f:
f.write('%s\n' % prefix[name])
def build_needed(name):
alternate_path = getattr(opts,'%s_loc' % name,False)
if alternate_path:
print 'Alternative given for %s.\nUsing %s' % (name, alternate_path)
prefix[name] = alternate_path
return False
cmdline_flag_set = getattr(opts,name,False) # default to false if not found
if cmdline_flag_set:
return marker_is_missing(name)
else:
return False
def marker_is_missing(name):
path = os.path.join(src_dir,'herwig_bootstrap_%s_done' % name)
try:
with open(path) as f:
prefixpath = f.readline().rstrip()
except EnvironmentError:
return True
else:
print 'Marker file for %s exists in src/, skipping build,' % name
print ' using prefix=%s.' % prefixpath
prefix[name] = prefixpath
return False
# download and compile gcc
if build_needed('gcc'):
buildgcc()
mark_as_done('gcc')
if opts.gcc:
default_cc = os.path.join(base_dir,'bin','gcc%s' % GCC_SUFFIX)
default_cxx = os.path.join(base_dir,'bin','g++%s' % GCC_SUFFIX)
default_fc = os.path.join(base_dir,'bin','gfortran%s' % GCC_SUFFIX)
os.environ['CC'] = default_cc
os.environ['CXX'] = default_cxx
os.environ['FC'] = default_fc
os.environ['F77'] = default_fc
if build_needed('gengetopt'):
tmp_ncore=opts.ncore
opts.ncore=1
downloadAndCompile("ftp://ftp.gnu.org/gnu/gengetopt/",
"gengetopt-2.22.6",".tar.gz",[])
opts.ncore=tmp_ncore
mark_as_done('gengetopt')
# install boost if required
if build_needed('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(src_dir,boost_base))
# make sure we use our own compiler
if opts.gcc:
with open('tools/build/src/user-config.jam','w') as f:
# this line only works if default_cxx is actually gcc-related
f.write('using gcc : : %s ;\n' % default_cxx)
if opts.boost_minimal:
check_call(["./bootstrap.sh","--prefix="+base_dir,'threading=multi',"--with-libraries=filesystem,system,test"])
else :
check_call(["./bootstrap.sh","--prefix="+base_dir,'threading=multi'])
check_call(["./b2","--layout=tagged","install","-j"+str(opts.ncore)])
os.chdir(src_dir)
# on OS X, write helper script
if platform.system() == 'Darwin':
helpername='./boost-osx-path-fix'
with open(helpername,'w') as f:
f.write(
"""\
#!/bin/bash
for i in %s/lib*/libboost*.dylib
do
install_name_tool -id $i $i || true
if [ $(basename $i) == 'libboost_filesystem-mt.dylib' ]; then
install_name_tool -change libboost_system-mt.dylib $(dirname $i)/libboost_system-mt.dylib $i || true
fi
done
""" % base_dir)
os.chmod(helpername,0755)
check_call([helpername])
prefix['boost']=base_dir
mark_as_done('boost')
# install gsl if required
if build_needed('gsl'):
downloadAndCompile("http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gsl",
"gsl-"+opts.gsl_ver,".tar.gz",
[])
prefix['gsl']=base_dir
mark_as_done('gsl')
# install fastjet if required
if build_needed('fastjet'):
downloadAndCompile("http://fastjet.fr/repo",
"fastjet-"+opts.fastjet_ver,".tar.gz",
["--enable-allplugins"])
prefix['fastjet']=base_dir
mark_as_done('fastjet')
# install hepmc if needed
if build_needed('hepmc'):
downloadAndCompile("http://lcgapp.cern.ch/project/simu/HepMC/download",
"HepMC-"+opts.hepmc_ver,".tar.gz",
["--with-momentum=GEV","--with-length=MM"])
prefix['hepmc']=base_dir
mark_as_done('hepmc')
# install lhapdf if needed
if build_needed('lhapdf'):
args=[]
if prefix['boost']:
args.append("--with-boost="+prefix['boost'])
downloadAndCompile("http://www.hepforge.org/archive/lhapdf",
"LHAPDF-"+opts.lhapdf_ver,".tar.gz",
args)
for pdf in opts.pdfs :
lhapdftool = os.path.join(base_dir,'bin','lhapdf')
check_call([lhapdftool,
'--listdir='+os.path.join(base_dir,'share','LHAPDF'),
'--pdfdir='+os.path.join(base_dir,'share','LHAPDF'),
"install",
pdf])
prefix['lhapdf']=base_dir
mark_as_done('lhapdf')
if opts.lhapdf:
os.environ['LHAPATH'] = os.path.join(base_dir,'share','LHAPDF')
# install yoda if needed
if build_needed('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(src_dir,"YODA-"+opts.yoda_ver))
else :
if opts.yoda_ver :
if len(opts.yoda_ver)==5:
branch="yoda-"+opts.yoda_ver
else :
branch=opts.yoda_ver
else :
branch=""
checkout(src_dir,"YODA",opts.yoda_ver,opts.yoda_repo,branch)
args=[]
if prefix['boost']:
args.append("--with-boost="+prefix['boost'])
compile(args)
prefix['yoda']=base_dir
mark_as_done('yoda')
# install rivet if needed
if build_needed('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(src_dir,"Rivet-"+opts.rivet_ver))
else:
if len(opts.rivet_ver)==5:
branch="rivet-"+opts.rivet_ver
else:
branch=opts.rivet_ver
checkout(src_dir,"Rivet",opts.rivet_ver,opts.rivet_repo,branch)
args = ["--enable-unvalidated"]
for tool in ['boost','gsl','yoda','hepmc','fastjet']:
if prefix[tool]:
args.append( "--with-%s=%s" % (tool,prefix[tool]) )
compile(args)
prefix['rivet']=base_dir
mark_as_done('rivet')
# install thepeg if needed
if build_needed('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(src_dir,"ThePEG-"+opts.thepeg_ver))
else:
if len(opts.thepeg_ver)==5:
branch="release-"+opts.thepeg_ver[:3].replace(".","-")
else:
branch=opts.thepeg_ver
checkout(src_dir,"ThePEG",opts.thepeg_ver,opts.thepeg_repo,branch)
args=[]
for tool in ['boost','gsl','rivet','hepmc','fastjet','lhapdf']:
if prefix[tool]:
args.append( "--with-%s=%s" % (tool,prefix[tool]) )
compile(args)
prefix['thepeg']=base_dir
mark_as_done('thepeg')
# install madgraph
if build_needed('madgraph'):
# from tar ball
if not opts.madgraph_bzr:
mg_name = "MG5_aMC_v"+opts.madgraph_ver.replace(".","_")
download("https://launchpad.net/mg5amcnlo/2.0/2.2.0/+download","MG5_aMC_v"+opts.madgraph_ver+".tar.gz")
prefix['madgraph']=os.path.join(opt_dir, mg_name)
print os.path.join(src_dir, mg_name), os.path.join(opt_dir, mg_name)
shutil.move(os.path.join(src_dir, mg_name), os.path.join(opt_dir, mg_name))
del mg_name
else :
checkout(opt_dir,"madgraph",opts.madgraph_ver,opts.madgraph_repo,"",'bzr')
prefix['madgraph']=os.path.join(opt_dir,"madgraph")
mark_as_done('madgraph')
# install the NLO codes if needed
# install njet if required
if build_needed('njet'):
downloadAndCompile("https://bitbucket.org/njet/njet/downloads",
"njet-"+opts.njet_ver,".tar.gz",
["--disable-autoflags",
"FC="+default_fc,
"F77="+default_fc])
prefix['njet']=base_dir
mark_as_done('njet')
OPENLOOPS_CONFIG = """\
[OpenLoops]
fortran_compiler = {fc}
# fortran_tool = 'gfortran'
compile_extra = 0
"""
# install openloops if needed
if build_needed('openloops'):
checkout(opt_dir,"OpenLoops",opts.openloops_ver,opts.openloops_repo,opts.openloops_ver,'svn',
revision='1400')
with open('openloops.cfg','w') as f:
f.write(OPENLOOPS_CONFIG.format(fc=default_fc))
# We know our gcc works. Disable the strange test that uses the system version number.
if opts.gcc:
searchtext = "env.subst('$CCVERSION').split('.')[:2])) < (4,6)"
with open('tmp.tmp','w') as outfile:
with open('SConstruct') as infile:
for line in infile:
outfile.write(line.replace(searchtext, searchtext + " and False"))
shutil.move('tmp.tmp','SConstruct')
del searchtext
check_call(["./openloops",
"libinstall",
opts.openloops_processes,
"num_jobs=%s" % opts.ncore
])
os.chdir(src_dir)
prefix['openloops']=opt_dir+"/OpenLoops"
mark_as_done('openloops')
# install gosam if needed
if build_needed('gosam'):
# build qgraf
if marker_is_missing('qgraf'):
download('https://www.hepforge.org/archive/herwig/mirror',"qgraf-3.1.4.tgz")
os.chdir(os.path.join(src_dir,'qgraf-3.1.4'))
check_call([default_fc,'qgraf-3.1.4.f','-o','qgraf','-O2'])
shutil.move('qgraf',os.path.join(bin_dir,'qgraf'))
prefix['qgraf']=base_dir
os.chdir(src_dir)
mark_as_done('qgraf')
# build form
if marker_is_missing('form'):
downloadAndCompile('https://gosam.hepforge.org/gosam-installer',"form-4.1",".tar.gz",[])
prefix['form']=base_dir
mark_as_done('form')
# build gosam-contrib
if marker_is_missing('gosam-contrib'):
download('https://www.hepforge.org/archive/gosam/gosam-contrib-2.0-20150803.tar.gz',
"gosam-contrib-2.0.tar.gz", distinct=True)
os.chdir(os.path.join(src_dir,'gosam-contrib-2.0'))
compile([])
prefix['gosam-contrib']=base_dir
mark_as_done('gosam-contrib')
download('https://www.hepforge.org/archive/gosam/','gosam-2.0.2-865.tar.gz')
os.chdir(os.path.join(src_dir,'gosam-2.0.2'))
check_call(["./setup.py",
"install",
"--prefix="+base_dir,
"-f"])
os.chdir(src_dir)
prefix['gosam']=base_dir
mark_as_done('gosam')
# install vbfnlo if required
if build_needed('vbfnlo'):
download("http://www.itp.kit.edu/~vbfnloweb/archive","vbfnlo-"+opts.vbfnlo_ver+".tgz")
os.chdir(os.path.join(src_dir,"VBFNLO-"+opts.vbfnlo_ver))
# work around VBFNLO's broken handwritten compiler checks
del os.environ['F77']
check_call(["./configure","--prefix="+base_dir,"--enable-processes="+opts.vbfnlo_processes])
check_call(["make","-s","-j%s"%opts.ncore])
check_call(["make","-s","install"])
# reinsert F77 for the others
os.environ['F77'] = default_fc
os.chdir(src_dir)
prefix['vbfnlo']=base_dir
mark_as_done('vbfnlo')
# need to install Herwig if we want HJets++
if opts.hjets:
opts.herwig = True
# install herwig if needed
if build_needed('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(src_dir,"Herwig-"+opts.herwig_ver))
else:
if len(opts.herwig_ver)==5:
branch = "herwig-"+opts.herwig_ver[:3].replace(".","-")
else:
branch = opts.herwig_ver
checkout(src_dir,"Herwig",opts.herwig_ver,opts.herwig_repo,branch)
args=[]
for tool in ['thepeg','boost','gsl','fastjet',
'madgraph','njet','openloops','gosam','vbfnlo']:
if prefix[tool]:
args.append( "--with-%s=%s" % (tool,prefix[tool]) )
compile(args)
prefix['herwig']=base_dir
mark_as_done('herwig')
-if build_needed('hjets') and opts.herwig_hg: # TODO: only works with herwig_hg for now!
- os.chdir(os.path.join(src_dir, "Herwig-"+opts.herwig_ver, 'Contrib', 'HJets++'))
- if not os.access('configure', os.X_OK):
- check_call(["autoreconf","-vi"])
- # work around hjets' broken handwritten compiler checks
- del os.environ['F77']
- compile([])
- # reinsert F77 for the others
+if build_needed('hjets'):
+ del os.environ['F77']
+ downloadAndCompile("http://www.hepforge.org/archive/hjets",
+ "HJets-1.0",".tar.bz2",
+ ["--with-herwig=%s" % prefix['herwig'] ])
os.environ['F77'] = default_fc
-
prefix['hjets']=base_dir
+ try:
+ os.symlink(os.path.join(prefix['hjets'], 'lib','HJets', 'HJets.so'),
+ os.path.join(prefix['herwig'],'lib','Herwig','HJets.so'))
+ except:
+ pass
mark_as_done('hjets')
# generate an 'activate' shell include like python's virtualenv does
from string import Template
class ShellTemplate(Template):
delimiter = '@'
ACTIVATE = ShellTemplate("""\
# Herwig bootstrap 'activate',
# based on Python's virtualenv mechanism
# This file must be used with "source @{bin_dir}/activate"
# *from bash or zsh*. You cannot run it directly.
deactivate () {
# reset old environment variables
if [ "${_OLD_VIRTUAL_PATH-}" = "Unset" ] ; then
unset PATH
unset _OLD_VIRTUAL_PATH
elif [ -n "${_OLD_VIRTUAL_PATH-}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ "${_OLD_VIRTUAL_PYTHONPATH-}" = "Unset" ] ; then
unset PYTHONPATH
unset _OLD_VIRTUAL_PYTHONPATH
elif [ -n "${_OLD_VIRTUAL_PYTHONPATH-}" ] ; then
PYTHONPATH="$_OLD_VIRTUAL_PYTHONPATH"
export PYTHONPATH
unset _OLD_VIRTUAL_PYTHONPATH
fi
if [ "${_OLD_VIRTUAL_LHAPATH-}" = "Unset" ] ; then
unset LHAPATH
unset _OLD_VIRTUAL_LHAPATH
elif [ -n "${_OLD_VIRTUAL_LHAPATH-}" ] ; then
LHAPATH="$_OLD_VIRTUAL_LHAPATH"
export LHAPATH
unset _OLD_VIRTUAL_LHAPATH
fi
if [ "${_OLD_VIRTUAL_@{ld_env_name}-}" = "Unset" ] ; then
unset @{ld_env_name}
unset _OLD_VIRTUAL_@{ld_env_name}
elif [ -n "${_OLD_VIRTUAL_@{ld_env_name}-}" ] ; then
@{ld_env_name}="$_OLD_VIRTUAL_@{ld_env_name}"
export @{ld_env_name}
unset _OLD_VIRTUAL_@{ld_env_name}
fi
if [ "${_OLD_VIRTUAL_CC-}" = "Unset" ] ; then
unset CC
unset _OLD_VIRTUAL_CC
elif [ -n "${_OLD_VIRTUAL_CC-}" ] ; then
CC="$_OLD_VIRTUAL_CC"
export CC
unset _OLD_VIRTUAL_CC
fi
if [ "${_OLD_VIRTUAL_CXX-}" = "Unset" ] ; then
unset CXX
unset _OLD_VIRTUAL_CXX
elif [ -n "${_OLD_VIRTUAL_CXX-}" ] ; then
CXX="$_OLD_VIRTUAL_CXX"
export CXX
unset _OLD_VIRTUAL_CXX
fi
if [ "${_OLD_VIRTUAL_FC-}" = "Unset" ] ; then
unset FC
unset _OLD_VIRTUAL_FC
elif [ -n "${_OLD_VIRTUAL_FC-}" ] ; then
FC="$_OLD_VIRTUAL_FC"
export FC
unset _OLD_VIRTUAL_FC
fi
if [ "${_OLD_VIRTUAL_F77-}" = "Unset" ] ; then
unset F77
unset _OLD_VIRTUAL_F77
elif [ -n "${_OLD_VIRTUAL_F77-}" ] ; then
F77="$_OLD_VIRTUAL_F77"
export F77
unset _OLD_VIRTUAL_F77
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" -o -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi
if [ -n "${_OLD_VIRTUAL_PS1-}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset HERWIG_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
HERWIG_ENV="@{base_dir}"
export HERWIG_ENV
_OLD_VIRTUAL_PATH="${PATH-Unset}"
PATH="@{bin_dir}:$PATH"
export PATH
_OLD_VIRTUAL_PYTHONPATH="${PYTHONPATH-Unset}"
PYTHONPATH="@{python_path}:$PYTHONPATH"
export PYTHONPATH
_OLD_VIRTUAL_LHAPATH="${LHAPATH-Unset}"
LHAPATH="@{lha_path}:$LHAPATH"
export LHAPATH
_OLD_VIRTUAL_@{ld_env_name}="${@{ld_env_name}-Unset}"
@{ld_env_name}="@{lib_dirs}:$@{ld_env_name}"
export @{ld_env_name}
_OLD_VIRTUAL_CC="${CC-Unset}"
CC="@{default_cc}"
export CC
_OLD_VIRTUAL_CXX="${CXX-Unset}"
CXX="@{default_cxx}"
export CXX
_OLD_VIRTUAL_FC="${FC-Unset}"
FC="@{default_fc}"
export FC
_OLD_VIRTUAL_F77="${F77-Unset}"
F77="@{default_fc}"
export F77
if [ -z "${HERWIG_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
PS1="(`basename \"$HERWIG_ENV\"`)$PS1"
fi
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" -o -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi
""")
subs = {
'ld_env_name' : ld_env_name,
'bin_dir' : bin_dir,
'base_dir' : base_dir,
'python_path' : python_path,
'lib_dirs' : lib_dirs,
'default_cc' : os.path.basename(default_cc),
'default_cxx' : os.path.basename(default_cxx),
'default_fc' : os.path.basename(default_fc),
'lha_path' : os.path.join(base_dir,'share','LHAPDF')
}
activate_file = os.path.join(bin_dir,'activate')
with open(activate_file,'w') as f:
f.write(ACTIVATE.substitute(subs))
# back to the original directory
os.chdir(current_dir)
try:
path_to_activate = os.path.join(os.path.relpath(bin_dir,current_dir),'activate')
except:
path_to_activate = activate_file
print """
################ / / ^^/ ##########################
############### /--/ / ###########################
############## / / / ############################
Herwig 7 bootstrap was successful.
$ source %s
activates all required environment variables.
$ deactivate
returns to the original environment variables.
""" % path_to_activate

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 2:32 PM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3796581
Default Alt Text
(38 KB)

Event Timeline