summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2021-02-04 11:00:37 -0600
committerGitHub <noreply@github.com>2021-02-04 11:00:37 -0600
commitba70f90ee0c4af2ba8dcd6fb07be0837660a343a (patch)
treec9aab608591e6cab500a481e8ece90e5d1c205fb /var
parentf0cafd21ceaecd8243ea2b11653147afa0d3a53b (diff)
downloadspack-ba70f90ee0c4af2ba8dcd6fb07be0837660a343a.tar.gz
spack-ba70f90ee0c4af2ba8dcd6fb07be0837660a343a.tar.bz2
spack-ba70f90ee0c4af2ba8dcd6fb07be0837660a343a.tar.xz
spack-ba70f90ee0c4af2ba8dcd6fb07be0837660a343a.zip
Fix usage of PythonPackage.test outside of PythonPackage (#20555)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/gdal/package.py11
-rw-r--r--var/spack/repos/builtin/packages/py-tensorflow/package.py15
2 files changed, 22 insertions, 4 deletions
diff --git a/var/spack/repos/builtin/packages/gdal/package.py b/var/spack/repos/builtin/packages/gdal/package.py
index 13d41c1ddb..8b49376f8e 100644
--- a/var/spack/repos/builtin/packages/gdal/package.py
+++ b/var/spack/repos/builtin/packages/gdal/package.py
@@ -20,6 +20,7 @@ class Gdal(AutotoolsPackage):
list_depth = 1
maintainers = ['adamjstewart']
+ import_modules = ['osgeo', 'osgeo.utils']
version('3.2.1', sha256='6c588b58fcb63ff3f288eb9f02d76791c0955ba9210d98c3abd879c770ae28ea')
version('3.2.0', sha256='b051f852600ffdf07e337a7f15673da23f9201a9dbb482bd513756a3e5a196a6')
@@ -562,5 +563,13 @@ class Gdal(AutotoolsPackage):
fix_darwin_install_name(self.prefix.lib)
def test(self):
+ """Attempts to import modules of the installed package."""
+
if '+python' in self.spec:
- PythonPackage.test(self)
+ # Make sure we are importing the installed modules,
+ # not the ones in the source directory
+ for module in self.import_modules:
+ self.run_test(self.spec['python'].command.path,
+ ['-c', 'import {0}'.format(module)],
+ purpose='checking import of {0}'.format(module),
+ work_dir='spack-test')
diff --git a/var/spack/repos/builtin/packages/py-tensorflow/package.py b/var/spack/repos/builtin/packages/py-tensorflow/package.py
index 4ed0d78352..73dafed353 100644
--- a/var/spack/repos/builtin/packages/py-tensorflow/package.py
+++ b/var/spack/repos/builtin/packages/py-tensorflow/package.py
@@ -15,6 +15,7 @@ class PyTensorflow(Package, CudaPackage):
url = "https://github.com/tensorflow/tensorflow/archive/v2.3.1.tar.gz"
maintainers = ['adamjstewart', 'aweits']
+ import_modules = ['tensorflow']
version('2.4.1', sha256='f681331f8fc0800883761c7709d13cda11942d4ad5ff9f44ad855e9dc78387e0')
version('2.4.0', sha256='26c833b7e1873936379e810a39d14700281125257ddda8cd822c89111db6f6ae')
@@ -298,9 +299,6 @@ class PyTensorflow(Package, CudaPackage):
phases = ['configure', 'build', 'install']
- import_modules = PythonPackage.import_modules
- test = PythonPackage.test
-
# https://www.tensorflow.org/install/source
def setup_build_environment(self, env):
spec = self.spec
@@ -790,3 +788,14 @@ def protobuf_deps():
setup_py('install', '--prefix={0}'.format(prefix),
'--single-version-externally-managed', '--root=/')
remove_linked_tree(tmp_path)
+
+ def test(self):
+ """Attempts to import modules of the installed package."""
+
+ # Make sure we are importing the installed modules,
+ # not the ones in the source directory
+ for module in self.import_modules:
+ self.run_test(self.spec['python'].command.path,
+ ['-c', 'import {0}'.format(module)],
+ purpose='checking import of {0}'.format(module),
+ work_dir='spack-test')