From 8d7873e8b2f3b5c37ef55138893e03f6d85dae0d Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 29 Apr 2018 23:18:39 -0700 Subject: 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. --- lib/spack/spack/abi.py | 1 - lib/spack/spack/binary_distribution.py | 2 -- lib/spack/spack/cmd/activate.py | 3 ++- lib/spack/spack/cmd/create.py | 4 ++-- lib/spack/spack/cmd/deactivate.py | 1 - lib/spack/spack/cmd/python.py | 1 - lib/spack/spack/cmd/reindex.py | 3 +-- lib/spack/spack/cmd/spec.py | 2 +- lib/spack/spack/cmd/uninstall.py | 1 - lib/spack/spack/cmd/view.py | 7 ++++--- lib/spack/spack/dependency.py | 2 +- lib/spack/spack/directives.py | 21 ++++++++++----------- lib/spack/spack/filesystem_view.py | 1 - lib/spack/spack/hooks/licensing.py | 5 +++-- lib/spack/spack/patch.py | 1 - lib/spack/spack/provider_index.py | 4 +--- lib/spack/spack/repo.py | 1 - lib/spack/spack/test/architecture.py | 2 +- lib/spack/spack/test/build_systems.py | 2 -- lib/spack/spack/test/cmd/dependencies.py | 3 +-- lib/spack/spack/test/cmd/dependents.py | 2 +- lib/spack/spack/test/cmd/install.py | 1 - lib/spack/spack/test/spec_dag.py | 1 - lib/spack/spack/test/spec_syntax.py | 2 +- lib/spack/spack/test/test_activations.py | 2 +- lib/spack/spack/variant.py | 5 +++-- 26 files changed, 33 insertions(+), 47 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/abi.py b/lib/spack/spack/abi.py index 6663adf29f..1f7e16cfdb 100644 --- a/lib/spack/spack/abi.py +++ b/lib/spack/spack/abi.py @@ -26,7 +26,6 @@ import os from llnl.util.lang import memoized -import spack import spack.spec from spack.build_environment import dso_suffix from spack.spec import CompilerSpec diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index 5ca6fe54e6..1ae068e897 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -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 yaml 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 diff --git a/lib/spack/spack/cmd/activate.py b/lib/spack/spack/cmd/activate.py index 34cf2ee720..b0e4be91f1 100644 --- a/lib/spack/spack/cmd/activate.py +++ b/lib/spack/spack/cmd/activate.py @@ -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 diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py index 899868ba12..4161f08324 100644 --- a/lib/spack/spack/cmd/create.py +++ b/lib/spack/spack/cmd/create.py @@ -28,10 +28,10 @@ import os 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 diff --git a/lib/spack/spack/cmd/deactivate.py b/lib/spack/spack/cmd/deactivate.py index 841a295cdb..30eb271412 100644 --- a/lib/spack/spack/cmd/deactivate.py +++ b/lib/spack/spack/cmd/deactivate.py @@ -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 diff --git a/lib/spack/spack/cmd/python.py b/lib/spack/spack/cmd/python.py index a4638a2a21..e5aa6b6220 100644 --- a/lib/spack/spack/cmd/python.py +++ b/lib/spack/spack/cmd/python.py @@ -30,7 +30,6 @@ import platform import spack - description = "launch an interpreter as spack would launch a command" section = "developer" level = "long" diff --git a/lib/spack/spack/cmd/reindex.py b/lib/spack/spack/cmd/reindex.py index 580fa977b4..91c8205fa8 100644 --- a/lib/spack/spack/cmd/reindex.py +++ b/lib/spack/spack/cmd/reindex.py @@ -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" diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py index b51ca9d879..0bc1c7874e 100644 --- a/lib/spack/spack/cmd/spec.py +++ b/lib/spack/spack/cmd/spec.py @@ -25,7 +25,7 @@ from __future__ import print_function import argparse -import spack + import spack.cmd import spack.cmd.common.arguments as arguments diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py index 31cbd80d2e..80f68df401 100644 --- a/lib/spack/spack/cmd/uninstall.py +++ b/lib/spack/spack/cmd/uninstall.py @@ -26,7 +26,6 @@ from __future__ import print_function import argparse -import spack import spack.cmd import spack.store import spack.repo diff --git a/lib/spack/spack/cmd/view.py b/lib/spack/spack/cmd/view.py index 71333a088f..b847e89240 100644 --- a/lib/spack/spack/cmd/view.py +++ b/lib/spack/spack/cmd/view.py @@ -52,13 +52,14 @@ All operations on views are performed via proxy objects such as 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" diff --git a/lib/spack/spack/dependency.py b/lib/spack/spack/dependency.py index a1691157a4..317d7ba9e5 100644 --- a/lib/spack/spack/dependency.py +++ b/lib/spack/spack/dependency.py @@ -26,7 +26,7 @@ """ from six import string_types -import spack +import spack.spec #: The types of dependency relationships that Spack understands. diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py index 2c270e7448..68678d904d 100644 --- a/lib/spack/spack/directives.py +++ b/lib/spack/spack/directives.py @@ -55,16 +55,14 @@ from six import string_types 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 extends(spec, **kwargs): 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 variant( 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 resource(**kwargs): 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) diff --git a/lib/spack/spack/filesystem_view.py b/lib/spack/spack/filesystem_view.py index c7646d1120..ead18c5836 100644 --- a/lib/spack/spack/filesystem_view.py +++ b/lib/spack/spack/filesystem_view.py @@ -31,7 +31,6 @@ import sys 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 diff --git a/lib/spack/spack/hooks/licensing.py b/lib/spack/spack/hooks/licensing.py index 6c4224b47c..1421663f96 100644 --- a/lib/spack/spack/hooks/licensing.py +++ b/lib/spack/spack/hooks/licensing.py @@ -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 diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py index 7c144b11c2..ffa94d964f 100644 --- a/lib/spack/spack/patch.py +++ b/lib/spack/spack/patch.py @@ -27,7 +27,6 @@ import os.path import inspect import hashlib -import spack import spack.error import spack.fetch_strategy as fs import spack.stage diff --git a/lib/spack/spack/provider_index.py b/lib/spack/spack/provider_index.py index 6cb530b2f4..02e76182ac 100644 --- a/lib/spack/spack/provider_index.py +++ b/lib/spack/spack/provider_index.py @@ -29,12 +29,10 @@ from itertools import product as iproduct 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 diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py index d71ab2452e..f00428f9a2 100644 --- a/lib/spack/spack/repo.py +++ b/lib/spack/spack/repo.py @@ -50,7 +50,6 @@ import llnl.util.lang import llnl.util.tty as tty from llnl.util.filesystem import mkdirp, install -import spack import spack.config import spack.caches import spack.error diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py index 1ed0dc3277..bc5bca5761 100644 --- a/lib/spack/spack/test/architecture.py +++ b/lib/spack/spack/test/architecture.py @@ -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 diff --git a/lib/spack/spack/test/build_systems.py b/lib/spack/spack/test/build_systems.py index 4b0ca19aa2..cac0711b48 100644 --- a/lib/spack/spack/test/build_systems.py +++ b/lib/spack/spack/test/build_systems.py @@ -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 diff --git a/lib/spack/spack/test/cmd/dependencies.py b/lib/spack/spack/test/cmd/dependencies.py index 015eac589c..2dc8d2e8f2 100644 --- a/lib/spack/spack/test/cmd/dependencies.py +++ b/lib/spack/spack/test/cmd/dependencies.py @@ -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') diff --git a/lib/spack/spack/test/cmd/dependents.py b/lib/spack/spack/test/cmd/dependents.py index c6a5b01111..7857161882 100644 --- a/lib/spack/spack/test/cmd/dependents.py +++ b/lib/spack/spack/test/cmd/dependents.py @@ -28,7 +28,7 @@ import pytest from llnl.util.tty.color import color_when -import spack +import spack.store from spack.main import SpackCommand dependents = SpackCommand('dependents') diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index a5448797bd..084eb59072 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -31,7 +31,6 @@ import pytest import llnl.util.filesystem as fs -import spack import spack.config import spack.package import spack.cmd.install diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py index f75b7e3feb..d6d4b34d55 100644 --- a/lib/spack/spack/test/spec_dag.py +++ b/lib/spack/spack/test/spec_dag.py @@ -26,7 +26,6 @@ These tests check Spec DAG operations using dummy packages. """ import pytest -import spack import spack.architecture import spack.package diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py index 168fb4fc68..98f0c31df5 100644 --- a/lib/spack/spack/test/spec_syntax.py +++ b/lib/spack/spack/test/spec_syntax.py @@ -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 diff --git a/lib/spack/spack/test/test_activations.py b/lib/spack/spack/test/test_activations.py index dcccbaa05d..da20a46bdc 100644 --- a/lib/spack/spack/test/test_activations.py +++ b/lib/spack/spack/test/test_activations.py @@ -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 diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py index af05ed93a9..9e6583af42 100644 --- a/lib/spack/spack/variant.py +++ b/lib/spack/spack/variant.py @@ -29,11 +29,12 @@ variants both in packages and in specs. 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): -- cgit v1.2.3-60-g2f50