Skip to content

Commit e233c7f

Browse files
committed
Additional syntax improvements
1 parent f8cd590 commit e233c7f

1 file changed

Lines changed: 38 additions & 30 deletions

File tree

tutorial_basics.rst

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,30 @@ For the rest of this section, we'll ignore these components and focus on the pac
7979

8080
Spack can install software either from source or from a binary cache.
8181
Packages in the binary cache are signed with GPG for security.
82-
For the tutorial we prepared a binary cache so we don't have to wait on slow compilation from source.
82+
For this tutorial, we've prepared a binary cache so we don't have to wait for slow compilation from source.
83+
8384
To enable installation from the binary cache, we'll need to configure Spack with the location of the cache and trust the GPG key that the cache was signed with.
8485

8586
.. literalinclude:: outputs/basics/mirror.out
8687
:language: console
8788

88-
We'll learn more about configuring Spack later in the tutorial, but for now we will be able to install the rest of the packages in the tutorial from the cache using the same ``spack install`` command.
89-
By default this will install the binary cached version if it exists and fall back to install the package from source if it does not.
89+
We'll learn more about configuring Spack later in the tutorial, but for now we can install the rest of the packages in the tutorial from the cache using the same ```spack install``` command.
90+
By default, this will install the binary cached version if it exists and fall back to installing the package from source if it does not.
9091

92+
Now that we understand how Spack handles installations, let's explore how we can customize what gets installed.
9193
Spack's "spec" syntax is the interface by which we can request specific configurations of a package.
92-
The ``%`` sigil is used to specify compilers.
94+
The ``%`` sigil is used to specify direct dependencies like a package's compiler.
95+
For example, we can install zlib (a commonly used compression library), but instead of building it with the GCC compiler as we did for gmake previously, we'll install it with ``%clang`` to build it on top of the clang compiler.
9396

9497
.. literalinclude:: outputs/basics/zlib-clang.out
9598
:language: console
9699

97-
Note that this installation is located separately from the previous one.
98-
We will discuss this in more detail later, but this is part of what allows Spack to support many versions of software packages.
100+
Notice that this installation is located separately from the previous one.
101+
We'll explore this concept in more detail later, but this separation is fundamental to how Spack supports multiple configurations and versions of software packages simultaneously.
99102

100-
You can check for particular versions before requesting them.
101-
We will use the ``spack versions`` command to see the available versions, and then install a different version of ``zlib-ng``.
103+
Now that we've seen how Spack handles separate installations, let's explore this capability further by installing multiple versions of the same package.
104+
Before we install additional versions, we can check what versions are available to us using the ```spack versions``` command.
105+
Let's check what versions of zlib-ng are available, and then we'll install a different version to demonstrate Spack's flexibility in managing multiple package versions.
102106

103107
.. literalinclude:: outputs/basics/versions-zlib.out
104108
:language: console
@@ -111,47 +115,51 @@ The ``@`` sigil is used to specify versions, both of packages and of compilers.
111115
.. literalinclude:: outputs/basics/zlib-gcc-10.out
112116
:language: console
113117

114-
The spec syntax also includes compiler flags.
115-
Spack accepts ``cppflags``, ``cflags``, ``cxxflags``, ``fflags``, ``ldflags``, and ``ldlibs`` parameters.
116-
The values of these fields must be quoted on the command line if they include spaces.
117-
These values are injected into the compilation commands automatically by the Spack compiler wrappers.
118+
The spec syntax in Spack also supports compiler flags.
119+
We can specify parameters such as ``cppflags``, ``cflags``, ``cxxflags``, ``fflags``, ``ldflags``, and ``ldlibs``.
120+
If any of these values contain spaces, we'll need to enclose them in quotes on the command line.
121+
Spack’s compiler wrappers will automatically inject these flags into the appropriate compilation commands.
118122

119123
.. literalinclude:: outputs/basics/zlib-O3.out
120124
:language: console
121125

122-
The ``spack find`` command is used to query installed packages.
123-
Note that some packages appear identical with the default output.
124-
The ``-l`` flag shows the hash of each package, and the ``-f`` flag shows any non-empty compiler flags of those packages.
126+
After installing packages, we can use the ``spack find`` command to query which packages are installed.
127+
Notice that by default, some installed packages appear identical in the output.
128+
To help distinguish between them, we can add the ``-l`` flag to display each package’s unique hash.
129+
Additionally if we include the ``-f`` flag, Spack will show any non-empty compiler flags that were used during installation.
130+
131+
We use the ``spack find`` command to query which packages are installed.
132+
Note that, with the default output, some packages may appear identical. To distinguish between them, we can use the ``-l`` flag to display the hash of each package.
133+
Additionally, if we include the ``-f`` flag, Spack will show any non-empty compiler flags that were used during installation.
125134

126135
.. literalinclude:: outputs/basics/find.out
127136
:language: console
128137

129138
.. literalinclude:: outputs/basics/find-lf.out
130139
:language: console
131140

132-
Spack generates a hash for each spec.
133-
This hash is a function of the full provenance of the package, so any change to the spec affects the hash.
134-
Spack uses this value to compare specs and to generate unique installation directories for every combinatorial version.
135-
As we move into more complicated packages with software dependencies, we can see that Spack reuses existing packages to satisfy a dependency.
136-
By default, Spack tries hard to reuse existing installations as dependencies, either from a local store or from configured remote binary caches.
137-
This minimizes unwanted rebuilds of common dependencies, in particular if you update Spack frequently.
141+
Spack generates a unique hash for each spec we define.
142+
This hash reflects the complete provenance of the package, so any change to the spec—such as compiler version, build options, or dependencies—will result in a different hash.
143+
Spack uses these hashes both to compare specs and to create unique installation directories for every possible configuration.
144+
145+
As we work with more complex packages that have multiple software dependencies, we will see that Spack efficiently reuses existing packages to satisfy dependency requirements.
146+
By default, Spack prioritizes reusing installations that already exist, whether they are stored locally or available from configured remote binary caches.
147+
This approach helps us avoid unnecessary rebuilds of common dependencies, which is especially valuable if we update Spack frequently.
138148

139149
.. literalinclude:: outputs/basics/tcl.out
140150
:language: console
141151

142-
Dependencies can be explicitly requested using the ``^`` sigil.
143-
Note that the spec syntax is recursive.
144-
Anything we could specify about the top-level package, we can also specify about a dependency using ``^``.
152+
When we need to specify dependencies explicitly, we use the ``^`` sigil in the spec syntax. The syntax is recursive, meaning that anything we can specify for the top-level package can also be specified for a dependency using ``^``. This allows us to precisely control the configuration of both packages and their dependencies.
145153

146154
.. literalinclude:: outputs/basics/tcl-zlib-clang.out
147155
:language: console
148156

149-
Packages can also be referred to from the command line by their package hash.
150-
Using the ``spack find -lf`` command earlier we saw that the hash of our optimized installation of zlib-ng (``cflags="-O3"``) began with ``umrbkwv``.
151-
We can now explicitly build with that package without typing the entire spec, by using the ``/`` sigil to refer to it by hash.
152-
As with other tools like Git, you do not need to specify an *entire* hash on the command line.
153-
You can specify just enough digits to identify a hash uniquely.
154-
If a hash prefix is ambiguous (i.e., two or more installed packages share the prefix) then Spack will report an error.
157+
We can also refer to packages from the command line by their package hash.
158+
Earlier, when we used the ``spack find -lf`` command, we saw that the hash for our optimized installation of zlib-ng (with ``cflags="-O3"``) began with ``umrbkwv``.
159+
Instead of typing out the entire spec, we can now build explicitly with that package by using the ``/`` sigil followed by its hash.
160+
161+
Similar to tools like Git, we do not need to enter the entire hash on the command line—just enough digits to uniquely identify the package.
162+
If the prefix we provide matches more than one installed package, Spack will report an error and prompt us to be more specific.
155163

156164
.. literalinclude:: outputs/basics/tcl-zlib-hash.out
157165
:language: console

0 commit comments

Comments
 (0)