summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorStephen Nicholas Swatman <stephen@v25.nl>2024-11-01 16:41:34 +0100
committerGitHub <noreply@github.com>2024-11-01 15:41:34 +0000
commit24d3ed8c1805ccd7553dba2c62984d99dc301f6e (patch)
tree36a09ef42b10bd8ec046404a2bb14e2499c4c2cd /var
parent492c52089f81654f00b0d52defed71e7b56152b7 (diff)
downloadspack-24d3ed8c1805ccd7553dba2c62984d99dc301f6e.tar.gz
spack-24d3ed8c1805ccd7553dba2c62984d99dc301f6e.tar.bz2
spack-24d3ed8c1805ccd7553dba2c62984d99dc301f6e.tar.xz
spack-24d3ed8c1805ccd7553dba2c62984d99dc301f6e.zip
geant4: make downloading data dependency optional (#47298)
* geant4: make downloading data dependency optional This PR makes downloading the data repository of the Geant4 spec optional by adding a sticky, default-enabled variant which controls the dependency on `geant4-data`. This should not change the default behaviour, but should allow users to choose whether or not they want the data directory. * Add comment * Update env variable * Generic docs * Buildable false
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/geant4/package.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/geant4/package.py b/var/spack/repos/builtin/packages/geant4/package.py
index a606c9c7e1..8dd3f18b5d 100644
--- a/var/spack/repos/builtin/packages/geant4/package.py
+++ b/var/spack/repos/builtin/packages/geant4/package.py
@@ -84,6 +84,40 @@ class Geant4(CMakePackage):
variant("timemory", default=False, description="Use TiMemory for profiling", when="@9.5:")
variant("vtk", default=False, description="Enable VTK support", when="@11:")
+ # For most users, obtaining the Geant4 data via Spack will be useful; the
+ # sticky, default-enabled `+data` variant ensures that this happens.
+ # Furthermore, if this variant is enabled, Spack will automatically set the
+ # necessary environment variables to ensure that the Geant4 code runs
+ # correctly.
+ #
+ # However, the Geant4 data is also large and it is, on many machines used
+ # in HEP, already available via e.g. CVMFS. In these cases, users can save
+ # network bandwidth by using externally supplied Geant4 data. This can be
+ # done in two different ways.
+ #
+ # The first is to declare the Geant4 data directories as externals. This
+ # can be done by manually adding them to the `packages.yaml` file, e.g.:
+ #
+ # ```
+ # g4radioactivedecay:
+ # externals:
+ # - spec: g4radioactivedecay@5.6
+ # prefix: <PREFIX>
+ # buildable: False
+ # ```
+ #
+ # Where <PREFIX> is a path such that <PREFIX>/share/data/<DATASET><VERSION>
+ # exists.
+ #
+ # Alternatively, the `~data` variant can be supplied; in this case, Spack
+ # will not attempt to use the `geant4-data` spec at all. It is then
+ # essential to set up the `GEANT4_DATA_DIR` environment variable manually
+ # at runtime; see the Geant4 installation guide for more information:
+ # https://geant4-userdoc.web.cern.ch/UsersGuides/InstallationGuide/html/postinstall.html
+ variant(
+ "data", default=True, sticky=True, description="Enable downloading of the data directory"
+ )
+
depends_on("cmake@3.16:", type="build", when="@11.0.0:")
depends_on("cmake@3.8:", type="build", when="@10.6.0:")
depends_on("cmake@3.5:", type="build")
@@ -109,7 +143,7 @@ class Geant4(CMakePackage):
"11.2.2:11.2",
"11.3:",
]:
- depends_on("geant4-data@" + _vers, type="run", when="@" + _vers)
+ depends_on("geant4-data@" + _vers, type="run", when="+data @" + _vers)
depends_on("expat")
depends_on("zlib-api")
@@ -301,7 +335,8 @@ class Geant4(CMakePackage):
# geant4-data's install directory to correctly set up the
# Geant4Config.cmake values for Geant4_DATASETS .
options.append(self.define("GEANT4_INSTALL_DATA", False))
- options.append(self.define("GEANT4_INSTALL_DATADIR", self.datadir))
+ if spec.satisfies("+data"):
+ options.append(self.define("GEANT4_INSTALL_DATADIR", self.datadir))
# Vecgeom
if spec.satisfies("+vecgeom"):