Skip to content

Commit 9915291

Browse files
alecbcscmelone
andauthored
Rewriting the start of the basics tutorial (#443)
* Rewriting the start of the basics tutorial * Additional syntax improvements * Additional syntax improvements * Fix style for sentences * Update tutorial_basics.rst Co-authored-by: Caetano Melone <cmelone@users.noreply.github.com> * Update tutorial_basics.rst Co-authored-by: Caetano Melone <cmelone@users.noreply.github.com> * Command line not command-line * Update tutorial_basics.rst Co-authored-by: Caetano Melone <cmelone@users.noreply.github.com> * Update tutorial_basics.rst Co-authored-by: Caetano Melone <cmelone@users.noreply.github.com> * Remove original text for rewrite --------- Co-authored-by: Caetano Melone <cmelone@users.noreply.github.com>
1 parent 0c52476 commit 9915291

1 file changed

Lines changed: 52 additions & 48 deletions

File tree

tutorial_basics.rst

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@
88
Basic Installation Tutorial
99
=========================================
1010

11-
This tutorial will guide you through the process of installing software using Spack.
12-
We will first cover the ``spack install`` command, focusing on the power of the spec syntax and the flexibility it gives to users.
13-
We will also cover the ``spack find`` command for viewing installed packages and the ``spack uninstall`` command for uninstalling them.
14-
Finally, we will touch on how Spack manages compilers, especially as it relates to using Spack-built compilers within Spack.
15-
We will include full output from all of the commands demonstrated, although we will frequently call attention to only small portions of that output (or merely to the fact that it succeeded).
16-
The provided output is all from an Ubuntu 22.04 Docker image.
11+
This tutorial will provide a step-by-step guide for installing software with Spack.
12+
We will begin by introducing the ``spack install`` command, highlighting the versatility of Spack’s spec syntax and the flexibility it offers users.
13+
Next, we will demonstrate how to use the ``spack find`` command to view installed packages, as well as the ``spack uninstall`` command to remove them.
14+
15+
Additionally, we will discuss how Spack manages compilers, with a particular focus on using Spack-built compilers within the Spack environment.
16+
Throughout the tutorial, we will present complete command outputs; however, we will often emphasize only the most relevant sections or simply confirm successful execution.
17+
All examples and outputs are based on an Ubuntu 22.04 Docker image.
1718

1819
.. _basics-tutorial-install:
1920

2021
----------------
2122
Installing Spack
2223
----------------
2324

24-
Spack works out of the box.
25-
Simply clone Spack to get going.
26-
We will clone Spack and immediately check out the most recent release, v0.23.
25+
Spack is ready to use immediately after installation.
26+
To get started, we simply clone the Spack repository and check out the latest release, v1.0.
2727

2828
.. literalinclude:: outputs/basics/clone.out
2929
:language: console
3030

31-
Next, add Spack to your path.
32-
Spack has some nice command line integration tools, so instead of simply prepending to your ``PATH`` variable, source the Spack setup script.
31+
Next, we'll add Spack to our path.
32+
Spack has some nice command line integration tools, so instead of simply prepending to our ``PATH`` variable, we'll source the Spack setup script.
3333

3434
.. code-block:: console
3535
3636
$ . share/spack/setup-env.sh
3737
38-
You're good to go!
38+
And now we're good to go!
3939

4040
-----------------
4141
What is in Spack?
@@ -49,8 +49,8 @@ The ``spack list`` command shows available packages.
4949

5050

5151
The ``spack list`` command can also take a query string.
52-
Spack automatically adds wildcards to both ends of the string, or you can add your own wildcards.
53-
For example, we can view all available Python packages.
52+
Spack automatically adds wildcards to both ends of the string, or we can add our own wildcards for more advanced searches.
53+
For example, let's view all available Python packages.
5454

5555
.. literalinclude:: outputs/basics/list-py.out
5656
:language: console
@@ -61,7 +61,7 @@ Installing Packages
6161
-------------------
6262

6363
Installing a package with Spack is very simple.
64-
To install a piece of software simply type,
64+
To install a software package, type:
6565

6666
.. code-block:: console
6767
@@ -72,33 +72,37 @@ Let's go ahead and install ``gmake``,
7272
.. literalinclude:: outputs/basics/gmake.out
7373
:language: console
7474

75-
You will see Spack installed ``gmake``, ``gcc-runtime``, and ``glibc``.
75+
We see Spack installed ``gmake``, ``gcc-runtime``, and ``glibc``.
7676
The ``glibc`` and ``gcc-runtime`` packages are automatically tracked by Spack to manage consistency requirements among compiler runtimes.
7777
They do not represent separate software builds from source, but are records of the system's compiler runtime components Spack used for the install.
78-
For the rest of this section, we will ignore these components and focus on the packages explicitly installed.
78+
For the rest of this section, we'll ignore these components and focus on the packages explicitly installed.
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 have prepared a binary cache so you don't have to wait on slow compilation from source.
83-
To be able to install from the binary cache, we will need to configure Spack with the location of the binary cache and trust the GPG key that the binary cache was signed with.
82+
For this tutorial, we've prepared a binary cache so we don't have to wait for slow compilation from source.
83+
84+
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-
You'll learn more about configuring Spack later in the tutorial, but for now you will be able to install the rest of the packages in the tutorial from a binary cache using the same ``spack install`` command.
89-
By default this will install the binary cached version if it exists and fall back on installing 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 by installing multiple versions of the same package.
104+
Before we install additional versions, we can check the versions 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,47 @@ 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.
125130

126131
.. literalinclude:: outputs/basics/find.out
127132
:language: console
128133

129134
.. literalinclude:: outputs/basics/find-lf.out
130135
:language: console
131136

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.
137+
Spack generates a unique hash for each spec we define.
138+
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.
139+
Spack uses these hashes both to compare specs and to create unique installation directories for every possible configuration.
140+
141+
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.
142+
By default, Spack prioritizes reusing installations that already exist, whether they are stored locally or available from configured remote binary caches.
143+
This approach helps us avoid unnecessary rebuilds of common dependencies, which is especially valuable if we update Spack frequently.
138144

139145
.. literalinclude:: outputs/basics/tcl.out
140146
:language: console
141147

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 ``^``.
148+
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.
145149

146150
.. literalinclude:: outputs/basics/tcl-zlib-clang.out
147151
:language: console
148152

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.
153+
We can also refer to packages from the command line by their package hash.
154+
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``.
155+
Instead of typing out the entire spec, we can now build explicitly with that package by using the ``/`` sigil followed by its hash.
156+
157+
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.
158+
If the prefix we provide matches more than one installed package, Spack will report an error and prompt us to be more specific.
155159

156160
.. literalinclude:: outputs/basics/tcl-zlib-hash.out
157161
:language: console

0 commit comments

Comments
 (0)