diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/package.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/test/test_activations.py | 29 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index dc32effbec..5c4ff23d40 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1027,6 +1027,11 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)): if not self.is_extension: raise ValueError( "is_activated called on package that is not an extension.") + if self.extendee_spec.package.installed_upstream: + # If this extends an upstream package, it cannot be activated for + # it. This bypasses construction of the extension map, which can + # can fail when run in the context of a downstream Spack instance + return False extensions_layout = view.extensions_layout exts = extensions_layout.extension_map(self.extendee_spec) return (self.name in exts) and (exts[self.name] == self.spec) diff --git a/lib/spack/spack/test/test_activations.py b/lib/spack/spack/test/test_activations.py index eaac98f318..d1780b8963 100644 --- a/lib/spack/spack/test/test_activations.py +++ b/lib/spack/spack/test/test_activations.py @@ -408,3 +408,32 @@ def test_perl_activation_view(tmpdir, perl_and_extension_dirs, assert not os.path.exists(os.path.join(perl_prefix, 'bin/perl-ext-tool')) assert os.path.exists(os.path.join(view_dir, 'bin/perl-ext-tool')) + + +def test_is_activated_upstream_extendee(tmpdir, builtin_and_mock_packages, + monkeypatch): + """When an extendee is installed upstream, make sure that the extension + spec is never considered to be globally activated for it. + """ + extendee_spec = spack.spec.Spec('python') + extendee_spec._concrete = True + + python_name = 'python' + tmpdir.ensure(python_name, dir=True) + + python_prefix = str(tmpdir.join(python_name)) + # Set the prefix on the package's spec reference because that is a copy of + # the original spec + extendee_spec.package.spec.prefix = python_prefix + monkeypatch.setattr(extendee_spec.package.__class__, + 'installed_upstream', True) + + ext_name = 'py-extension1' + tmpdir.ensure(ext_name, dir=True) + ext_pkg = create_ext_pkg( + ext_name, str(tmpdir.join(ext_name)), extendee_spec, monkeypatch) + + # The view should not be checked at all if the extendee is installed + # upstream, so use 'None' here + mock_view = None + assert not ext_pkg.is_activated(mock_view) |