Skip to content

Commit

Permalink
sherpa: add v3.0.0, remove deprecated @:2.2.10 (spack#45101)
Browse files Browse the repository at this point in the history
* Remove deprecated versions

* Add sherpa 3.0.0 and CMake builds

* Address comments in spack#45101

* Add builder classes for cmake and autotools

---------

Co-authored-by: jmcarcell <jmcarcell@users.noreply.github.com>
  • Loading branch information
jmcarcell and jmcarcell authored Aug 21, 2024
1 parent 34df21b commit d3cdb2a
Showing 1 changed file with 58 additions and 125 deletions.
183 changes: 58 additions & 125 deletions var/spack/repos/builtin/packages/sherpa/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from spack.package import *


class Sherpa(AutotoolsPackage):
class Sherpa(CMakePackage, AutotoolsPackage):
"""Sherpa is a Monte Carlo event generator for the Simulation of
High-Energy Reactions of PArticles in lepton-lepton, lepton-photon,
photon-photon, lepton-hadron and hadron-hadron collisions."""
Expand All @@ -22,100 +22,15 @@ class Sherpa(AutotoolsPackage):

license("GPL-3.0-only")

version("3.0.0", sha256="e460d8798b323c4ef663293a2c918b1463e9641b35703a54d70d25c852c67d36")
version("2.2.15", sha256="0300fd719bf6a089b7dc5441f720e669ac1cb030045d87034a4733bee98e7bbc")
version("2.2.14", sha256="f17d88d7f3bc4234a9db3872e8a3c1f3ef99e1e2dc881ada5ddf848715dc82da")
version("2.2.13", sha256="ed1fd1372923c191ca44897802d950702b810382260e7464d36ac3234c5c8a64")
version("2.2.12", sha256="4ba78098e45aaac0bc303d1b5abdc15809f30b407abf9457d99b55e63384c83d")
version("2.2.11", sha256="5e12761988b41429f1d104f84fdf352775d233cde7a165eb64e14dcc20c3e1bd")
version(
"2.2.10",
sha256="ae23bc8fdcc9f8c26becc41692822233b62203cd72a7e0dab2ca19316aa0aad7",
deprecated=True,
)
version(
"2.2.9",
sha256="ebc836d42269a0c4049d3fc439a983d19d12595d9a06db2d18765bd1e301923e",
deprecated=True,
)
version(
"2.2.8",
sha256="ff198cbae5de445e6fe383151021ef24b1628dffc0da6bf3737753f6672a0091",
deprecated=True,
)
version(
"2.0.0",
sha256="0e873b27bb1be46ca5ed451d1b8514ca84c10221057b11be5952180076e6f848",
deprecated=True,
)
version(
"1.3.1",
sha256="31881207838d341358db64e3fdadfeee1ea2f6d1cb42f370014f622f579159ae",
deprecated=True,
)
version(
"1.3.0",
sha256="08b13c65b66f2edde6996d2a06762a12a0682ffb64bca43654df47321e5039a0",
deprecated=True,
)
version(
"1.2.3",
sha256="029727337a430d6675a1a12dce3ced0411041e79ddaf4ce3b9466035cf6c8804",
deprecated=True,
)
version(
"1.2.2",
sha256="6e7b5ea80b99f1378519009e494030d6cf4c4491f91218d749eabb8ffaad9ac1",
deprecated=True,
)
version(
"1.2.1",
sha256="838462f4a1e8768135363aa6b8532fd8f5e5789a269b858f8e3728ab37f6a1d1",
deprecated=True,
)
version(
"1.2.0",
sha256="509508fd0ad72aaf55ab484da8b6bc0b31688c955adcda62a3e8f94689cebf99",
deprecated=True,
)
version(
"1.1.3",
sha256="6335e5eb1fc304e9618496d3ddb198b3591e57b27db6e876af8fd649a8b98c93",
deprecated=True,
)
version(
"1.1.2",
sha256="e1689cad6700dc013af0afb0d33729ac2b5e9841d2f325c85b10d773e7f8a80e",
deprecated=True,
)
version(
"1.1.1",
sha256="b80e1d75934be79b73400d2c95d96e88651626ea29ddcb9d8fde9c1812039e29",
deprecated=True,
)
version(
"1.1.0",
sha256="8052d137d668353dc710f8691b921e772820d39e20361f0d616ee2da1ac798f2",
deprecated=True,
)
version(
"1.0.9",
sha256="fe28db91ea8264364395c7e5efeeae3e5c01ea1343e0db7fe13924c6f17fb963",
deprecated=True,
)
version(
"1.0.8",
sha256="6e346bafd13b5b05ad566a73759da6d5e64d65c5036780cc4911d93277e891fa",
deprecated=True,
)
version(
"1.0.7",
sha256="d1eeefd96c6822ea8eb926447ca91ec4a1c714e4746323e92b1e17764e51ff0b",
deprecated=True,
)
version(
"1.0.6",
sha256="358d417ec3afde24618c222bc9b742bc5102d435622b3cd6f2e3f72d03656255",
deprecated=True,

build_system(
conditional("cmake", when="@3:"), conditional("autotools", when="@:2"), default="cmake"
)

depends_on("c", type="build") # generated
Expand All @@ -134,11 +49,11 @@ class Sherpa(AutotoolsPackage):
variant("analysis", default=True, description="Enable analysis components")
variant("mpi", default=False, description="Enable MPI")
variant("python", default=False, description="Enable Python API")
variant("hepmc2", default=True, description="Enable HepMC (version 2.x) support")
variant("hepmc2", default=True, when="@:2", description="Enable HepMC (version 2.x) support")
variant("hepmc3", default=True, description="Enable HepMC (version 3.x) support")
variant("hepmc3root", default=False, description="Enable HepMC (version 3.1+) ROOT support")
variant("rivet", default=False, description="Enable Rivet support")
variant("fastjet", default=True, description="Enable FASTJET")
variant("fastjet", default=True, when="@:2", description="Enable FASTJET")
variant("openloops", default=False, description="Enable OpenLoops")
variant("recola", default=False, description="Enable Recola")
variant("lhole", default=False, description="Enable Les Houches One-Loop Generator interface")
Expand All @@ -148,7 +63,7 @@ class Sherpa(AutotoolsPackage):
variant("pythia", default=True, description="Enable fragmentation/decay interface to Pythia")
variant("blackhat", default=False, description="Enable BLACKHAT support")
variant("ufo", default=False, description="Enable UFO support")
variant("hztool", default=False, description="Enable HZTOOL support")
variant("hztool", default=False, when="@:2", description="Enable HZTOOL support")
variant(
"libs",
default="shared,static",
Expand All @@ -164,11 +79,10 @@ class Sherpa(AutotoolsPackage):
# Note that the delphes integration seems utterly broken: https://sherpa.hepforge.org/trac/ticket/305

# autotools dependencies are needed at runtime to compile processes
# at least as long as sherpa is an autotools package
depends_on("autoconf")
depends_on("automake")
depends_on("libtool")
depends_on("m4")
depends_on("autoconf", when="@:2")
depends_on("automake", when="@:2")
depends_on("libtool", when="@:2")
depends_on("m4", when="@:2")
depends_on("texinfo", type="build")
depends_on("sqlite")

Expand All @@ -188,10 +102,12 @@ class Sherpa(AutotoolsPackage):
depends_on("root", when="+root")
depends_on("lhapdf", when="+lhapdf")
depends_on("gzip", when="+gzip")
depends_on("pythia6", when="+pythia")
depends_on("pythia6", when="+pythia @:2")
depends_on("pythia8", when="+pythia @3:")
depends_on("blackhat", when="+blackhat")
depends_on("hztool", when="+hztool")
# depends_on('cernlib', when='+cernlib')
depends_on("libzip", when="@3:")

filter_compiler_wrappers("share/SHERPA-MC/makelibs")

Expand All @@ -213,6 +129,42 @@ def patch(self):
string=True,
)

def flag_handler(self, name, flags):
flags = list(flags)
if name == "cxxflags":
flags.append("-std=c++" + self.spec.variants["cxxstd"].value)

if "+cms" in self.spec:
flags.extend(["-fuse-cxa-atexit", "-O2"])
if self.spec.target.family == "x86_64":
flags.append("-m64")

return (None, None, flags)


class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self):
args = [
self.define_from_variant("SHERPA_ENABLE_ANALYSIS", "analysis"),
self.define_from_variant("SHERPA_ENABLE_BLACKHAT", "blackhat"),
self.define_from_variant("SHERPA_ENABLE_GZIP", "gzip"),
self.define_from_variant("SHERPA_ENABLE_HEPMC3", "hepmc3"),
self.define_from_variant("SHERPA_ENABLE_HEPMC3_ROOT", "hepmc3root"),
self.define_from_variant("SHERPA_ENABLE_LHAPDF", "lhapdf"),
self.define_from_variant("SHERPA_ENABLE_LHOLE", "lhole"),
self.define_from_variant("SHERPA_ENABLE_MPI", "mpi"),
self.define_from_variant("SHERPA_ENABLE_OPENLOOPS", "openloops"),
self.define_from_variant("SHERPA_ENABLE_PYTHIA8", "pythia"),
self.define_from_variant("SHERPA_ENABLE_PYTHON", "python"),
self.define_from_variant("SHERPA_ENABLE_RECOLA", "recola"),
self.define_from_variant("SHERPA_ENABLE_RIVET", "rivet"),
self.define_from_variant("SHERPA_ENABLE_ROOT", "root"),
self.define_from_variant("SHERPA_ENABLE_UFO", "ufo"),
]
return args


class AutotoolsBuilder(spack.build_systems.autotools.AutotoolsBuilder):
def configure_args(self):
args = []
args.append("--enable-binreloc")
Expand All @@ -227,18 +179,13 @@ def configure_args(self):
args.extend(self.enable_or_disable("pythia"))
hepmc_root = lambda x: self.spec["hepmc"].prefix
args.extend(self.enable_or_disable("hepmc2", activation_value=hepmc_root))
if self.spec.satisfies("@3:"):
args.extend(self.enable_or_disable("hepmc3", activation_value="prefix"))
args.extend(self.enable_or_disable("rivet", activation_value="prefix"))
args.extend(self.enable_or_disable("lhapdf", activation_value="prefix"))
else:
# See https://gitlab.com/sherpa-team/sherpa/-/issues/348
if self.spec.satisfies("+hepmc3"):
args.append("--enable-hepmc3=" + self.spec["hepmc3"].prefix)
if self.spec.satisfies("+rivet"):
args.append("--enable-rivet=" + self.spec["rivet"].prefix)
if self.spec.satisfies("+lhapdf"):
args.append("--enable-lhapdf=" + self.spec["lhapdf"].prefix)
# See https://gitlab.com/sherpa-team/sherpa/-/issues/348
if self.spec.satisfies("+hepmc3"):
args.append("--enable-hepmc3=" + self.spec["hepmc3"].prefix)
if self.spec.satisfies("+rivet"):
args.append("--enable-rivet=" + self.spec["rivet"].prefix)
if self.spec.satisfies("+lhapdf"):
args.append("--enable-lhapdf=" + self.spec["lhapdf"].prefix)

args.extend(self.enable_or_disable("fastjet", activation_value="prefix"))
args.extend(self.enable_or_disable("openloops", activation_value="prefix"))
Expand All @@ -258,20 +205,6 @@ def configure_args(self):

return args

def flag_handler(self, name, flags):
flags = list(flags)
if name == "cxxflags":
flags.append("-std=c++" + self.spec.variants["cxxstd"].value)

if "+cms" in self.spec:
flags.extend(["-fuse-cxa-atexit", "-O2"])
if self.spec.target.family == "x86_64":
flags.append("-m64")

return (None, None, flags)

# This may not be needed when this package is changed to be a CMake package
# since it's specific to makelibs
def install(self, spec, prefix):
# Make sure the path to the provided libtool is used instead of the system one
filter_file(
Expand Down

0 comments on commit d3cdb2a

Please sign in to comment.