Skip to content

Commit

Permalink
docs: updates for stage.source_path (#11702)
Browse files Browse the repository at this point in the history
  • Loading branch information
tldahlgren authored and tgamblin committed Jun 17, 2019
1 parent b57ba62 commit a551e43
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
18 changes: 13 additions & 5 deletions lib/spack/docs/packaging_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ Skipping the expand step
^^^^^^^^^^^^^^^^^^^^^^^^

Spack normally expands archives (e.g. ``*.tar.gz`` and ``*.zip``) automatically
after downloading them. If you want to skip this step (e.g., for
self-extracting executables and other custom archive types), you can add
``expand=False`` to a ``version`` directive.
into a standard stage source directory (``self.stage.source_path``) after
downloading them. If you want to skip this step (e.g., for self-extracting
executables and other custom archive types), you can add ``expand=False`` to a
``version`` directive.

.. code-block:: python
Expand Down Expand Up @@ -814,7 +815,8 @@ For some packages, source code is provided in a Version Control System
(VCS) repository rather than in a tarball. Spack can fetch packages
from VCS repositories. Currently, Spack supports fetching with `Git
<git-fetch_>`_, `Mercurial (hg) <hg-fetch_>`_, `Subversion (svn)
<svn-fetch_>`_, and `Go <go-fetch_>`_.
<svn-fetch_>`_, and `Go <go-fetch_>`_. In all cases, the destination
is the standard stage source path.

To fetch a package from a source repository, Spack needs to know which
VCS to use and where to download from. Much like with ``url``, package
Expand Down Expand Up @@ -881,6 +883,8 @@ Git fetching supports the following parameters to ``version``:

Only one of ``tag``, ``branch``, or ``commit`` can be used at a time.

The destination directory for the clone is the standard stage source path.

Default branch
To fetch a repository's default branch:

Expand Down Expand Up @@ -981,6 +985,7 @@ Mercurial

Fetching with Mercurial works much like `Git <git-fetch>`_, but you
use the ``hg`` parameter.
The destination directory is still the standard stage source path.

Default branch
Add the ``hg`` attribute with no ``revision`` passed to ``version``:
Expand Down Expand Up @@ -1019,6 +1024,7 @@ Subversion
^^^^^^^^^^

To fetch with subversion, use the ``svn`` and ``revision`` parameters.
The destination directory will be the standard stage source path.

Fetching the head
Simply add an ``svn`` parameter to the package:
Expand Down Expand Up @@ -1063,7 +1069,9 @@ Go
Go isn't a VCS, it is a programming language with a builtin command,
`go get <https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies>`_,
that fetches packages and their dependencies automatically.
It can clone a Git repository, or download from another source location.
The destination directory will be the standard stage source path.

This strategy can clone a Git repository, or download from another source location.
For example:

.. code-block:: python
Expand Down
22 changes: 17 additions & 5 deletions lib/spack/spack/fetch_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
Apply a checksum to the downloaded source code, e.g. for an archive.
May not do anything if the fetch method was safe to begin with.
* expand()
Expand (e.g., an archive) downloaded file to source.
Expand (e.g., an archive) downloaded file to source, with the
standard stage source path as the destination directory.
* reset()
Restore original state of downloaded code. Used by clean commands.
This may just remove the expanded source and re-expand an archive,
Expand Down Expand Up @@ -111,7 +112,7 @@ def check(self):
"""Checksum the archive fetched by this FetchStrategy."""

def expand(self):
"""Expand the downloaded archive."""
"""Expand the downloaded archive into the stage source path."""

def reset(self):
"""Revert to freshly downloaded state.
Expand Down Expand Up @@ -172,8 +173,10 @@ def source_id(self):


class URLFetchStrategy(FetchStrategy):
"""FetchStrategy that pulls source code from a URL for an archive,
checks the archive against a checksum,and decompresses the archive.
"""
FetchStrategy that pulls source code from a URL for an archive, check the
archive against a checksum, and decompresses the archive. The destination
for the resulting file(s) is the standard stage source path.
"""
enabled = True
url_attr = 'url'
Expand Down Expand Up @@ -537,7 +540,10 @@ class GoFetchStrategy(VCSFetchStrategy):
version('name',
go='github.com/monochromegane/the_platinum_searcher/...')
Go get does not natively support versions, they can be faked with git
Go get does not natively support versions, they can be faked with git.
The fetched source will be moved to the standard stage sourcepath directory
during the expand step.
"""
enabled = True
url_attr = 'go'
Expand Down Expand Up @@ -614,6 +620,8 @@ class GitFetchStrategy(VCSFetchStrategy):
repository's default branch)
* ``tag``: Particular tag to check out
* ``commit``: Particular commit hash in the repo
Repositories are cloned into the standard stage source path directory.
"""
enabled = True
url_attr = 'git'
Expand Down Expand Up @@ -783,6 +791,8 @@ class SvnFetchStrategy(VCSFetchStrategy):
version('name', svn='http://www.example.com/svn/trunk',
revision='1641')
Repositories are checked out into the standard stage source path directory.
"""
enabled = True
url_attr = 'svn'
Expand Down Expand Up @@ -877,6 +887,8 @@ class HgFetchStrategy(VCSFetchStrategy):
discouraged.
* ``revision``: Particular revision, branch, or tag.
Repositories are cloned into the standard stage source path directory.
"""
enabled = True
url_attr = 'hg'
Expand Down
10 changes: 7 additions & 3 deletions lib/spack/spack/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Stage(object):
with Stage() as stage: # Context manager creates and destroys the
# stage directory
stage.fetch() # Fetch a source archive into the stage.
stage.expand_archive() # Expand the source archive.
stage.expand_archive() # Expand the archive into source_path.
<install> # Build and install the archive.
# (handled by user of Stage)
Expand All @@ -122,7 +122,7 @@ class Stage(object):
try:
stage.create() # Explicitly create the stage directory.
stage.fetch() # Fetch a source archive into the stage.
stage.expand_archive() # Expand the source archive.
stage.expand_archive() # Expand the archive into source_path.
<install> # Build and install the archive.
# (handled by user of Stage)
finally:
Expand Down Expand Up @@ -594,7 +594,11 @@ def mirror_path(self):


class DIYStage(object):
"""Simple class that allows any directory to be a spack stage."""
"""
Simple class that allows any directory to be a spack stage. Consequently,
it does not expect or require that the source path adhere to the standard
directory naming convention.
"""

def __init__(self, path):
if path is None:
Expand Down

0 comments on commit a551e43

Please sign in to comment.