Warning, /acts/docs/pages/contributing/spack.md is written in an unsupported language. File is not indexed.
0001 @page howto_spack Building with Spack
0002 @brief Guide to building ACTS with Spack
0003
0004 # Building with Spack
0005
0006 [Spack](https://spack.io/) is a package manager designed to handle software
0007 used in scientific computing, including computing in high-energy physics. The
0008 Spack package manager can be used to more easily install ACTS' dependencies.
0009 Builds using Spack are not officially supported. In order to start using Spack,
0010 follow the instructions on the [official Spack
0011 documentation](https://spack.readthedocs.io/en/latest/getting_started.html).
0012
0013 ## Installing dependencies
0014
0015 Once Spack has been installed, we are ready to create a development
0016 environment; for example:
0017
0018 ```console
0019 spack env create acts
0020 ```
0021
0022 This new environment can then be activated and deactivated as follows:
0023
0024 ```console
0025 spack env activate acts
0026 despacktivate
0027 ```
0028
0029 > [!tip]
0030 > The creation of a Spack environment is persistent, i.e. you should only
0031 > need to create your environment once. The activation of the environment, on the
0032 > other hand, affects only your current shell. As a result, you will need to
0033 > activate the environment every time you open a new shell.
0034
0035 With the Spack environment activated, you are ready to install ACTS'
0036 dependencies. You can either do this manually, or you can rely on Spack's
0037 definition of how to do this. To use the Spack definition, execute the
0038 following command (tuned for ACTS version 36.1.0; make sure you update the
0039 version number to match the version of ACTS you want to build):
0040
0041 ```console
0042 spack install --add --only dependencies "acts@36.1.0"
0043 ```
0044
0045 This specification will suffice to build the core ACTS library. If you want to
0046 build ACTS plugins, you will need to add additional _variants_; the following
0047 is a spec which can be used to build ACTS and all its plugins:
0048
0049 ```console
0050 spack install --add --only dependencies "acts@36.1.0+tgeo+geomodel+podio+edm4hep+examples+odd+fatras+json+dd4hep+geant4+fatras_geant4+hepmc3+pythia8+python+svg+traccc"
0051 ```
0052
0053 The string starting with `acts` in the commands above is the so-called _spec_,
0054 and it consists of three parts. The first part is the name of the package,
0055 which is `acts`. The second part is the version of the package, in this case
0056 `36.1.0`; Spack will pull in a set of dependencies suitable for that given
0057 version, so it is recommended to tune the version number to match the version
0058 of ACTS you want to build. The final part is a series of variants, marked with
0059 the `+` symbol. The command above allows you to build virtually all components
0060 of ACTS, but it also pulls in a large number of dependencies. You can remove
0061 variants you do not need in order to speed up the Spack build.
0062
0063 Once Spack has concretized and installed the ACTS dependencies, you can build
0064 ACTS as normal using CMake.
0065
0066 ### Running with dependencies {#spack_running_with_dependencies}
0067
0068 In order to run code depending on ACTS dependencies such as DD4hep, you may
0069 need to run an additional shell script when you activate your Spack
0070 environment. This shell script is called `this_acts_withdeps.sh` and resides in
0071 your ACTS build directory:
0072
0073 ```console
0074 source <build directory>/this_acts_withdeps.sh
0075 ```
0076
0077 ## Build caches
0078
0079 Work on build caches for ACTS is in progress.
0080
0081 ## Support
0082
0083 Spack support is experimental and not officially supported. Because ACTS'
0084 dependencies are constantly changing, it is possible that Spack's database may
0085 at times be out of date. If you encounter any problems using Spack to build
0086 ACTS, unofficial support is available in the
0087 [#Spack](https://mattermost.web.cern.ch/acts/channels/spack) channel on the
0088 ACTS Mattermost.
0089
0090 ## Troubleshooting
0091
0092 The following are some common problems you may encounter using Spack to build
0093 ACTS.
0094
0095 ### DD4hep not finding factories
0096
0097 If you run into an error like the following, DD4hep is failing to find the
0098 object files required to parse some its required factories. Remember to
0099 initialize the ACTS dependencies as described in ["Running
0100 with dependencies"](#spack_running_with_dependencies):
0101
0102 ```text
0103 dd4hep: Failed to locate plugin to interprete files of type "lccdd" - no factory:lccdd_XML_reader.
0104 No factory with name Create(lccdd_XML_reader) for type lccdd_XML_reader found.
0105 Please check library load path and/or plugin factory name.
0106 ```