You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial_packaging.rst
+35-33Lines changed: 35 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ Creating the Package File
53
53
.. note::
54
54
55
55
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>`_.
57
57
58
58
59
59
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
73
73
74
74
You should now be in your text editor of choice, with the ``package.py`` file open for editing.
75
75
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``.
77
77
78
78
Take a moment to look over the file.
79
79
80
80
As we can see from the skeleton contents, the Spack template:
81
81
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;
84
84
* imports and inherits from the inferred `build system package <https://spack.readthedocs.io/en/latest/build_systems.html>`_;
85
85
* provides a docstring template;
86
86
* provides an example homepage URL;
@@ -89,8 +89,8 @@ As we can see from the skeleton contents, the Spack template:
89
89
* 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>`_;
90
90
* lists the inferred language and other build `dependencies <https://spack.readthedocs.io/en/latest/packaging_guide_creation.html#dependencies>`_;
91
91
* 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.
94
94
95
95
The areas we need to modify are highlighted in the figure below.
96
96
@@ -101,8 +101,8 @@ The areas we need to modify are highlighted in the figure below.
101
101
102
102
.. note::
103
103
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.
106
106
This information is useful for developers who maintain a Spack package for their own software and/or rely on software maintained by others.
107
107
108
108
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
123
123
124
124
We will now fill in the provided placeholders and customize the package for the software as we:
125
125
126
-
* document some information about this package;
126
+
* document key information about this package;
127
127
* add dependencies; and
128
128
* add the configuration arguments needed to build the package.
129
129
@@ -141,11 +141,11 @@ Bring ``tutorial-mpileaks``' ``package.py`` file back up in your editor with the
141
141
142
142
Let's make the following changes:
143
143
144
-
* remove the boilerplate between dashed lines at the top;
144
+
* remove the boilerplate comments between and including the dashed lines at the top;
145
145
* replace the first ``FIXME`` comment with a description of ``mpileaks``
146
146
in the docstring;
147
147
* 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
149
149
* replace the ``license`` of the project with the correct name and the placeholder with your GitHub user name.
150
150
151
151
.. tip::
@@ -184,30 +184,28 @@ Also notice it shows:
184
184
* the preferred version derived from the code;
185
185
* the default ``Autotools`` package `installation phases <https://spack.readthedocs.io/en/latest/build_systems/autotoolspackage.html#phases>`_;
186
186
* 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``.
188
188
189
189
As we fill in more information about the package, the ``spack info`` command will become more informative.
190
190
191
191
.. note::
192
192
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>`_.
194
194
195
195
The full list of build systems known to Spack can be found at `Build Systems <https://spack.readthedocs.io/en/latest/build_systems.html>`_.
196
196
197
-
Refer to the links at the end of this section for more information.
198
-
199
197
Now we're ready to start filling in the build recipe.
200
198
201
-
.. note::
199
+
.. tip::
202
200
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.
204
202
205
203
-------------------
206
204
Adding Dependencies
207
205
-------------------
208
206
209
207
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:
211
209
212
210
* ``mpi``,
213
211
* ``adept-utils``, and
@@ -227,7 +225,7 @@ and add the dependencies by specifying them using the ``depends_on`` directive a
@@ -443,15 +444,16 @@ Notice the addition of the two stack start arguments in the configure command th
443
444
444
445
.. note::
445
446
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..
447
449
448
450
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.
449
451
450
452
------------
451
453
Adding Tests
452
454
------------
453
455
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.
455
457
456
458
If we look at a successful installation, we can see that the following directories are installed:
457
459
@@ -465,7 +467,7 @@ Bring ``tutorial-mpileaks``' ``package.py`` file back up with the ``spack edit``
@@ -476,20 +478,20 @@ Since these are `build-time tests <https://spack.readthedocs.io/en/latest/packag
476
478
477
479
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``.
This only scratches the surface of testing an installation.
494
+
The material covered here only scratches the surface of testing an installation.
493
495
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>`_.
494
496
495
497
@@ -571,10 +573,10 @@ Spack has thousands of built-in packages that can serve as examples to guide the
571
573
572
574
.. tip::
573
575
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.
575
577
576
578
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.
578
580
579
581
----------------------
580
582
Multiple Build Systems
@@ -619,7 +621,7 @@ We also need to explicitly specify the ``build_system`` directive, and add condi
619
621
depends_on("autoconf", type="build")
620
622
depends_on("libtools", type="build")
621
623
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.
623
625
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.
624
626
625
627
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