diff options
Diffstat (limited to 'lib/spack/spack/packages/__init__.py')
-rw-r--r-- | lib/spack/spack/packages/__init__.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/spack/spack/packages/__init__.py b/lib/spack/spack/packages/__init__.py index 8692dde5a8..40270afc99 100644 --- a/lib/spack/spack/packages/__init__.py +++ b/lib/spack/spack/packages/__init__.py @@ -19,6 +19,7 @@ valid_package_re = r'^\w[\w-]*$' invalid_package_re = r'[_-][_-]+' instances = {} +providers = {} def get(pkg_name): @@ -29,6 +30,24 @@ def get(pkg_name): return instances[pkg_name] +def get_providers(vpkg_name): + if not providers: + compute_providers() + + if not vpkg_name in providers: + raise UnknownPackageError("No such virtual package: %s" % vpkg_name) + + return providers[vpkg_name] + + +def compute_providers(): + for pkg in all_packages(): + for vpkg in pkg.provided_virtual_packages: + if vpkg not in providers: + providers[vpkg] = [] + providers[vpkg].append(pkg) + + def valid_package_name(pkg_name): return (re.match(valid_package_re, pkg_name) and not re.search(invalid_package_re, pkg_name)) @@ -75,6 +94,11 @@ def class_name_for_package_name(pkg_name): return class_name +def exists(pkg_name): + """Whether a package is concrete.""" + return os.path.exists(filename_for_package_name(pkg_name)) + + def get_class_for_package_name(pkg_name): file_name = filename_for_package_name(pkg_name) @@ -149,7 +173,6 @@ def graph_dependencies(out=sys.stdout): out.write('}\n') - class InvalidPackageNameError(spack.error.SpackError): """Raised when we encounter a bad package name.""" def __init__(self, name): |