From c9e214f6d37af9320afc3a3bca304143c91254e7 Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Thu, 22 Aug 2019 11:08:23 -0700 Subject: Spack BundlePackage: a group of other packages (#11981) This adds a special package type to Spack which is used to aggregate a set of packages that a user might commonly install together; it does not include any source code itself and does not require a download URL like other Spack packages. It may include an 'install' method to generate scripts, and Spack will run post-install hooks (including module generation). * Add new BundlePackage type * Update the Xsdk package to be a BundlePackage and remove the 'install' method (previously it had a noop install method) * "spack create --template" now takes "bundle" as an option * Rename cmd_create_repo fixture to "mock_test_repo" and relocate it to shared pytest fixtures * Add unit tests for BundlePackage behavior --- .../packages/nosource-install/package.py | 31 ++++++++++++++++++++++ .../builtin.mock/packages/nosource/package.py | 17 ++++++++++++ .../packages/noversion-bundle/package.py | 18 +++++++++++++ .../builtin.mock/packages/noversion/package.py | 19 +++++++++++++ var/spack/repos/builtin/packages/xsdk/package.py | 21 ++++----------- 5 files changed, 90 insertions(+), 16 deletions(-) create mode 100644 var/spack/repos/builtin.mock/packages/nosource-install/package.py create mode 100644 var/spack/repos/builtin.mock/packages/nosource/package.py create mode 100644 var/spack/repos/builtin.mock/packages/noversion-bundle/package.py create mode 100644 var/spack/repos/builtin.mock/packages/noversion/package.py (limited to 'var') diff --git a/var/spack/repos/builtin.mock/packages/nosource-install/package.py b/var/spack/repos/builtin.mock/packages/nosource-install/package.py new file mode 100644 index 0000000000..7ea8661d6e --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/nosource-install/package.py @@ -0,0 +1,31 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +import os +from spack import * +from llnl.util.filesystem import touch + + +class NosourceInstall(BundlePackage): + """Simple bundle package with one dependency and metadata 'install'.""" + + homepage = "http://www.example.com" + + version('2.0') + version('1.0') + + depends_on('dependency-install') + + # The install phase must be specified. + phases = ['install'] + + # The install method must also be present. + def install(self, spec, prefix): + touch(os.path.join(self.prefix, 'install.txt')) + + @run_after('install') + def post_install(self): + touch(os.path.join(self.prefix, 'post-install.txt')) diff --git a/var/spack/repos/builtin.mock/packages/nosource/package.py b/var/spack/repos/builtin.mock/packages/nosource/package.py new file mode 100644 index 0000000000..82e82267b0 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/nosource/package.py @@ -0,0 +1,17 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack import * + + +class Nosource(BundlePackage): + """Simple bundle package with one dependency""" + + homepage = "http://www.example.com" + + version('1.0') + + depends_on('dependency-install') diff --git a/var/spack/repos/builtin.mock/packages/noversion-bundle/package.py b/var/spack/repos/builtin.mock/packages/noversion-bundle/package.py new file mode 100644 index 0000000000..de6400636d --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/noversion-bundle/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack import * + + +class NoversionBundle(BundlePackage): + """ + Simple bundle package with no version and one dependency, which + should be rejected for lack of a version. + """ + + homepage = "http://www.example.com" + + depends_on('dependency-install') diff --git a/var/spack/repos/builtin.mock/packages/noversion/package.py b/var/spack/repos/builtin.mock/packages/noversion/package.py new file mode 100644 index 0000000000..40889a6a11 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/noversion/package.py @@ -0,0 +1,19 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class Noversion(Package): + """ + Simple package with no version, which should be rejected since a version + is required. + """ + + homepage = "http://www.example.com" + url = "http://www.example.com/a-1.0.tar.gz" + + def install(self, spec, prefix): + touch(join_path(prefix, 'an_installation_file')) diff --git a/var/spack/repos/builtin/packages/xsdk/package.py b/var/spack/repos/builtin/packages/xsdk/package.py index e6e3426f4d..8f1caa0a7c 100644 --- a/var/spack/repos/builtin/packages/xsdk/package.py +++ b/var/spack/repos/builtin/packages/xsdk/package.py @@ -4,25 +4,23 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import os from spack import * -class Xsdk(Package): +class Xsdk(BundlePackage): """Xsdk is a suite of Department of Energy (DOE) packages for numerical simulation. This is a Spack bundle package that installs the xSDK packages """ homepage = "http://xsdk.info" - url = 'http://ftp.mcs.anl.gov/pub/petsc/externalpackages/xsdk.tar.gz' maintainers = ['balay', 'luszczek'] - version('develop', 'a52dc710c744afa0b71429b8ec9425bc') - version('0.4.0', 'a52dc710c744afa0b71429b8ec9425bc') - version('0.3.0', 'a52dc710c744afa0b71429b8ec9425bc') - version('xsdk-0.2.0', 'a52dc710c744afa0b71429b8ec9425bc') + version('develop') + version('0.4.0') + version('0.3.0') + version('xsdk-0.2.0') variant('debug', default=False, description='Compile in debug mode') variant('cuda', default=False, description='Enable CUDA dependent packages') @@ -123,12 +121,3 @@ class Xsdk(Package): # How do we propagate debug flag to all depends on packages ? # If I just do spack install xsdk+debug will that propogate it down? - - # Dummy install for now, will be removed when metapackage is available - def install(self, spec, prefix): - # Prevent the error message - # ==> Error: Install failed for xsdk. Nothing was installed! - # ==> Error: Installation process had nonzero exit code : 256 - with open(os.path.join(spec.prefix, 'bundle-package.txt'), 'w') as out: - out.write('This is a bundle\n') - out.close() -- cgit v1.2.3-60-g2f50