imports: remove unnecessary import spack statements

- remove most `import spack` statements, except for files that need
  `spack_version`

- import spack is no longer sufficient to use submodules
  (e.g. spack.directives).

  - these submodules must be imported directly. Update references
    accordingly.
This commit is contained in:
Todd Gamblin 2018-04-29 23:18:39 -07:00
parent 6b2c49648a
commit 8d7873e8b2
26 changed files with 33 additions and 47 deletions

View file

@ -26,7 +26,6 @@
from llnl.util.lang import memoized
import spack
import spack.spec
from spack.build_environment import dso_suffix
from spack.spec import CompilerSpec

View file

@ -22,7 +22,6 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
import re
import tarfile
@ -37,7 +36,6 @@
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp, install_tree
import spack
import spack.cmd
import spack.fetch_strategy as fs
import spack.util.gpg as gpg_util

View file

@ -23,8 +23,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import argparse
import llnl.util.tty as tty
import spack
import spack.cmd
from spack.directory_layout import YamlViewExtensionsLayout

View file

@ -28,10 +28,10 @@
import re
import llnl.util.tty as tty
import spack
from llnl.util.filesystem import mkdirp
import spack.cmd
import spack.util.web
from llnl.util.filesystem import mkdirp
import spack.repo
from spack.spec import Spec
from spack.util.executable import which, ProcessError

View file

@ -25,7 +25,6 @@
import argparse
import llnl.util.tty as tty
import spack
import spack.cmd
import spack.store
from spack.directory_layout import YamlViewExtensionsLayout

View file

@ -30,7 +30,6 @@
import spack
description = "launch an interpreter as spack would launch a command"
section = "developer"
level = "long"

View file

@ -22,10 +22,9 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import spack
import spack.store
description = "rebuild Spack's package database"
description = "rebuild Spack's package database"
section = "admin"
level = "long"

View file

@ -25,7 +25,7 @@
from __future__ import print_function
import argparse
import spack
import spack.cmd
import spack.cmd.common.arguments as arguments

View file

@ -26,7 +26,6 @@
import argparse
import spack
import spack.cmd
import spack.store
import spack.repo

View file

@ -52,13 +52,14 @@
YamlFilesystemView.
'''
import os
import spack
import llnl.util.tty as tty
import spack.cmd
import spack.store
from spack.filesystem_view import YamlFilesystemView
import llnl.util.tty as tty
description = "produce a single-rooted directory view of packages"
section = "environment"

View file

@ -26,7 +26,7 @@
"""
from six import string_types
import spack
import spack.spec
#: The types of dependency relationships that Spack understands.

View file

@ -55,16 +55,14 @@ class OpenMpi(Package):
import llnl.util.lang
import spack
import spack.error
import spack.spec
import spack.url
import spack.variant
from spack.dependency import Dependency, default_deptype, canonical_deptype
from spack.fetch_strategy import from_kwargs
from spack.patch import Patch
from spack.resource import Resource
from spack.spec import Spec, parse_anonymous_spec
from spack.variant import Variant
from spack.version import Version
__all__ = []
@ -265,9 +263,9 @@ def _depends_on(pkg, spec, when=None, type=default_deptype, patches=None):
# If when is None or True make sure the condition is always satisfied
if when is None or when is True:
when = pkg.name
when_spec = parse_anonymous_spec(when, pkg.name)
when_spec = spack.spec.parse_anonymous_spec(when, pkg.name)
dep_spec = Spec(spec)
dep_spec = spack.spec.Spec(spec)
if pkg.name == dep_spec.name:
raise CircularReferenceError(
"Package '%s' cannot depend on itself." % pkg.name)
@ -328,7 +326,7 @@ def conflicts(conflict_spec, when=None, msg=None):
def _execute_conflicts(pkg):
# If when is not specified the conflict always holds
condition = pkg.name if when is None else when
when_spec = parse_anonymous_spec(condition, pkg.name)
when_spec = spack.spec.parse_anonymous_spec(condition, pkg.name)
# Save in a list the conflicts and the associated custom messages
when_spec_list = pkg.conflicts.setdefault(conflict_spec, [])
@ -382,7 +380,7 @@ def _execute_extends(pkg):
when = kwargs.get('when', pkg.name)
_depends_on(pkg, spec, when=when)
pkg.extendees[spec] = (Spec(spec), kwargs)
pkg.extendees[spec] = (spack.spec.Spec(spec), kwargs)
return _execute_extends
@ -394,7 +392,7 @@ def provides(*specs, **kwargs):
"""
def _execute_provides(pkg):
spec_string = kwargs.get('when', pkg.name)
provider_spec = parse_anonymous_spec(spec_string, pkg.name)
provider_spec = spack.spec.parse_anonymous_spec(spec_string, pkg.name)
for string in specs:
for provided_spec in spack.spec.parse(string):
@ -431,7 +429,8 @@ def patch(url_or_filename, level=1, when=None, working_dir=".", **kwargs):
"""
def _execute_patch(pkg_or_dep):
constraint = pkg_or_dep.name if when is None else when
when_spec = parse_anonymous_spec(constraint, pkg_or_dep.name)
when_spec = spack.spec.parse_anonymous_spec(
constraint, pkg_or_dep.name)
# if this spec is identical to some other, then append this
# patch to the existing list.
@ -491,7 +490,7 @@ def _execute_variant(pkg):
msg = "Invalid variant name in {0}: '{1}'"
raise DirectiveError(directive, msg.format(pkg.name, name))
pkg.variants[name] = Variant(
pkg.variants[name] = spack.variant.Variant(
name, default, description, values, multi, validator
)
return _execute_variant
@ -538,7 +537,7 @@ def _execute_resource(pkg):
message += "\tdestination : '{dest}'\n".format(dest=destination)
raise RuntimeError(message)
when_spec = parse_anonymous_spec(when, pkg.name)
when_spec = spack.spec.parse_anonymous_spec(when, pkg.name)
resources = pkg.resources.setdefault(when_spec, [])
name = kwargs.get('name')
fetcher = from_kwargs(**kwargs)

View file

@ -31,7 +31,6 @@
from llnl.util.link_tree import LinkTree
from llnl.util import tty
import spack
import spack.spec
import spack.store
from spack.directory_layout import ExtensionAlreadyInstalledError

View file

@ -24,10 +24,11 @@
##############################################################################
import os
import spack
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp
from spack.util.editor import editor
def pre_install(spec):
"""This hook handles global license setup for licensed software."""
@ -55,7 +56,7 @@ def set_up_license(pkg):
# Create a new license file
write_license_file(pkg, license_path)
# Open up file in user's favorite $EDITOR for editing
spack.editor(license_path)
editor(license_path)
tty.msg("Added global license file %s" % license_path)
else:
# Use already existing license file

View file

@ -27,7 +27,6 @@
import inspect
import hashlib
import spack
import spack.error
import spack.fetch_strategy as fs
import spack.stage

View file

@ -29,12 +29,10 @@
from six import iteritems
from pprint import pformat
import spack.error
import spack.util.spack_yaml as syaml
from yaml.error import MarkedYAMLError
import spack
import spack.error
class ProviderIndex(object):
"""This is a dict of dicts used for finding providers of particular

View file

@ -50,7 +50,6 @@
import llnl.util.tty as tty
from llnl.util.filesystem import mkdirp, install
import spack
import spack.config
import spack.caches
import spack.error

View file

@ -28,7 +28,7 @@
import itertools
import os
import platform as py_platform
import spack
import spack.architecture
from spack.spec import Spec
from spack.platforms.cray import Cray

View file

@ -22,8 +22,6 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import spack
import pytest
import spack.repo

View file

@ -23,12 +23,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import re
import pytest
from llnl.util.tty.color import color_when
import spack
import spack.store
from spack.main import SpackCommand
dependencies = SpackCommand('dependencies')

View file

@ -28,7 +28,7 @@
from llnl.util.tty.color import color_when
import spack
import spack.store
from spack.main import SpackCommand
dependents = SpackCommand('dependents')

View file

@ -31,7 +31,6 @@
import llnl.util.filesystem as fs
import spack
import spack.config
import spack.package
import spack.cmd.install

View file

@ -26,7 +26,6 @@
These tests check Spec DAG operations using dummy packages.
"""
import pytest
import spack
import spack.architecture
import spack.package

View file

@ -25,7 +25,7 @@
import pytest
import shlex
import spack
import spack.store
import spack.spec as sp
from spack.parse import Token
from spack.spec import Spec, parse, parse_anonymous_spec

View file

@ -25,7 +25,7 @@
import os
import pytest
import spack
import spack.spec
from spack.directory_layout import YamlDirectoryLayout
from spack.filesystem_view import YamlFilesystemView

View file

@ -29,11 +29,12 @@
import functools
import inspect
import re
from six import StringIO
import llnl.util.lang as lang
import spack
import spack.directives
import spack.error as error
from six import StringIO
class Variant(object):