Page MenuHomeHEPForge

No OneTemporary

diff --git a/rivet-bootstrap b/rivet-bootstrap
--- a/rivet-bootstrap
+++ b/rivet-bootstrap
@@ -1,768 +1,768 @@
#! /usr/bin/env python
"""\
%prog [options]
%prog is a helper script which downloads and installs Rivet and the
other packages needed to get the Rivet generator validation system up and
running. It tries to be relatively intelligent about what it downloads so that,
e.g. for users on systems with the LCG applications mounted in
/afs/cern.ch/sw/lcg/external it will try to build Rivet using those when
possible, rather than downloading and building things that are already
available.
TODO:
* Build logging: can we stream build output as it happens (in verbose mode)?
"""
import os, sys
import logging
import shutil, commands
def compute_lcg_tag():
import platform
import re
## Get distribution
slversion = None
osxversion = None
distribution = platform.system()
## SL tests
rhreleasepath = "/etc/redhat-release"
if os.path.exists(rhreleasepath):
distribution = "redhat"
f = open(rhreleasepath, "r")
#sltest = commands.getoutput("lsb_release -ds")
sltest = f.read()
f.close()
if "Scientific Linux" in sltest:
#slversion = [int(i) for i in commands.getoutput("lsb_release -rs").split(".")]
m = re.search(r'Scientific Linux.*? (\d)\.(\d).*', sltest)
if m:
slversion = [int(m.group(1)), int(m.group(2))]
distribution = "slc%d" % slversion[0]
## Mac tests
if distribution == "Darwin":
osxversion = (10,4)
macver = platform.mac_ver()[0]
if len(macver) > 0:
ver = macver.split(".")
osxversion = [int(i) for i in ver]
distribution = "mac%d%d" % (osxversion[0], osxversion[1])
## Windows tests
if distribution == "Windows":
distribution = "winxp"
logging.debug("OS: " + distribution)
## Get architecture
machine = platform.machine()
logging.debug("Architecture: " + machine)
## Get compiler version
compiler_code = None
vcversion = None
if distribution != "winxp":
## Get GCC version
GCC_CMD = "g++"
if os.environ.has_key("CC"):
GCC_CMD = os.environ["CC"]
elif os.environ.has_key("CXX"):
GCC_CMD = os.environ["CXX"]
gcc_version_str = commands.getoutput(GCC_CMD + ' --version | head -1')
gcc_version_match = re.search(r'.*? (\d)\.(\d)\.?(\d)?.*?', gcc_version_str)
compiler_code = "gccXX"
if gcc_version_match is not None:
gcc_major = gcc_version_match.group(1)
gcc_minor = gcc_version_match.group(2)
gcc_micro = gcc_version_match.group(3)
compiler_code = "gcc%s%s" % (gcc_major, gcc_minor)
else:
## Try to find VC version... somehow!
import distutils.msvccompiler as msvc
vcversions = sorted(msvc.get_devstudio_versions())
vcversion = vcversions[0]
compiler_code = "vc%s" % vcversion
## the "future-proof" platform tag
LCGPLATFORM = "%s-%s-%s-%s" % (machine, distribution, compiler_code, "opt")
## Historical platform tags
if vcversion is not None and vcversion < 9:
logging.debug("Computing old-style Windows tag to replace " + LCGPLATFORM)
LCGPLATFORM = "win32_vc71_dbg"
elif slversion is not None and slversion[0] < 5 or \
osxversion is not None and osxversion[1] < 6:
logging.debug("Computing old-style tag to replace " + LCGPLATFORM)
## Different arch codes
if "64" in machine:
machine = "amd64"
else:
machine = "ia32"
## Old Mac code is "osx" rather than "mac"
if osxversion:
distribution = distribution.replace("mac", "osx")
## Historical exceptions for GCC version
if compiler_code in ["gcc32", "gcc40"] and gcc_micro is not None:
compiler_code += gcc_micro
## Set legacy LCG platform
LCGPLATFORM = "%s_%s_%s" % (distribution, machine, compiler_code)
# ## For Macs, append "_dbg" if needed
# if osxversion and opts.BUILD_TYPE == "dbg":
# LCGPLATFORM += "_dbg"
return LCGPLATFORM
##############################
from optparse import OptionParser
DEFAULTPREFIX = os.path.join(os.getcwd(), "local")
parser = OptionParser(usage=__doc__)
parser.add_option("--prefix", metavar="INSTALLDIR", default=DEFAULTPREFIX, dest="PREFIX",
help="Location to install packages to [%default]")
parser.add_option("--force", action="store_true", default=False, dest="FORCE",
help="Overwrite existing tarballs [%default]")
parser.add_option("-j", default="2", dest="JMAKE",
help="Num of 'make' threads to run in parallel (the n in 'make -j<n>') [%default]")
parser.add_option("--dev-mode", action="store_true", default=False, dest="DEV_MODE",
help="Use the development head version of Rivet [%default]")
parser.add_option("--devmode", action="store_true", default=False, dest="DEV_MODE",
help="Deprecated: alias for --dev-mode [%default]")
parser.add_option("--dev-mode-aida", action="store_true", default=False, dest="DEV_MODE_AIDA",
help="Use the AIDA development head version of Rivet [%default]")
parser.add_option("--lcgextdir", default="/afs/cern.ch/sw/lcg/external", dest="LCGDIR",
help="Standard location of LCG external packages [%default]")
parser.add_option("--lcgtag", default=compute_lcg_tag(), dest="LCGTAG",
help="Force the LCG platform tag if it's not being computed correctly [%default]")
parser.add_option("--ignore-lcgext", action="store_true", default=False, dest="IGNORE_LCG",
help="Always bootstrap from sources, even if LCG versions are available [%default]")
parser.add_option("--no-install-rivet", action="store_false", default=True, dest="INSTALL_RIVET",
help="Don't install Rivet! Useful to set up required packages, or AGILe only [install=%default]")
parser.add_option("--rivet-version", default="1.8.3", dest="RIVET_VERSION",
help="Explicitly specify version of Rivet to get and use [%default]")
parser.add_option("--rivet-url", default="http://www.hepforge.org/archive/rivet/",
dest="RIVET_URL", help="Base URL for Rivet tarball downloads [%default]")
parser.add_option("--build-rivet-manual", default=False, action="store_true",
dest="BUILD_RIVET_MANUAL", help="Try to build the Rivet PDF manual (requires LaTeX) [%default]")
parser.add_option("--build-unvalidated", default=False, action="store_true",
dest="BUILD_UNVALIDATED", help="Build the unvalidated collection of Rivet analyses [%default]")
parser.add_option("--install-yoda", action="store_true", default=False, dest="INSTALL_YODA",
help="Install the YODA histogramming system [install=%default]")
parser.add_option("--install-agile", action="store_true", default=False, dest="INSTALL_AGILE",
help="Install the AGILe interface system for Fortran generators [install=%default]")
parser.add_option("--agile-version", default="1.4.0", dest="AGILE_VERSION",
help="Explicitly specify version of AGILe to get and use [%default]")
parser.add_option("--agile-url", default="http://www.hepforge.org/archive/agile/",
dest="AGILE_URL", help="Base URL for AGILe tarball downloads [%default]")
parser.add_option("--hepmc-version", default="2.06.06", dest="HEPMC_VERSION",
help="Explicitly specify version of HepMC to get and use [%default]")
parser.add_option("--hepmc-url", default="http://lcgapp.cern.ch/project/simu/HepMC/download/",
dest="HEPMC_URL", help="Base URL for HepMC tarball downloads [%default]")
parser.add_option("--fastjet-version", default="3.0.3", dest="FASTJET_VERSION",
help="Explicitly specify version of FastJet to get and use [%default]")
parser.add_option("--fastjet-url", default="http://www.fastjet.fr/repo/",
dest="FASTJET_URL", help="Base URL for FastJet tarball downloads [%default]")
parser.add_option("--gsl-version", default="1.10", dest="GSL_VERSION",
help="Version of GSL to be used from LCG if AFS is available and used [%default]")
parser.add_option("--with-gsl", metavar="DIR", default=None, dest="GSL_DIR",
help="Explicit path to find GSL -- overrides --gsl-version [%default]")
parser.add_option("--with-boost", metavar="DIR", default=None, dest="BOOST_DIR",
help="Explicit path to find Boost [%default]")
parser.add_option("--install-yamlcpp", action="store_true", default=False, dest="INSTALL_YAMLCPP",
help="Don't use a system copy of yaml-cpp [%default]")
parser.add_option("--yamlcpp-version", default="0.3.0", dest="YAMLCPP_VERSION",
help="Explicitly specify version of yaml-cpp to get if --install-yamlcpp is used [%default]")
parser.add_option("--install-boost", action="store_true", default=False, dest="INSTALL_BOOST",
help="Don't use a system copy of Boost (NB. it's a big download!) [%default]")
parser.add_option("--boost-version", default="1.50.0", dest="BOOST_VERSION",
help="Explicitly specify version of Boost to use from LCG (or to get if --install-boost is used) [%default]")
parser.add_option("--install-autotools", action="store_true", default=False, dest="INSTALL_AUTOTOOLS",
help="Don't use a system copy of autotools [%default]")
parser.add_option("--autoconf-version", default="2.69", dest="AUTOCONF_VERSION",
help="Explicitly specify version of autoconf to get if --install-autotools is used [%default]")
parser.add_option("--automake-version", default="1.13.3", dest="AUTOMAKE_VERSION",
help="Explicitly specify version of automake to get if --install-autotools is used [%default]")
parser.add_option("--libtool-version", default="2.4.2", dest="LIBTOOL_VERSION",
help="Explicitly specify version of libtool to get if --install-autotools is used [%default]")
parser.add_option("--install-cython", action="store_true", default=False, dest="INSTALL_CYTHON",
help="Don't use a system copy of Cython [%default]")
parser.add_option("--cython-version", default="0.19.1", dest="CYTHON_VERSION",
help="Explicitly specify version of Cython to use from LCG (or to get if --install-cython is used) [%default]")
parser.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
default=logging.INFO, help="print debug (very verbose) messages")
parser.add_option("-q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
default=logging.INFO, help="be very quiet")
opts, args = parser.parse_args()
if opts.DEV_MODE_AIDA:
opts.DEV_MODE = True
if opts.DEV_MODE and not opts.DEV_MODE_AIDA:
opts.INSTALL_YODA = True
## Configure logging
try:
logging.basicConfig(level=opts.LOGLEVEL, format="%(message)s")
except:
pass
h = logging.StreamHandler()
h.setFormatter(logging.Formatter("%(message)s"))
logging.getLogger().setLevel(opts.LOGLEVEL)
if logging.getLogger().handlers:
logging.getLogger().handlers[0] = h
else:
logging.getLogger().addHandler(h)
## Build location
ROOTDIR = os.path.abspath(os.getcwd())
## Build location
DLDIR = os.path.abspath(os.path.join(ROOTDIR, "downloads"))
if not os.path.exists(DLDIR):
os.makedirs(DLDIR)
if not os.access(DLDIR, os.W_OK):
logging.error("Can't write to downloads directory, %s... exiting" % DLDIR)
## Build location
BUILDDIR = os.path.abspath(os.path.join(ROOTDIR, "build"))
if not os.path.exists(BUILDDIR):
os.makedirs(BUILDDIR)
if not os.access(BUILDDIR, os.W_OK):
logging.error("Can't write to build directory, %s... exiting" % BUILDDIR)
## Install to the PREFIX location
PREFIX = os.path.abspath(opts.PREFIX)
if not os.path.exists(PREFIX):
os.makedirs(PREFIX)
if not os.access(PREFIX, os.W_OK):
logging.error("Can't write to installation directory, %s... exiting" % PREFIX)
INCDIR = os.path.join(PREFIX, "include")
if not os.path.exists(INCDIR):
os.makedirs(INCDIR)
LIBDIR = os.path.join(PREFIX, "lib")
if not os.path.exists(LIBDIR):
os.makedirs(LIBDIR)
###########################
## Function to grab a tarball from the Web
def get_tarball(url, outname=None):
if not outname:
import urlparse
outname = os.path.basename(urlparse.urlparse(url)[2])
outpath = os.path.join(DLDIR, outname)
if os.path.exists(outpath):
if not opts.FORCE:
logging.info("Not overwriting tarball at %s" % outpath)
return outpath
else:
logging.info("Overwriting tarball at %s" % outpath)
os.remove(outpath)
import urllib2
hreq = None
out = None
try:
logging.info("Downloading %s" % url)
request = urllib2.Request(url, headers={"Accept" : "text/html"})
hreq = urllib2.urlopen(request)
out = open(outpath, "w")
out.write(hreq.read())
out.close()
hreq.close()
return outpath
except urllib2.URLError:
logging.error("Problem downloading tarball from %s" % url)
if hreq:
hreq.close()
except IOError:
logging.error("Problem while writing tarball to %s" % outpath)
if out:
out.close()
if hreq:
hreq.close()
return None
## Function to unpack a tarball
def unpack_tarball(path):
import tarfile
tar = tarfile.open(path)
try:
for i in tar.getnames():
if not os.path.exists(os.path.join(BUILDDIR, i)):
tar.extract(i, path=BUILDDIR)
except:
return False
tar.close()
return True
## Convenience function to get and unpack the tarball
def get_unpack_tarball(tarurl, outname=None):
outfile = get_tarball(tarurl, outname)
unpack_tarball(outfile) or sys.exit(1)
return True
## Function to enter an expanded tarball and run the usual
## autotools ./configure, make, make install mantra
def conf_mk_mkinst(d, extraopts=""):
prevdir = os.getcwd()
if os.access(d, os.W_OK):
os.chdir(d)
confcmd = "./configure --prefix=%s %s" % (PREFIX, extraopts)
logging.info("Configuring in %s: %s" % (os.getcwd(), confcmd))
st, op = commands.getstatusoutput(confcmd)
if st != 0:
logging.error(op)
sys.exit(1)
logging.debug("Configure output:\n" + op)
buildcmd = "make -j%s && make -j%s install" % (opts.JMAKE, opts.JMAKE)
logging.info("Building in %s: %s" % (os.getcwd(), buildcmd))
st, op = commands.getstatusoutput(buildcmd)
if st != 0:
logging.error(op)
sys.exit(1)
logging.debug("Build output:\n" + op)
os.chdir(prevdir)
else:
logging.error("Couldn't find %s... exiting" % d)
sys.exit(1)
DEVTOOLS_OK = False
def check_devtools():
global DEVTOOLS_OK
if not DEVTOOLS_OK:
logging.info("Checking for developer mode programs")
path = []
if os.environ.has_key("PATH"):
path = os.environ["PATH"].split(":")
if os.environ.has_key("path"):
path = os.environ["path"].split(":")
# TODO: Move AGILe -> hg and remove svn dependence
# TODO: Eliminate SWIG dependence when we remove support for the AIDA Rivet branch
pkgs = ["svn", "hg", "autoconf", "autoreconf", "automake", "libtool"]
if opts.DEV_MODE and not opts.DEV_MODE_AIDA:
pkgs.append("cython")
if not opts.DEV_MODE or opts.DEV_MODE_AIDA:
pkgs.append("swig")
for pkg in pkgs:
found = False
for d in path:
if os.access(os.path.join(d, pkg), os.X_OK):
found = True
break
if not found:
logging.error("You must have %s installed to bootstrap in developer mode" % pkg)
return False
DEVTOOLS_OK = True
return True
def pkg_bootstrap_svn(svnurl, pkgname, displayname=None):
st = check_devtools()
if not st:
return False
#
if displayname is None:
displayname = pkgname
os.chdir(BUILDDIR)
if not os.path.exists(pkgname):
logging.info("Checking out %s from SVN head" % displayname)
st, op = commands.getstatusoutput("svn co %s %s" % (svnurl, pkgname))
if st != 0:
logging.error(op)
return False
logging.debug("SVN checkout output:\n" + op)
elif not os.path.exists(os.path.join(pkgname, ".svn")):
logging.error("Non-SVN '%s' directory already exists, blocking SVN checkout" % pkgname)
return False
os.chdir(pkgname)
logging.info("Updating %s SVN working copy" % displayname)
st, op = commands.getstatusoutput("svn update")
if st != 0:
logging.error(op)
return False
logging.debug("SVN update output:\n" + op)
if not os.path.exists("configure"):
logging.info("Bootstrapping autoconf files")
st, op = commands.getstatusoutput("autoreconf -i")
if st != 0:
logging.error(op)
return False
logging.debug("autoreconf output:\n" + op)
os.chdir(BUILDDIR)
return True
def pkg_bootstrap_hg(hgurl, branchname, pkgname, displayname=None):
st = check_devtools()
if not st:
return False
#
if displayname is None:
displayname = pkgname
os.chdir(BUILDDIR)
if not os.path.exists(pkgname):
logging.info("Checking out %s from hg head" % displayname)
- st, op = commands.getstatusoutput("hg clone -U %s %s" % (hgurl, pkgname))
+ st, op = commands.getstatusoutput("hg clone %s %s" % (hgurl, pkgname))
if st != 0:
logging.error(op)
return False
logging.debug("hg checkout output:\n" + op)
elif not os.path.exists(os.path.join(pkgname, ".hg")):
logging.error("Non-hg '%s' directory already exists, blocking hg checkout" % pkgname)
return False
os.chdir(pkgname)
logging.info("Updating %s hg working copy" % displayname)
st, op = commands.getstatusoutput("hg pull -u %s" % branchname)
if st != 0:
logging.error(op)
return False
logging.debug("hg update output:\n" + op)
if not os.path.exists("configure"):
logging.info("Bootstrapping autoconf files")
st, op = commands.getstatusoutput("autoreconf -i")
if st != 0:
logging.error(op)
return False
logging.debug("autoreconf output:\n" + op)
os.chdir(BUILDDIR)
return True
try:
## Put the prefix bin in the path
os.environ["PATH"] = os.path.join(PREFIX, "bin") + ":" + os.environ["PATH"]
## Get autotools
if opts.INSTALL_AUTOTOOLS:
import urlparse
os.chdir(BUILDDIR)
AUTOCONF_NAME = "autoconf-%s" % opts.AUTOCONF_VERSION
AUTOCONF_URL = urlparse.urljoin("http://ftp.gnu.org/gnu/autoconf/", "%s.tar.gz" % AUTOCONF_NAME)
logging.info("Getting %s" % AUTOCONF_URL)
get_unpack_tarball(AUTOCONF_URL)
conf_mk_mkinst(os.path.join(BUILDDIR, AUTOCONF_NAME))
AUTOMAKE_NAME = "automake-%s" % opts.AUTOMAKE_VERSION
AUTOMAKE_URL = urlparse.urljoin("http://ftp.gnu.org/gnu/automake/", "%s.tar.gz" % AUTOMAKE_NAME)
logging.info("Getting %s" % AUTOMAKE_URL)
get_unpack_tarball(AUTOMAKE_URL)
conf_mk_mkinst(os.path.join(BUILDDIR, AUTOMAKE_NAME))
LIBTOOL_NAME = "libtool-%s" % opts.LIBTOOL_VERSION
LIBTOOL_URL = urlparse.urljoin("http://mirror.ibcp.fr/pub/gnu/libtool/", "%s.tar.gz" % LIBTOOL_NAME)
logging.info("Getting %s" % LIBTOOL_URL)
get_unpack_tarball(LIBTOOL_URL)
conf_mk_mkinst(os.path.join(BUILDDIR, LIBTOOL_NAME))
## Get Cython and include in paths
if opts.INSTALL_CYTHON:
cythonname = "Cython-" + opts.CYTHON_VERSION
os.chdir(BUILDDIR)
if not os.path.exists(cythonname):
cythontarname = cythonname + ".tar.gz"
cythonurl = "http://www.cython.org/release/" + cythontarname
get_unpack_tarball(cythonurl)
#os.system("python setup.py install --prefix=%s" % prefix)
CYTHONPATH = os.path.join(BUILDDIR, cythonname)
CYTHONBIN = os.path.join(CYTHONPATH, "bin")
os.environ['PATH'] = CYTHONBIN + ":" + os.environ['PATH']
os.environ['PYTHONPATH'] = CYTHONPATH + ":" + os.environ['PYTHONPATH']
## Get Boost
BOOSTFLAGS = None
if opts.INSTALL_BOOST:
logging.info("Installing a local copy of Boost")
boostname = "boost_%s" % opts.BOOST_VERSION.replace(".", "_")
boosttarname = boostname + ".tar.gz"
boosturl = "http://downloads.sourceforge.net/boost/%s?use_mirror=mesh" % boosttarname
get_unpack_tarball(boosturl)
boostbuilddir = os.path.join(BUILDDIR, boostname)
## Don't do a full install --- just copy the headers into place
## (the build system changes between versions, and usually cocks up the dir structure)
import shutil
boostincdir = os.path.join(INCDIR, "boost")
if not os.path.exists(boostincdir):
shutil.copytree(os.path.join(boostbuilddir, "boost"), boostincdir)
#else:
#logging.warning("Boost header directory %s already exists... exiting" % boostincdir)
#sys.exit(2)
logging.debug("Setting BOOST_DIR = " + PREFIX)
opts.BOOST_DIR = PREFIX
## Get and install yaml-cpp
if opts.INSTALL_YAMLCPP and opts.DEV_MODE and not opts.DEV_MODE_AIDA:
## NB. Rivet 1.x bundles its own version of yaml-cpp... and it's incompatible!
import urlparse
os.chdir(BUILDDIR)
YAMLCPP_NAME = "yaml-cpp-%s" % opts.YAMLCPP_VERSION
YAMLCPP_URL = urlparse.urljoin("https://yaml-cpp.googlecode.com/files/", "%s.tar.gz" % YAMLCPP_NAME)
logging.info("Getting %s" % YAMLCPP_URL)
get_unpack_tarball(YAMLCPP_URL)
prevdir = os.getcwd()
yamlcpp_name = "yaml-cpp"
if not os.path.exists(yamlcpp_name):
os.symlink(YAMLCPP_NAME, yamlcpp_name)
if os.access(yamlcpp_name, os.W_OK):
os.chdir(yamlcpp_name)
cmakecmd = "cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=%s" % PREFIX
st, op = commands.getstatusoutput(cmakecmd)
if st != 0:
logging.error(op)
sys.exit(1)
logging.debug("Cmake output:\n" + op)
buildcmd = "make -j%s && make -j%s install" % (opts.JMAKE, opts.JMAKE)
st, op = commands.getstatusoutput(buildcmd)
if st != 0:
logging.error(op)
sys.exit(1)
logging.debug("Build output:\n" + op)
os.chdir(prevdir)
else:
logging.error("Couldn't find %s... exiting" % yamlcpp_name)
sys.exit(1)
## Get YODA
if opts.INSTALL_YODA and opts.DEV_MODE and not opts.DEV_MODE_AIDA:
yodaname = "yoda"
os.chdir(BUILDDIR)
if os.path.islink(yodaname):
os.remove(yodaname)
pkg_bootstrap_hg("http://yoda.hepforge.org/hg/yoda","default",
yodaname, "YODA") or sys.exit(2)
## Get Rivet
if opts.INSTALL_RIVET:
rivetname = "rivet"
os.chdir(BUILDDIR)
if os.path.islink(rivetname):
os.remove(rivetname)
if not opts.DEV_MODE:
import urlparse
RIVET_NAME = "Rivet-" + opts.RIVET_VERSION
RIVET_URL = urlparse.urljoin(opts.RIVET_URL, "%s.tar.gz" % RIVET_NAME)
logging.info("Getting %s" % RIVET_URL)
get_unpack_tarball(RIVET_URL)
os.chdir(BUILDDIR)
if not os.path.exists(rivetname):
os.symlink(RIVET_NAME, rivetname)
else:
if not os.path.islink(rivetname):
logging.warn("A '%s' directory already exists in %s, but is not a symlink to an expanded tarball" % (rivetname, BUILDDIR))
sys.exit(1)
else:
if not opts.DEV_MODE_AIDA:
pkg_bootstrap_hg("http://rivet.hepforge.org/hg/rivet",
"default",
rivetname, "Rivet") or sys.exit(2)
else:
rivetname += "-aida"
pkg_bootstrap_hg("http://rivet.hepforge.org/hg/rivet",
"2012-06-aidarivet",
rivetname, "AIDA Rivet") or sys.exit(2)
## Get AGILe
if opts.INSTALL_AGILE:
agilename = "agile"
os.chdir(BUILDDIR)
if os.path.islink(agilename):
os.remove(agilename)
if not opts.DEV_MODE:
import urlparse
AGILE_NAME = "AGILe-" + opts.AGILE_VERSION
AGILE_URL = urlparse.urljoin(opts.AGILE_URL, "%s.tar.gz" % AGILE_NAME)
logging.info("Getting %s" % AGILE_URL)
get_unpack_tarball(AGILE_URL) or sys.exit(2)
os.chdir(BUILDDIR)
if not os.path.exists(agilename):
os.symlink(AGILE_NAME, agilename)
else:
if not os.path.islink(agilename):
logging.warn("A '%s' directory already exists in %s, but is not a symlink to an expanded tarball" % (agilename, BUILDDIR))
sys.exit(1)
else:
pkg_bootstrap_svn("http://agile.hepforge.org/svn/trunk", agilename, "AGILe") or sys.exit(2)
## Are we able to use pre-built packages from CERN AFS?
if not opts.IGNORE_LCG and os.path.isdir(opts.LCGDIR):
logging.info("LCG area available: using LCG-built packages")
logging.info("Using LCG platform tag = " + opts.LCGTAG)
## Warn explicitly if this is not a standard LCG platform tag... just gcc checking for now
if "slc" in opts.LCGTAG and "gcc" in opts.LCGTAG:
if not any(v in opts.LCGTAG for v in ("gcc43", "gcc46")):
logging.warn("LCG platform tag %s seems to contain a 'non-standard' GCC version. " % opts.LCGTAG +
"LCG builds of FastJet etc. may not be available, in which case this bootstrap script will fail!")
## Now work out paths to give to Rivet
## HepMC
HEPMCPATH = os.path.join(opts.LCGDIR, "HepMC", opts.HEPMC_VERSION, opts.LCGTAG)
if not os.path.exists(HEPMCPATH):
logging.error("HepMC does not exist at path %s. You may wish to use the --ignore-lcgext option" % HEPMCPATH)
sys.exit(1)
## FastJet
FASTJETPATH = os.path.join(opts.LCGDIR, "fastjet", opts.FASTJET_VERSION, opts.LCGTAG)
if not os.path.exists(FASTJETPATH):
logging.error("FastJet does not exist at path %s. You may wish to use the --ignore-lcgext option" % FASTJETPATH)
sys.exit(1)
## Boost
if not opts.INSTALL_BOOST:
lcg_boost_version = opts.BOOST_VERSION + "_python2.6"
opts.BOOST_DIR = os.path.join(opts.LCGDIR, "Boost", lcg_boost_version, opts.LCGTAG)
## GSL
if not opts.GSL_DIR:
opts.GSL_DIR = os.path.join(opts.LCGDIR, "GSL", opts.GSL_VERSION, opts.LCGTAG)
## Automatically set up a nice SWIG version from LCG if available
swigbin = os.path.join(opts.LCGDIR, "swig", "1.3.40", opts.LCGTAG, "bin")
if os.access(swigbin, os.R_OK) and os.access(os.path.join(swigbin, "swig"), os.X_OK):
## TODO: Check if this is exported to the builds
os.environ["PATH"] = os.environ["PATH"] + ":" + swigbin
else:
## We don't have access to LCG AFS, or are ignoring it, so we download the packages...
## Get and build HepMC
hepmcname = "HepMC-" + opts.HEPMC_VERSION
os.chdir(BUILDDIR)
if not os.path.exists(hepmcname):
hepmctarname = hepmcname + ".tar.gz"
hepmcurl = os.path.join(opts.HEPMC_URL, hepmctarname)
get_unpack_tarball(hepmcurl)
conf_mk_mkinst(os.path.join(BUILDDIR, hepmcname), "--with-momentum=GEV --with-length=MM")
HEPMCPATH = PREFIX
## Get and build FastJet
fastjetname = "fastjet-" + opts.FASTJET_VERSION
os.chdir(BUILDDIR)
if not os.path.exists(fastjetname):
fastjettarname = fastjetname + ".tar.gz"
fastjeturl = os.path.join(opts.FASTJET_URL, fastjettarname)
get_unpack_tarball(fastjeturl)
conf_mk_mkinst(os.path.join(BUILDDIR, fastjetname), "--enable-shared --enable-allcxxplugins")
FASTJETPATH = PREFIX
## This wouldn't be needed if Boost followed normal installation conventions...
if opts.BOOST_DIR:
logging.debug("Working out if Boost's headers are installed properly in " + opts.BOOST_DIR)
boostincdir = os.path.join(opts.BOOST_DIR, "include")
if not os.path.exists(os.path.join(boostincdir, "boost")):
logging.debug("Boost's headers are not installed properly in " + opts.BOOST_DIR)
incdirs = [d for d in os.listdir(boostincdir) if d.startswith("boost-")]
if len(incdirs) > 0:
BOOSTFLAGS = "--with-boost-incpath=%s" % os.path.join(boostincdir, incdirs[0])
else:
logging.error("Couldn't work out location of Boost headers in %s" % boostincdir)
sys.exit(1)
## Get build flags for Rivet and AGILe
RA_CONFIGURE_FLAGS = ""
YODA_CONFIGURE_FLAGS = ""
## LCG tag
RA_CONFIGURE_FLAGS += " --with-lcgtag=%s" % opts.LCGTAG
## HepMC
logging.debug("HepMC path: " + HEPMCPATH)
RA_CONFIGURE_FLAGS += " --with-hepmc=%s" % HEPMCPATH
## Boost
if opts.BOOST_DIR:
logging.debug("Boost path: " + opts.BOOST_DIR)
RA_CONFIGURE_FLAGS += " --with-boost=%s" % opts.BOOST_DIR
YODA_CONFIGURE_FLAGS += " --with-boost=%s" % opts.BOOST_DIR
## In case the Boost headers are not in the standard structure, also try this:
if BOOSTFLAGS:
logging.debug("Boost flags: " + BOOSTFLAGS)
RA_CONFIGURE_FLAGS += " " + BOOSTFLAGS
YODA_CONFIGURE_FLAGS += " " + BOOSTFLAGS
AGILE_CONFIGURE_FLAGS = RA_CONFIGURE_FLAGS
RIVET_CONFIGURE_FLAGS = RA_CONFIGURE_FLAGS
## Build and install Yoda
if opts.INSTALL_YODA:
conf_mk_mkinst(os.path.join(BUILDDIR, yodaname), YODA_CONFIGURE_FLAGS)
## Build and install Rivet
if opts.INSTALL_RIVET:
logging.debug("FastJet path: " + FASTJETPATH)
RIVET_CONFIGURE_FLAGS += " --with-fastjet=%s" % FASTJETPATH
if not opts.BUILD_RIVET_MANUAL:
RIVET_CONFIGURE_FLAGS += " --disable-pdfmanual"
if opts.BUILD_UNVALIDATED:
RIVET_CONFIGURE_FLAGS += " --enable-unvalidated"
if opts.GSL_DIR:
logging.debug("Using GSL path: " + opts.GSL_DIR)
RIVET_CONFIGURE_FLAGS += " --with-gsl=%s" % opts.GSL_DIR
conf_mk_mkinst(os.path.join(BUILDDIR, rivetname), RIVET_CONFIGURE_FLAGS)
## Build and install AGILe
if opts.INSTALL_AGILE:
conf_mk_mkinst(os.path.join(BUILDDIR, agilename), AGILE_CONFIGURE_FLAGS)
## Copy in the environment variable sourcing scripts
envpaths = []
if opts.INSTALL_RIVET:
envpaths += [os.path.join(BUILDDIR, "rivet", "rivetenv.sh"), os.path.join(BUILDDIR, "rivet", "rivetenv.csh")]
if opts.INSTALL_AGILE:
envpaths += [os.path.join(BUILDDIR, "agile", "agileenv.sh"), os.path.join(BUILDDIR, "agile", "agileenv.csh")]
os.chdir(ROOTDIR)
for ep in envpaths:
if os.path.exists(ep):
shutil.copy(ep, ".")
## Tell the user
print
logging.info("All done. Now set some variables in your shell by sourcing, for bash shell:\n")
if opts.INSTALL_RIVET:
logging.info("source rivetenv.sh")
if opts.INSTALL_AGILE:
logging.info("source agileenv.sh")
logging.info("\nor for csh shell:\n")
if opts.INSTALL_RIVET:
logging.info("source rivetenv.csh")
if opts.INSTALL_AGILE:
logging.info("source agileenv.csh")
except Exception, e:
import traceback
traceback.print_exc()
logging.error("\n\n")
logging.error("An error has occurred while bootstrapping Rivet or one of its dependencies. Sorry!")
logging.error("Please contact the Rivet developers at rivet@projects.hepforge.org, with a \
description of your problem, a copy of this script and any error trace that may have appeared \
and we'll try to get it fixed as soon as possible. Thanks for your help!")

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 3:45 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3801260
Default Alt Text
(32 KB)

Event Timeline