Update Package Creation Tutorial for PEARC19 (#12209)

* Update Package Creation Tutorial for PEARC19

* A few remaining fixes

* Fix section link
This commit is contained in:
Adam J. Stewart 2019-07-31 12:54:09 -05:00 committed by GitHub
parent 65a1db87f8
commit f7d1df4d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 250 additions and 237 deletions

View File

@ -26,9 +26,9 @@ class Mpileaks(Package):
# FIXME: Add a proper url for your package's homepage here. # FIXME: Add a proper url for your package's homepage here.
homepage = "http://www.example.com" homepage = "http://www.example.com"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa') version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
# FIXME: Add dependencies if required. # FIXME: Add dependencies if required.
# depends_on('foo') # depends_on('foo')

View File

@ -10,9 +10,10 @@ class Mpileaks(Package):
"""Tool to detect and report MPI objects like MPI_Requests and """Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes.""" MPI_Datatypes."""
homepage = "https://github.com/hpc/mpileaks" homepage = "https://github.com/LLNL/mpileaks"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" # NOQA url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa')
version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
# FIXME: Add dependencies if required. # FIXME: Add dependencies if required.
# depends_on('foo') # depends_on('foo')

View File

@ -10,10 +10,10 @@ class Mpileaks(Package):
"""Tool to detect and report MPI objects like MPI_Requests and """Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes.""" MPI_Datatypes."""
homepage = "https://github.com/hpc/mpileaks" homepage = "https://github.com/LLNL/mpileaks"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa') version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
depends_on('mpi') depends_on('mpi')
depends_on('adept-utils') depends_on('adept-utils')

View File

@ -10,10 +10,10 @@ class Mpileaks(Package):
"""Tool to detect and report MPI objects like MPI_Requests and """Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes.""" MPI_Datatypes."""
homepage = "https://github.com/hpc/mpileaks" homepage = "https://github.com/LLNL/mpileaks"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa') version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
depends_on('mpi') depends_on('mpi')
depends_on('adept-utils') depends_on('adept-utils')

View File

@ -10,18 +10,18 @@ class Mpileaks(Package):
"""Tool to detect and report MPI objects like MPI_Requests and """Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes.""" MPI_Datatypes."""
homepage = "https://github.com/hpc/mpileaks" homepage = "https://github.com/LLNL/mpileaks"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa') version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
depends_on('mpi') depends_on('mpi')
depends_on('adept-utils') depends_on('adept-utils')
depends_on('callpath') depends_on('callpath')
def install(self, spec, prefix): def install(self, spec, prefix):
configure('--with-adept-utils=%s' % self.spec['adept-utils'].prefix, configure('--prefix={0}'.format(prefix),
'--with-callpath=%s' % self.spec['callpath'].prefix, '--with-adept-utils={0}'.format(spec['adept-utils'].prefix),
'--prefix=%s' % self.spec.prefix) '--with-callpath={0}'.format(spec['callpath'].prefix))
make() make()
make('install') make('install')

View File

@ -10,25 +10,33 @@ class Mpileaks(Package):
"""Tool to detect and report MPI objects like MPI_Requests and """Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes.""" MPI_Datatypes."""
homepage = "https://github.com/hpc/mpileaks" homepage = "https://github.com/LLNL/mpileaks"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa') version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
variant('stackstart', values=int, default=0, description='Specify the number of stack frames to truncate.') variant('stackstart', values=int, default=0,
description='Specify the number of stack frames to truncate')
depends_on('mpi') depends_on('mpi')
depends_on('adept-utils') depends_on('adept-utils')
depends_on('callpath') depends_on('callpath')
def install(self, spec, prefix): def install(self, spec, prefix):
stackstart = int(self.spec.variants['stackstart'].value) stackstart = int(spec.variants['stackstart'].value)
confargs = ['--with-adept-utils=%s' % self.spec['adept-utils'].prefix,
'--with-callpath=%s' % self.spec['callpath'].prefix, args = [
'--prefix=%s' % self.spec.prefix] '--prefix={0}'.format(prefix),
'--with-adept-utils={0}'.format(spec['adept-utils'].prefix),
'--with-callpath={0}'.format(spec['callpath'].prefix),
]
if stackstart: if stackstart:
confargs.extend(['--with-stack-start-c=%s' % stackstart, args.extend([
'--with-stack-start-fortran=%s' % stackstart]) '--with-stack-start-c={0}'.format(stackstart),
configure(*confargs) '--with-stack-start-fortran={0}'.format(stackstart)
])
configure(*args)
make() make()
make('install') make('install')

View File

@ -10,8 +10,8 @@ Package Creation Tutorial
========================= =========================
This tutorial will walk you through the steps behind building a simple This tutorial will walk you through the steps behind building a simple
package installation script. We'll focus building an mpileaks package, package installation script. We'll focus on writing a package for
which is a MPI debugging tool. By creating a package file we're mpileaks, an MPI debugging tool. By creating a package file we're
essentially giving Spack a recipe for how to build a particular piece of essentially giving Spack a recipe for how to build a particular piece of
software. We're describing some of the software's dependencies, where to software. We're describing some of the software's dependencies, where to
find the package, what commands and options are used to build the package find the package, what commands and options are used to build the package
@ -20,7 +20,7 @@ ask Spack to build that package in many different ways.
This tutorial assumes you have a basic familiarity with some of the Spack This tutorial assumes you have a basic familiarity with some of the Spack
commands, and that you have a working version of Spack installed. If commands, and that you have a working version of Spack installed. If
not, we suggest looking at Spack's *Getting Started* guide. This not, we suggest looking at Spack's :ref:`getting_started` guide. This
tutorial also assumes you have at least a beginner's-level familiarity tutorial also assumes you have at least a beginner's-level familiarity
with Python. with Python.
@ -38,8 +38,8 @@ A few things before we get started:
variable ``SPACK_ROOT``. You should point ``SPACK_ROOT`` at wherever variable ``SPACK_ROOT``. You should point ``SPACK_ROOT`` at wherever
you have Spack installed. you have Spack installed.
- Add ``$SPACK_ROOT/bin`` to your ``PATH`` before you start. - Add ``$SPACK_ROOT/bin`` to your ``PATH`` before you start.
- Make sure your ``EDITOR`` environment variable is set to some text - Make sure your ``EDITOR`` environment variable is set to your
editor you like. preferred text editor.
- We'll be writing Python code as part of this tutorial. You can find - We'll be writing Python code as part of this tutorial. You can find
successive versions of the Python code in successive versions of the Python code in
``$SPACK_ROOT/lib/spack/docs/tutorial/examples``. ``$SPACK_ROOT/lib/spack/docs/tutorial/examples``.
@ -67,7 +67,7 @@ we run ``spack create`` on it:
.. code-block:: console .. code-block:: console
$ spack create -t generic -f https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz $ spack create -t generic https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz
==> This looks like a URL for mpileaks ==> This looks like a URL for mpileaks
==> Found 1 version of mpileaks: ==> Found 1 version of mpileaks:
@ -80,15 +80,15 @@ we run ``spack create`` on it:
==> Checksummed 1 version of mpileaks ==> Checksummed 1 version of mpileaks
==> Using specified package template: 'generic' ==> Using specified package template: 'generic'
==> Created template for mpileaks package ==> Created template for mpileaks package
==> Created package file: /home/spack1/spack/var/spack/repos/builtin/packages/mpileaks/package.py ==> Created package file: ~/spack/var/spack/repos/tutorial/packages/mpileaks/package.py
And Spack should spawn a text editor with this file: Spack should spawn a text editor with this file:
.. literalinclude:: tutorial/examples/0.package.py .. literalinclude:: tutorial/examples/0.package.py
:language: python :language: python
Spack has created this file in Spack has created this file in
``/home/spack1/spack/var/spack/repos/builtin/packages/mpileaks/package.py``. Take a ``$SPACK_ROOT/var/spack/repos/tutorial/packages/mpileaks/package.py``. Take a
moment to look over the file. There's a few placeholders that Spack has moment to look over the file. There's a few placeholders that Spack has
created, which we'll fill in as part of this tutorial: created, which we'll fill in as part of this tutorial:
@ -103,14 +103,14 @@ to build this package:
.. code-block:: console .. code-block:: console
$ spack install mpileaks $ spack install mpileaks
==> Installing mpileaks
==> Searching for binary cache of mpileaks
==> Warning: No Spack mirrors are currently configured
==> No binary for mpileaks found: installing from source ==> No binary for mpileaks found: installing from source
==> Fetching file:///mirror/mpileaks/mpileaks-1.0.tar.gz ==> Fetching https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz
curl: (37) Couldn't open file /mirror/mpileaks/mpileaks-1.0.tar.gz ############################################################################# 100.0%
==> Fetching from file:///mirror/mpileaks/mpileaks-1.0.tar.gz failed. ==> Staging archive: ~/spack/var/spack/stage/mpileaks-1.0-sv75n3u5ev6mljwcezisz3slooozbbxu/mpileaks-1.0.tar.gz
==> Fetching https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz ==> Created stage in ~/spack/var/spack/stage/mpileaks-1.0-sv75n3u5ev6mljwcezisz3slooozbbxu
######################################################################## 100.0%
==> Staging archive: /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-sv75n3u5ev6mljwcezisz3slooozbbxu/mpileaks-1.0.tar.gz
==> Created stage in /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-sv75n3u5ev6mljwcezisz3slooozbbxu
==> No patches needed for mpileaks ==> No patches needed for mpileaks
==> Building mpileaks [Package] ==> Building mpileaks [Package]
==> Executing phase: 'install' ==> Executing phase: 'install'
@ -123,12 +123,12 @@ to build this package:
>> 3 make: *** No targets specified and no makefile found. Stop. >> 3 make: *** No targets specified and no makefile found. Stop.
See build log for details: See build log for details:
/home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-sv75n3u5ev6mljwcezisz3slooozbbxu/mpileaks-1.0/spack-build-out.txt ~/spack/var/spack/stage/mpileaks-1.0-sv75n3u5ev6mljwcezisz3slooozbbxu/spack-build-out.txt
This obviously didn't work; we need to fill in the package-specific This obviously didn't work; we need to fill in the package-specific
information. Specifically, Spack didn't try to build any of mpileaks' information. Specifically, Spack didn't try to build any of mpileaks'
dependencies, nor did it use the proper configure arguments. Let's start dependencies, nor did it use the proper configure arguments. Let's start
fixing things fixing things.
--------------------- ---------------------
Package Documentation Package Documentation
@ -141,19 +141,19 @@ We can bring the ``package.py`` file back into our ``EDITOR`` with the
$ spack edit mpileaks $ spack edit mpileaks
Let's remove some of the ``FIXME`` comments, and add links to the mpileaks Let's remove some of the ``FIXME`` comments, add links to the mpileaks
homepage and document what mpileaks does. I'm also going to cut out the homepage, and document what mpileaks does. I'm also going to cut out the
Copyright clause at this point to keep this tutorial document shorter, Copyright clause at this point to keep this tutorial document shorter,
but you shouldn't do that normally. The results of these changes can be but you shouldn't do that normally. The results of these changes can be
found in ``$SPACK_ROOT/lib/spack/docs/tutorial/examples/1.package.py`` found in ``$SPACK_ROOT/lib/spack/docs/tutorial/examples/1.package.py``
and are below. Make these changes to your ``package.py``: and are displayed below. Make these changes to your ``package.py``:
.. literalinclude:: tutorial/examples/1.package.py .. literalinclude:: tutorial/examples/1.package.py
:lines: 6- :lines: 6-
:language: python :language: python
We've filled in the comment that describes what this package does and We've filled in the comment that describes what this package does and
added a link to the web site. That won't help us build yet, but it will added a link to its website. That won't help us build yet, but it will
allow Spack to provide some documentation on this package to other users: allow Spack to provide some documentation on this package to other users:
.. code-block:: console .. code-block:: console
@ -165,16 +165,16 @@ allow Spack to provide some documentation on this package to other users:
Tool to detect and report MPI objects like MPI_Requests and Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes. MPI_Datatypes.
Homepage: https://github.com/hpc/mpileaks Homepage: https://github.com/LLNL/mpileaks
Tags: Tags:
None None
Preferred version: Preferred version:
1.0 https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz 1.0 https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz
Safe versions: Safe versions:
1.0 https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz 1.0 https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz
Variants: Variants:
None None
@ -201,7 +201,7 @@ will become more informative. Now let's start making this package build.
Dependencies Dependencies
------------ ------------
The mpileaks packages depends on three other package: ``MPI``, The mpileaks package depends on three other packages: ``mpi``,
``adept-utils``, and ``callpath``. Let's add those via the ``adept-utils``, and ``callpath``. Let's add those via the
``depends_on`` command in our ``package.py`` (this version is in ``depends_on`` command in our ``package.py`` (this version is in
``$SPACK_ROOT/lib/spack/docs/tutorial/examples/2.package.py``): ``$SPACK_ROOT/lib/spack/docs/tutorial/examples/2.package.py``):
@ -213,37 +213,32 @@ The mpileaks packages depends on three other package: ``MPI``,
Now when we go to build mpileaks, Spack will fetch and build these Now when we go to build mpileaks, Spack will fetch and build these
dependencies before building mpileaks. Note that the mpi dependency is a dependencies before building mpileaks. Note that the mpi dependency is a
different kind of beast than the adept-utils and callpath dependencies; different kind of beast than the adept-utils and callpath dependencies;
there is no mpi package available in Spack. Instead mpi is a virtual there is no mpi package available in Spack. Instead mpi is a *virtual
dependency. Spack may satisfy that dependency by installing packages dependency*. Spack may satisfy that dependency by installing packages
such as ``openmpi`` or ``mvapich``. See the :ref:`packaging-guide` for more such as ``openmpi`` or ``mvapich2``. See the :ref:`packaging-guide` for more
information on virtual dependencies. information on virtual dependencies.
Now when we try to install this package a lot more happens: Now when we try to install this package, a lot more happens:
.. code-block:: console .. code-block:: console
$ spack install mpileaks $ spack install mpileaks
... ...
==> Successfully installed libdwarf from binary cache ==> Successfully installed libdwarf from binary cache
[+] /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/libdwarf-20180129-p4jeflorwlnkoq2vpuyocwrbcht2ayak [+] ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/libdwarf-20180129-p4jeflorwlnkoq2vpuyocwrbcht2ayak
==> Installing callpath ==> Installing callpath
==> Searching for binary cache of callpath ==> Searching for binary cache of callpath
==> Installing callpath from binary cache ==> Installing callpath from binary cache
==> Fetching file:///mirror/build_cache/linux-ubuntu16.04-x86_64/gcc-5.4.0/callpath-1.0.4/linux-ubuntu16.04-x86_64-gcc-5.4.0-callpath-1.0.4-empvyxdkc4j4pwg7gznwhbiumruey66x.spack ==> Fetching file:///mirror/build_cache/linux-ubuntu16.04-x86_64/gcc-5.4.0/callpath-1.0.4/linux-ubuntu16.04-x86_64-gcc-5.4.0-callpath-1.0.4-empvyxdkc4j4pwg7gznwhbiumruey66x.spack
######################################################################## 100.0% ######################################################################## 100.0%
gpg: Signature made Sat 10 Nov 2018 05:30:21 AM UTC using RSA key ID 3B7C69B2
gpg: Good signature from "sc-tutorial (GPG created for Spack) <becker33@llnl.gov>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 95C7 1787 7AC0 0FFD AA8F D6E9 9CFA 4A45 3B7C 69B2
==> Successfully installed callpath from binary cache ==> Successfully installed callpath from binary cache
[+] /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/callpath-1.0.4-empvyxdkc4j4pwg7gznwhbiumruey66x [+] ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/callpath-1.0.4-empvyxdkc4j4pwg7gznwhbiumruey66x
==> Installing mpileaks ==> Installing mpileaks
==> Searching for binary cache of mpileaks ==> Searching for binary cache of mpileaks
==> No binary for mpileaks found: installing from source ==> No binary for mpileaks found: installing from source
==> Using cached archive: /home/ubuntu/packaging/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz ==> Using cached archive: ~/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz
==> Staging archive: /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0.tar.gz ==> Staging archive: ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0.tar.gz
==> Created stage in /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb ==> Created stage in ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb
==> No patches needed for mpileaks ==> No patches needed for mpileaks
==> Building mpileaks [Package] ==> Building mpileaks [Package]
==> Executing phase: 'install' ==> Executing phase: 'install'
@ -256,7 +251,7 @@ Now when we try to install this package a lot more happens:
>> 3 make: *** No targets specified and no makefile found. Stop. >> 3 make: *** No targets specified and no makefile found. Stop.
See build log for details: See build log for details:
/home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0/spack-build-out.txt ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0/spack-build-out.txt
Note that this command may take a while to run and produce more output if Note that this command may take a while to run and produce more output if
you don't have an MPI already installed or configured in Spack. you don't have an MPI already installed or configured in Spack.
@ -273,7 +268,7 @@ Debugging Package Builds
Our ``mpileaks`` package is still not building. It may be obvious to Our ``mpileaks`` package is still not building. It may be obvious to
many of you that we never ran the configure script. Let's add a many of you that we never ran the configure script. Let's add a
call to ``configure()`` to the top of the install routine. The resulting call to ``configure()`` to the top of the install routine. The resulting
package.py is in ``$SPACK_ROOT/lib/spack/docs/tutorial/examples/3.package.py``: ``package.py`` is in ``$SPACK_ROOT/lib/spack/docs/tutorial/examples/3.package.py``:
.. literalinclude:: tutorial/examples/3.package.py .. literalinclude:: tutorial/examples/3.package.py
:lines: 6- :lines: 6-
@ -283,15 +278,15 @@ If we re-run we still get errors:
.. code-block:: console .. code-block:: console
$ spack install mpileask $ spack install mpileaks
... ...
==> Installing mpileaks ==> Installing mpileaks
==> Searching for binary cache of mpileaks ==> Searching for binary cache of mpileaks
==> Finding buildcaches in /mirror/build_cache ==> Finding buildcaches in /mirror/build_cache
==> No binary for mpileaks found: installing from source ==> No binary for mpileaks found: installing from source
==> Using cached archive: /home/ubuntu/packaging/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz ==> Using cached archive: ~/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz
==> Staging archive: /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0.tar.gz ==> Staging archive: ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0.tar.gz
==> Created stage in /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb ==> Created stage in ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb
==> No patches needed for mpileaks ==> No patches needed for mpileaks
==> Building mpileaks [Package] ==> Building mpileaks [Package]
==> Executing phase: 'install' ==> Executing phase: 'install'
@ -299,30 +294,25 @@ If we re-run we still get errors:
'./configure' './configure'
1 error found in build log: 1 error found in build log:
25 checking for /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc- 25 checking for ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/openmpi-3.1.3-3
5.4.0/openmpi-3.1.3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc... /home/ubuntu/pa njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc... ~/spack/opt/spack/linux-ubuntu16.04-
ckaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/openmpi-3.1.3-3njc4q5p x86_64/gcc-5.4.0/openmpi-3.1.3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc
qdpptq6jvqjrezkffwokv2sx/bin/mpicc 26 Checking whether ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/openmpi-3.1
26 Checking whether /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/ .3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '-showme:compile'... no
gcc-5.4.0/openmpi-3.1.3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '- 27 Checking whether ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/openmpi-3.1
showme:compile'... no .3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '-showme'... no
27 Checking whether /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/ 28 Checking whether ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/openmpi-3.1
gcc-5.4.0/openmpi-3.1.3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '- .3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '-compile-info'... no
showme'... no 29 Checking whether ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/openmpi-3.1
28 Checking whether /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/ .3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '-show'... no
gcc-5.4.0/openmpi-3.1.3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '-
compile-info'... no
29 Checking whether /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/
gcc-5.4.0/openmpi-3.1.3-3njc4q5pqdpptq6jvqjrezkffwokv2sx/bin/mpicc responds to '-
show'... no
30 ./configure: line 4809: Echo: command not found 30 ./configure: line 4809: Echo: command not found
>> 31 configure: error: unable to locate adept-utils installation >> 31 configure: error: unable to locate adept-utils installation
See build log for details: See build log for details:
/home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0/spack-build-out.txt ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0/spack-build-out.txt
Again, the problem may be obvious. But let's pretend we're not Again, the problem may be obvious. But let's pretend we're not
all intelligent developers and use this opportunity spend some all experienced Autotools developers and use this opportunity to spend some
time debugging. We have a few options that can tell us about time debugging. We have a few options that can tell us about
what's going wrong: what's going wrong:
@ -364,7 +354,7 @@ finding its ``adept-utils`` package. Spack has
automatically added the include and library directories of automatically added the include and library directories of
``adept-utils`` to the compiler's search path, but some packages like ``adept-utils`` to the compiler's search path, but some packages like
mpileaks can sometimes be picky and still want things spelled out on mpileaks can sometimes be picky and still want things spelled out on
their command line. But let's continue to pretend we're not brilliant their command line. But let's continue to pretend we're not experienced
developers, and explore some other debugging paths: developers, and explore some other debugging paths:
We can also enter the build area and try to manually run the build: We can also enter the build area and try to manually run the build:
@ -374,7 +364,7 @@ We can also enter the build area and try to manually run the build:
$ spack build-env mpileaks bash $ spack build-env mpileaks bash
$ spack cd mpileaks $ spack cd mpileaks
The ``spack env`` command spawned a new shell that contains the same The ``spack build-env`` command spawned a new shell that contains the same
environment that Spack used to build the mpileaks package (you can environment that Spack used to build the mpileaks package (you can
substitute bash for your favorite shell). The ``spack cd`` command substitute bash for your favorite shell). The ``spack cd`` command
changed our working dirctory to the last attempted build for mpileaks. changed our working dirctory to the last attempted build for mpileaks.
@ -415,7 +405,7 @@ the command ourselves and debug as needed. We could, for example, run
dependencies. dependencies.
We can use the ``exit`` command to leave the shell spawned by ``spack We can use the ``exit`` command to leave the shell spawned by ``spack
env``. build-env``.
------------------------------ ------------------------------
Specifying Configure Arguments Specifying Configure Arguments
@ -429,7 +419,7 @@ version can be found in
:lines: 6- :lines: 6-
:language: python :language: python
This is all we need for working mpileaks! If we install now we'll see: This is all we need for a working mpileaks package! If we install now we'll see:
.. code-block:: console .. code-block:: console
@ -439,27 +429,29 @@ This is all we need for working mpileaks! If we install now we'll see:
==> Searching for binary cache of mpileaks ==> Searching for binary cache of mpileaks
==> Finding buildcaches in /mirror/build_cache ==> Finding buildcaches in /mirror/build_cache
==> No binary for mpileaks found: installing from source ==> No binary for mpileaks found: installing from source
==> Using cached archive: /home/ubuntu/packaging/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz ==> Using cached archive: ~/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz
==> Staging archive: /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0.tar.gz ==> Staging archive: ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb/mpileaks-1.0.tar.gz
==> Created stage in /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb ==> Created stage in ~/spack/var/spack/stage/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb
==> No patches needed for mpileaks ==> No patches needed for mpileaks
==> Building mpileaks [Package] ==> Building mpileaks [Package]
==> Executing phase: 'install' ==> Executing phase: 'install'
==> Successfully installed mpileaks ==> Successfully installed mpileaks
Fetch: 0.00s. Build: 9.41s. Total: 9.41s. Fetch: 0.00s. Build: 9.41s. Total: 9.41s.
[+] /home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb [+] ~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/mpileaks-1.0-csoikctsalli4cdkkdk377gprkc472rb
There are some special circumstances in package that are worth highlighting. There are some special circumstances in this package that are worth highlighting.
Normally spack would have automatically detected that mpileaks was an Normally, Spack would have automatically detected that mpileaks was an
Autotools-based package when we ran ``spack create`` and made it an ``AutoToolsPackage`` class (except we added the ``-t generic`` option to skip this). Instead of Autotools-based package when we ran ``spack create`` and made it an ``AutoToolsPackage``
class (except we added the ``-t generic`` option to skip this). Instead of
a full install routine we would have just written: a full install routine we would have just written:
.. code-block:: python .. code-block:: python
def configure_args(self): def configure_args(self):
args = ['--with-adept-utils=%s' % self.spec['adept-utils'].prefix, return [
'--with-callpath=%s' % self.spec['callpath'].prefix] '--with-adept-utils={0}'.format(self.spec['adept-utils'].prefix),
return args '--with-callpath={0}'.format(self.spec['callpath'].prefix)
]
Similarly, if this had been a CMake-based package we Similarly, if this had been a CMake-based package we
would have been filling in a ``cmake_args`` function instead of would have been filling in a ``cmake_args`` function instead of
@ -473,7 +465,7 @@ Variants
We have a successful mpileaks build, but let's take some time to improve We have a successful mpileaks build, but let's take some time to improve
it. ``mpileaks`` has a build-time option to truncate parts of the stack it. ``mpileaks`` has a build-time option to truncate parts of the stack
that it walks. Let's add a variant to allow users to set this when they that it walks. Let's add a variant to allow users to set this when they
build in Spack. build mpileaks with Spack.
To do this, we'll add a variant to our package, as per the following (see To do this, we'll add a variant to our package, as per the following (see
``$SPACK_ROOT/lib/spack/docs/tutorial/examples/5.package.py``): ``$SPACK_ROOT/lib/spack/docs/tutorial/examples/5.package.py``):
@ -494,13 +486,13 @@ configure line (output truncated for length):
==> Searching for binary cache of mpileaks ==> Searching for binary cache of mpileaks
==> Finding buildcaches in /mirror/build_cache ==> Finding buildcaches in /mirror/build_cache
==> No binary for mpileaks found: installing from source ==> No binary for mpileaks found: installing from source
==> Using cached archive: /home/ubuntu/packaging/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz ==> Using cached archive: ~/spack/var/spack/cache/mpileaks/mpileaks-1.0.tar.gz
==> Staging archive: /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-meufjojkxve3l7rci2mbud3faidgplto/mpileaks-1.0.tar.gz ==> Staging archive: ~/spack/var/spack/stage/mpileaks-1.0-meufjojkxve3l7rci2mbud3faidgplto/mpileaks-1.0.tar.gz
==> Created stage in /home/ubuntu/packaging/spack/var/spack/stage/mpileaks-1.0-meufjojkxve3l7rci2mbud3faidgplto ==> Created stage in ~/spack/var/spack/stage/mpileaks-1.0-meufjojkxve3l7rci2mbud3faidgplto
==> No patches needed for mpileaks ==> No patches needed for mpileaks
==> Building mpileaks [Package] ==> Building mpileaks [Package]
==> Executing phase: 'install' ==> Executing phase: 'install'
==> './configure' '--with-adept-utils=/home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/adept-utils-1.0.1-7tippnvo5g76wpijk7x5kwfpr3iqiaen' '--with-callpath=/home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/callpath-1.0.4-empvyxdkc4j4pwg7gznwhbiumruey66x' '--prefix=/home/ubuntu/packaging/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/mpileaks-1.0-meufjojkxve3l7rci2mbud3faidgplto' '--with-stack-start-c=4' '--with-stack-start-fortran=4' ==> './configure' '--prefix=~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/mpileaks-1.0-meufjojkxve3l7rci2mbud3faidgplto' '--with-adept-utils=~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/adept-utils-1.0.1-7tippnvo5g76wpijk7x5kwfpr3iqiaen' '--with-callpath=~/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/callpath-1.0.4-empvyxdkc4j4pwg7gznwhbiumruey66x' '--with-stack-start-c=4' '--with-stack-start-fortran=4'
--------------- ---------------
The Spec Object The Spec Object
@ -508,7 +500,7 @@ The Spec Object
This tutorial has glossed over a few important features, which weren't This tutorial has glossed over a few important features, which weren't
too relevant for mpileaks but may be useful for other packages. There too relevant for mpileaks but may be useful for other packages. There
were several places we references the ``self.spec`` object. This is a were several places we reference the ``self.spec`` object. This is a
powerful class for querying information about what we're building. For powerful class for querying information about what we're building. For
example, you could use the spec to query information about how a example, you could use the spec to query information about how a
package's dependencies were built, or what compiler was being used, or package's dependencies were built, or what compiler was being used, or
@ -537,7 +529,7 @@ common queries:
if self.spec.satisfies('%gcc@:5.0.0'): if self.spec.satisfies('%gcc@:5.0.0'):
# Add arguments specific to gcc's earlier than 5.0.0 # Add arguments specific to gcc's earlier than 5.0.0
- Am I built with the ``debug`` variant: - Am I building with the ``debug`` variant:
.. code-block:: python .. code-block:: python
@ -560,7 +552,8 @@ To ensure that future sections of the tutorial run properly, please
uninstall mpileaks and remove the tutorial repo from your uninstall mpileaks and remove the tutorial repo from your
configuration. configuration.
.. code-block: console .. code-block:: console
$ spack uninstall -ay mpileaks $ spack uninstall -ay mpileaks
$ spack repo remove tutorial $ spack repo remove tutorial
$ rm -rf $SPACK_ROOT/var/spack/repos/tutorial/packages/mpileaks

View File

@ -7,22 +7,33 @@
class Mpileaks(AutotoolsPackage): class Mpileaks(AutotoolsPackage):
"""Tool to detect and report leaked MPI objects like MPI_Requests and """Tool to detect and report MPI objects like MPI_Requests and
MPI_Datatypes.""" MPI_Datatypes."""
homepage = "https://github.com/hpc/mpileaks" homepage = "https://github.com/LLNL/mpileaks"
url = "https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz" url = "https://github.com/LLNL/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz"
version('1.0', '8838c574b39202a57d7c2d68692718aa') version('1.0', sha256='2e34cc4505556d1c1f085758e26f2f8eea0972db9382f051b2dcfb1d7d9e1825')
depends_on("mpi") variant('stackstart', values=int, default=0,
depends_on("adept-utils") description='Specify the number of stack frames to truncate')
depends_on("callpath")
depends_on('mpi')
depends_on('adept-utils')
depends_on('callpath')
def configure_args(self): def configure_args(self):
args = [] stackstart = int(self.spec.variants['stackstart'].value)
args.append("--with-adept-utils=%s" % self.spec['adept-utils'].prefix) args = [
args.append("--with-callpath=%s" % self.spec['callpath'].prefix) '--with-adept-utils={0}'.format(self.spec['adept-utils'].prefix),
'--with-callpath={0}'.format(self.spec['callpath'].prefix),
]
if stackstart:
args.extend([
'--with-stack-start-c={0}'.format(stackstart),
'--with-stack-start-fortran={0}'.format(stackstart)
])
return args return args