Skip to content
Snippets Groups Projects
Unverified Commit dbee91f7 authored by Todd Gamblin's avatar Todd Gamblin Committed by GitHub
Browse files

bugfix: allow fetching no-code packages (#13429)

Previously, spack would error out if we tried to fetch something with no
code, but that would prevent fetching dependencies. In particular, this
would fail:

    spack fetch --dependencies xsdk

- [x] Instead of raising an error, just print a message that there is nothing
      to be fetched for packages like xsdk that do not have code.

- [x] Make BundleFetchStrategy a bit more quiet about doing nothing.
parent 757387dc
Branches
Tags
No related merge requests found
...@@ -201,28 +201,16 @@ class BundleFetchStrategy(FetchStrategy): ...@@ -201,28 +201,16 @@ class BundleFetchStrategy(FetchStrategy):
url_attr = '' url_attr = ''
def fetch(self): def fetch(self):
tty.msg("No code to fetch.") """Simply report success -- there is no code to fetch."""
return True return True
def check(self):
tty.msg("No code to check.")
def expand(self):
tty.msg("No archive to expand.")
def reset(self):
tty.msg("No code to reset.")
def archive(self, destination):
tty.msg("No code to archive.")
@property @property
def cachable(self): def cachable(self):
tty.msg("No code to cache.") """Report False as there is no code to cache."""
return False return False
def source_id(self): def source_id(self):
tty.msg("No code to be uniquely identified.") """BundlePackages don't have a source id."""
return '' return ''
......
...@@ -1046,7 +1046,9 @@ def do_fetch(self, mirror_only=False): ...@@ -1046,7 +1046,9 @@ def do_fetch(self, mirror_only=False):
raise ValueError("Can only fetch concrete packages.") raise ValueError("Can only fetch concrete packages.")
if not self.has_code: if not self.has_code:
raise InvalidPackageOpError("Can only fetch a package with a URL.") tty.msg(
"No fetch required for %s: package has no code." % self.name
)
start_time = time.time() start_time = time.time()
checksum = spack.config.get('config:checksum') checksum = spack.config.get('config:checksum')
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
from llnl.util.filesystem import mkdirp, touch, working_dir from llnl.util.filesystem import mkdirp, touch, working_dir
from spack.package import \ from spack.package import InstallError, PackageBase, PackageStillNeededError
InstallError, InvalidPackageOpError, PackageBase, PackageStillNeededError
import spack.patch import spack.patch
import spack.repo import spack.repo
import spack.store import spack.store
...@@ -327,7 +326,9 @@ def test_uninstall_by_spec_errors(mutable_database): ...@@ -327,7 +326,9 @@ def test_uninstall_by_spec_errors(mutable_database):
PackageBase.uninstall_by_spec(rec.spec) PackageBase.uninstall_by_spec(rec.spec)
def test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages): @pytest.mark.disable_clean_stage_check
def test_nosource_pkg_install(
install_mockery, mock_fetch, mock_packages, capfd):
"""Test install phases with the nosource package.""" """Test install phases with the nosource package."""
spec = Spec('nosource').concretized() spec = Spec('nosource').concretized()
pkg = spec.package pkg = spec.package
...@@ -336,9 +337,8 @@ def test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages): ...@@ -336,9 +337,8 @@ def test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages):
pkg.do_install() pkg.do_install()
# Also make sure an error is raised if `do_fetch` is called. # Also make sure an error is raised if `do_fetch` is called.
with pytest.raises(InvalidPackageOpError, pkg.do_fetch()
match="fetch a package with a URL"): assert "No fetch required for nosource" in capfd.readouterr()[0]
pkg.do_fetch()
def test_nosource_pkg_install_post_install( def test_nosource_pkg_install_post_install(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment