summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-11-07 17:13:51 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-01 20:23:06 -0800
commitc36d9f297fafd1f9a1fd3d309a46eb3ee8987f44 (patch)
treeb4621e6f0df88dff9431fecb5ebdf5b2ec982ec5 /lib
parentb44df29316c52150702d35026e8da7b84fd8632b (diff)
downloadspack-c36d9f297fafd1f9a1fd3d309a46eb3ee8987f44.tar.gz
spack-c36d9f297fafd1f9a1fd3d309a46eb3ee8987f44.tar.bz2
spack-c36d9f297fafd1f9a1fd3d309a46eb3ee8987f44.tar.xz
spack-c36d9f297fafd1f9a1fd3d309a46eb3ee8987f44.zip
bugfix: mirror path works for unknown versions (#13626)
`mirror_archive_path` was failing to account for the case where the fetched version isn't known to Spack. - [x] don't require the fetched version to be in `Package.versions` - [x] add regression test for mirror paths when package does not have a version
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/mirror.py4
-rw-r--r--lib/spack/spack/test/mirror.py6
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 0c5e2a9cc2..f7e8e73ea9 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -303,8 +303,8 @@ def mirror_archive_paths(fetcher, per_package_ref, spec=None):
storage path of the resource associated with the specified ``fetcher``."""
ext = None
if spec:
- ext = spec.package.versions[spec.package.version].get(
- 'extension', None)
+ versions = spec.package.versions.get(spec.package.version, {})
+ ext = versions.get('extension', None)
# If the spec does not explicitly specify an extension (the default case),
# then try to determine it automatically. An extension can only be
# specified for the primary source of the package (e.g. the source code
diff --git a/lib/spack/spack/test/mirror.py b/lib/spack/spack/test/mirror.py
index da40cfac37..9068db7193 100644
--- a/lib/spack/spack/test/mirror.py
+++ b/lib/spack/spack/test/mirror.py
@@ -146,6 +146,12 @@ def test_all_mirror(
repos.clear()
+def test_mirror_archive_paths_no_version(mock_packages, config, mock_archive):
+ spec = Spec('trivial-install-test-package@nonexistingversion')
+ fetcher = spack.fetch_strategy.URLFetchStrategy(mock_archive.url)
+ spack.mirror.mirror_archive_paths(fetcher, 'per-package-ref', spec)
+
+
def test_mirror_with_url_patches(mock_packages, config, monkeypatch):
spec = Spec('patch-several-dependencies')
spec.concretize()