Skip to content

Commit 7dce079

Browse files
committed
Another pass with tweaks and link corrections
Signed-off-by: tldahlgren <dahlgren1@llnl.gov>
1 parent 34587f6 commit 7dce079

1 file changed

Lines changed: 35 additions & 33 deletions

File tree

tutorial_packaging.rst

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Creating the Package File
5353
.. note::
5454

5555
Before proceeding, make sure your ``SPACK_EDITOR``, ``VISUAL``, or ``EDITOR`` environment variable is set to the name or path of your preferred text editor.
56-
Details can be found at `<https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#controlling-the-editor>`_.
56+
Details can be found at `Controlling the Editor <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#controlling-the-editor>`_.
5757

5858

5959
Suppose you want to install software that depends on mpileaks but found Spack did not already have a built-in package for it.
@@ -73,14 +73,14 @@ Spack will look at the contents of the tarball and generate a package when we ru
7373

7474
You should now be in your text editor of choice, with the ``package.py`` file open for editing.
7575

76-
Your ``package.py`` file should reside in the ``tutorial-mpileaks`` subdirectory of your tutorial repository's ``packages`` directory, i.e., ``/home/spack/repos/spack_repo/tutorial/packages/tutorial_mpileaks/package.py``.
76+
Your ``package.py`` file should reside in the ``tutorial-mpileaks`` subdirectory of your ``tutorial`` repository's ``packages`` directory, i.e., ``/home/spack/repos/spack_repo/tutorial/packages/tutorial_mpileaks/package.py``.
7777

7878
Take a moment to look over the file.
7979

8080
As we can see from the skeleton contents, the Spack template:
8181

82-
* provides the required Spack copyright and license;
83-
* provides information on the commands for installing and editing the package;
82+
* provides the **required** Spack copyright and license;
83+
* provides boilerplate information on the commands for installing and editing the package;
8484
* imports and inherits from the inferred `build system package <https://spack.readthedocs.io/en/latest/build_systems.html>`_;
8585
* provides a docstring template;
8686
* provides an example homepage URL;
@@ -89,8 +89,8 @@ As we can see from the skeleton contents, the Spack template:
8989
* specifies the `version directive <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#versions-and-urls>`_ with the `checksum <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#checksum-verification>`_;
9090
* lists the inferred language and other build `dependencies <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#dependencies>`_;
9191
* provides a skeleton for another dependency;
92-
* provides a preliminary implementation of the `autoreconf method <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#using-a-custom-autoreconf-phase>`_; and
93-
* provides a skeleton `configure_args method <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#adding-flags-to-configure>`_.
92+
* provides a preliminary implementation of the `autoreconf <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#using-a-custom-autoreconf-phase>`_ method; and
93+
* provides a skeleton `configure_args <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#adding-flags-to-configure>`_ method.
9494

9595
The areas we need to modify are highlighted in the figure below.
9696

@@ -101,8 +101,8 @@ The areas we need to modify are highlighted in the figure below.
101101

102102
.. note::
103103

104-
The `maintainers directive <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#maintainers>`_ holds a comma-separated list of **GitHub user name**s for those accounts willing to be notified when a change is made to the package.
105-
They will be given an opportunity to review the changes.
104+
The `maintainers directive <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#maintainers>`_ holds a comma-separated list of GitHub user names for those accounts willing to be notified when a change is made to the package.
105+
They will also be given an opportunity to review the changes.
106106
This information is useful for developers who maintain a Spack package for their own software and/or rely on software maintained by others.
107107

108108
Since we are providing a ``url``, we can `confirm the checksum <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#checksum-verification>`_, or ``sha256`` calculation.
@@ -123,7 +123,7 @@ The error indicates ``configure`` is unable to find the installation location of
123123

124124
We will now fill in the provided placeholders and customize the package for the software as we:
125125

126-
* document some information about this package;
126+
* document key information about this package;
127127
* add dependencies; and
128128
* add the configuration arguments needed to build the package.
129129

@@ -141,11 +141,11 @@ Bring ``tutorial-mpileaks``' ``package.py`` file back up in your editor with the
141141
142142
Let's make the following changes:
143143

144-
* remove the boilerplate between dashed lines at the top;
144+
* remove the boilerplate comments between and including the dashed lines at the top;
145145
* replace the first ``FIXME`` comment with a description of ``mpileaks``
146146
in the docstring;
147147
* replace the ``homepage`` property with the correct link;
148-
* uncomment the ``maintainers`` directive and add your GitHub user name; and
148+
* uncomment the ``maintainers`` directive and replace the placeholder with your GitHub user name; and
149149
* replace the ``license`` of the project with the correct name and the placeholder with your GitHub user name.
150150

151151
.. tip::
@@ -184,30 +184,28 @@ Also notice it shows:
184184
* the preferred version derived from the code;
185185
* the default ``Autotools`` package `installation phases <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#phases>`_;
186186
* the `gmake <https://github.com/spack/spack-packages/blob/c27b98c74c41e6b1000215d4fc5661aa6841694d/repos/spack_repo/builtin/build_systems/autotools.py#L62>`_ and `gnuconfig <https://github.com/spack/spack-packages/blob/c27b98c74c41e6b1000215d4fc5661aa6841694d/repos/spack_repo/builtin/build_systems/autotools.py#L60>`_ build dependencies inherited from ``AutotoolsPackage``; and
187-
* both the link and run dependencies are currently ``None``.
187+
* both link and run dependencies are currently ``None``.
188188

189189
As we fill in more information about the package, the ``spack info`` command will become more informative.
190190

191191
.. note::
192192

193-
More information on using Autotools packages is provided in `AutotoolsPackage <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#phases>`_.
193+
More information on this build system package is provided in `AutotoolsPackage <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#autotools>`_.
194194

195195
The full list of build systems known to Spack can be found at `Build Systems <https://spack.readthedocs.io/en/latest/build_systems.html>`_.
196196

197-
Refer to the links at the end of this section for more information.
198-
199197
Now we're ready to start filling in the build recipe.
200198

201-
.. note::
199+
.. tip::
202200

203-
Refer to the `style guide <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#style-guidelines-for-packages>`_ for more information.
201+
Refer to the `style guide <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#style-guidelines-for-packages>`_ for Spack's guidelines.
204202

205203
-------------------
206204
Adding Dependencies
207205
-------------------
208206

209207
First we'll add the dependencies determined by reviewing documentation in the software's repository (https://github.com/LLNL/mpileaks).
210-
The ``mpileaks`` software relies on three third-party libraries:
208+
We can see from the ``README`` file's instructions, ``mpileaks`` software relies on three third-party libraries:
211209

212210
* ``mpi``,
213211
* ``adept-utils``, and
@@ -227,7 +225,7 @@ and add the dependencies by specifying them using the ``depends_on`` directive a
227225

228226
.. literalinclude:: tutorial/examples/packaging/2.package.py
229227
:caption: tutorial-mpileaks/package.py (from tutorial/examples/packaging/2.package.py)
230-
:lines: 6-
228+
:lines: 5-
231229
:language: python
232230
:emphasize-lines: 25-27
233231

@@ -271,6 +269,9 @@ Our options for proceeding are:
271269
* review the build log; and
272270
* build the package manually.
273271

272+
273+
.. _reviewing_build_log:
274+
274275
~~~~~~~~~~~~~~~~~~~~~~~
275276
Reviewing the Build Log
276277
~~~~~~~~~~~~~~~~~~~~~~~
@@ -321,7 +322,7 @@ This command spawned a new shell containing the same environment that Spack used
321322
If you are running using an AWS instance, you'll want to substitute your home directory for ``/home/spack`` below.
322323

323324
From here we can manually re-run the build using the ``configure`` command with the ``--prefix`` option that Spack passed in the failed build.
324-
If you aren't sure, check the appropriate line under ``Executing phase: 'configure'`` in the build log in :ref:`Reviewing the Build Log`.
325+
If you aren't sure, check the appropriate line under ``Executing phase: 'configure'`` in the build log in :ref:`reviewing_build_log`.
325326

326327
.. literalinclude:: outputs/packaging/build-env-configure.out
327328
:language: console
@@ -373,9 +374,9 @@ and add the ``--with-adept-utils`` and ``--with-callpath`` arguments in the ``co
373374

374375
.. literalinclude:: tutorial/examples/packaging/3.package.py
375376
:caption: tutorial-mpileaks/package.py (from tutorial/examples/packaging/3.package.py)
376-
:lines: 6-
377+
:lines: 5-
377378
:language: python
378-
:emphasize-lines: 32-36
379+
:emphasize-lines: 33-36
379380

380381
Since this is an ``AutotoolsPackage``, the arguments returned from the method will automatically get passed to ``configure`` during the build.
381382

@@ -427,7 +428,7 @@ and add the ``variant`` directive and associated arguments as follows:
427428

428429
.. literalinclude:: tutorial/examples/packaging/4.package.py
429430
:caption: tutorial-mpileaks/package.py (from tutorial/examples/packaging/4.package.py)
430-
:lines: 6-
431+
:lines: 5-
431432
:language: python
432433
:emphasize-lines: 16-21,45-52
433434

@@ -443,15 +444,16 @@ Notice the addition of the two stack start arguments in the configure command th
443444

444445
.. note::
445446

446-
``Autotools`` is one of several packages that implement `helper functions <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#helper-functions>`_ to simplify setting options tied to variants.
447+
Not all packages have such simple options.
448+
Fortunately, ``Autotools`` is one of several packages that implement `helper functions <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#helper-functions>`_ to simplify setting arguments tied to boolean and multi-valued variants..
447449

448450
Now that we have a package we can build, it's time to consider adding tests that can be used to gain confidence that the software works.
449451

450452
------------
451453
Adding Tests
452454
------------
453455

454-
The simplest tests we can add are `sanity checks <https://spack.readthedocs.io/en/latest/packaging_guide_testing.html#adding-sanity-checks>`_, which can be used to ensure the directories and files we expect to be installed for all versions of the package actually exist.
456+
The simplest tests we can add are `sanity checks <https://spack.readthedocs.io/en/latest/packaging_guide_testing.html#adding-sanity-checks>`_, which can be used to ensure the directories and or files we expect to be installed for all versions of the package actually exist.
455457

456458
If we look at a successful installation, we can see that the following directories are installed:
457459

@@ -465,7 +467,7 @@ Bring ``tutorial-mpileaks``' ``package.py`` file back up with the ``spack edit``
465467

466468
.. literalinclude:: tutorial/examples/packaging/5.package.py
467469
:caption: tutorial-mpileaks/package.py (from tutorial/examples/packaging/5.package.py)
468-
:lines: 6-
470+
:lines: 5-
469471
:language: python
470472
:emphasize-lines: 14
471473

@@ -476,20 +478,20 @@ Since these are `build-time tests <https://spack.readthedocs.io/en/latest/packag
476478

477479
Notice the installation fails due to the missing directory with the error: ``Error: InstallError: Install failed for tutorial-mpileaks. No such directory in prefix: shar``.
478480

479-
Now let's fix the error and try again:
481+
Now let's properly fix the error and try again:
480482

481483
.. literalinclude:: tutorial/examples/packaging/6.package.py
482484
:caption: tutorial-mpileaks/package.py (from tutorial/examples/packaging/6.package.py)
483-
:lines: 6-
485+
:lines: 5-
484486
:language: python
485487
:emphasize-lines: 14
486488

487-
Installing again we can see we fixed the problem.
489+
Success!
488490

489491
.. literalinclude:: outputs/packaging/install-mpileaks-6.out
490492
:language: console
491493

492-
This only scratches the surface of testing an installation.
494+
The material covered here only scratches the surface of testing an installation.
493495
We could leverage the examples from this package to add `post-install phase tests <https://spack.readthedocs.io/en/latest/packaging_guide_testing.html#adding-installation-phase-tests>`_ and/or `stand-alone tests <https://spack.readthedocs.io/en/latest/packaging_guide_testing.html#stand-alone-tests>`_.
494496

495497

@@ -571,10 +573,10 @@ Spack has thousands of built-in packages that can serve as examples to guide the
571573

572574
.. tip::
573575

574-
You can find these packages in the ``spack/spack-packages`` repository's ``repos/spack_repo/builtin/packages`` directory.
576+
You can find these packages under the `spack/spack-packages <https://github.com/spack/spack-packages> repository's ``repos/spack_repo/builtin/packages`` directory.
575577

576578
Or use `spack pkg grep <https://spack.readthedocs.io/en/latest/command_index.html#spack-pkg>`_ to perform a query.
577-
For example, to find the paths to all builtin ``AutotoolsPackage`` packages, you can enter ``spack pkg grep AutotoolsPackage | sed "s/:.*##g" | sort -u``, which will search the packages in all of your configured repositories.
579+
For example, to find the paths to all builtin ``AutotoolsPackage`` packages, you can enter ``spack pkg grep AutotoolsPackage | sed "s/:.*//g" | sort -u``, which will search the packages in all of your configured repositories.
578580

579581
----------------------
580582
Multiple Build Systems
@@ -619,7 +621,7 @@ We also need to explicitly specify the ``build_system`` directive, and add condi
619621
depends_on("autoconf", type="build")
620622
depends_on("libtools", type="build")
621623
622-
As we saw with `tutorial-mpileaks <info_mpileaks>`, each spec has a ``build_system`` variant that specifies the build system it uses.
624+
As we saw with :ref:`tutorial-mpileaks <info_mpileaks>`, each spec has a ``build_system`` variant that specifies the build system it uses.
623625
In most cases that variant has a single allowed value, inherited from the corresponding base package - so, usually, you don't have to think about it.
624626

625627
When your package supports more than one build system though, you have to explicitly declare which ones are allowed and under what conditions.

0 commit comments

Comments
 (0)