Skip to content

Commit 673565a

Browse files
authored
imports: automate missing imports (#46410)
1 parent 930e711 commit 673565a

File tree

136 files changed

+383
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+383
-170
lines changed

lib/spack/spack/audit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def _search_duplicate_compilers(error_cls):
5151

5252
import llnl.util.lang
5353

54+
import spack.builder
5455
import spack.config
56+
import spack.fetch_strategy
5557
import spack.patch
5658
import spack.repo
5759
import spack.spec

lib/spack/spack/bootstrap/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import spack.compilers
1515
import spack.config
1616
import spack.environment
17+
import spack.modules
1718
import spack.paths
1819
import spack.platforms
1920
import spack.repo

lib/spack/spack/bootstrap/environment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
from llnl.util import tty
1515

1616
import spack.environment
17+
import spack.spec
1718
import spack.tengine
19+
import spack.util.path
1820

1921
from ._common import _root_spec
2022
from .config import root_path, spec_for_current_python, store_path

lib/spack/spack/build_environment.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from llnl.util.tty.color import cescape, colorize
5454
from llnl.util.tty.log import MultiProcessFd
5555

56+
import spack.build_systems._checks
5657
import spack.build_systems.cmake
5758
import spack.build_systems.meson
5859
import spack.build_systems.python
@@ -62,6 +63,7 @@
6263
import spack.deptypes as dt
6364
import spack.error
6465
import spack.main
66+
import spack.multimethod
6567
import spack.package_base
6668
import spack.paths
6769
import spack.platforms
@@ -73,9 +75,8 @@
7375
import spack.util.executable
7476
from spack import traverse
7577
from spack.context import Context
76-
from spack.error import NoHeadersError, NoLibrariesError
78+
from spack.error import InstallError, NoHeadersError, NoLibrariesError
7779
from spack.install_test import spack_install_test_log
78-
from spack.installer import InstallError
7980
from spack.util.cpus import determine_number_of_jobs
8081
from spack.util.environment import (
8182
SYSTEM_DIR_CASE_ENTRY,
@@ -1135,7 +1136,7 @@ def _setup_pkg_and_run(
11351136
return_value = function(pkg, kwargs)
11361137
write_pipe.send(return_value)
11371138

1138-
except StopPhase as e:
1139+
except spack.error.StopPhase as e:
11391140
# Do not create a full ChildError from this, it's not an error
11401141
# it's a control statement.
11411142
write_pipe.send(e)
@@ -1296,7 +1297,7 @@ def exitcode_msg(p):
12961297
p.join()
12971298

12981299
# If returns a StopPhase, raise it
1299-
if isinstance(child_result, StopPhase):
1300+
if isinstance(child_result, spack.error.StopPhase):
13001301
# do not print
13011302
raise child_result
13021303

@@ -1505,17 +1506,6 @@ def _make_child_error(msg, module, name, traceback, log, log_type, context):
15051506
return ChildError(msg, module, name, traceback, log, log_type, context)
15061507

15071508

1508-
class StopPhase(spack.error.SpackError):
1509-
"""Pickle-able exception to control stopped builds."""
1510-
1511-
def __reduce__(self):
1512-
return _make_stop_phase, (self.message, self.long_message)
1513-
1514-
1515-
def _make_stop_phase(msg, long_msg):
1516-
return StopPhase(msg, long_msg)
1517-
1518-
15191509
def write_log_summary(out, log_type, log, last=None):
15201510
errors, warnings = parse_log_events(log)
15211511
nerr = len(errors)

lib/spack/spack/build_systems/_checks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import llnl.util.lang
99

1010
import spack.builder
11-
import spack.installer
11+
import spack.error
1212
import spack.relocate
1313
import spack.spec
1414
import spack.store
@@ -34,15 +34,15 @@ def check_paths(path_list, filetype, predicate):
3434
if not predicate(abs_path):
3535
msg = "Install failed for {0}. No such {1} in prefix: {2}"
3636
msg = msg.format(pkg.name, filetype, path)
37-
raise spack.installer.InstallError(msg)
37+
raise spack.error.InstallError(msg)
3838

3939
check_paths(pkg.sanity_check_is_file, "file", os.path.isfile)
4040
check_paths(pkg.sanity_check_is_dir, "directory", os.path.isdir)
4141

4242
ignore_file = llnl.util.lang.match_predicate(spack.store.STORE.layout.hidden_file_regexes)
4343
if all(map(ignore_file, os.listdir(pkg.prefix))):
4444
msg = "Install failed for {0}. Nothing was installed!"
45-
raise spack.installer.InstallError(msg.format(pkg.name))
45+
raise spack.error.InstallError(msg.format(pkg.name))
4646

4747

4848
def apply_macos_rpath_fixups(builder: spack.builder.Builder):

lib/spack/spack/build_systems/autotools.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import spack.build_environment
1515
import spack.builder
16+
import spack.error
1617
import spack.package_base
1718
from spack.directives import build_system, conflicts, depends_on
1819
from spack.multimethod import when
@@ -248,7 +249,7 @@ def runs_ok(script_abs_path):
248249

249250
# An external gnuconfig may not not have a prefix.
250251
if gnuconfig_dir is None:
251-
raise spack.build_environment.InstallError(
252+
raise spack.error.InstallError(
252253
"Spack could not find substitutes for GNU config files because no "
253254
"prefix is available for the `gnuconfig` package. Make sure you set a "
254255
"prefix path instead of modules for external `gnuconfig`."
@@ -268,7 +269,7 @@ def runs_ok(script_abs_path):
268269
msg += (
269270
" or the `gnuconfig` package prefix is misconfigured as" " an external package"
270271
)
271-
raise spack.build_environment.InstallError(msg)
272+
raise spack.error.InstallError(msg)
272273

273274
# Filter working substitutes
274275
candidates = [f for f in candidates if runs_ok(f)]
@@ -293,9 +294,7 @@ def runs_ok(script_abs_path):
293294
and set the prefix to the directory containing the `config.guess` and
294295
`config.sub` files.
295296
"""
296-
raise spack.build_environment.InstallError(
297-
msg.format(", ".join(to_be_found), self.name)
298-
)
297+
raise spack.error.InstallError(msg.format(", ".join(to_be_found), self.name))
299298

300299
# Copy the good files over the bad ones
301300
for abs_path in to_be_patched:

lib/spack/spack/build_systems/cmake.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import spack.build_environment
1616
import spack.builder
1717
import spack.deptypes as dt
18+
import spack.error
1819
import spack.package_base
1920
from spack.directives import build_system, conflicts, depends_on, variant
2021
from spack.multimethod import when
@@ -344,7 +345,7 @@ def std_args(pkg, generator=None):
344345
msg = "Invalid CMake generator: '{0}'\n".format(generator)
345346
msg += "CMakePackage currently supports the following "
346347
msg += "primary generators: '{0}'".format("', '".join(valid_primary_generators))
347-
raise spack.package_base.InstallError(msg)
348+
raise spack.error.InstallError(msg)
348349

349350
try:
350351
build_type = pkg.spec.variants["build_type"].value

lib/spack/spack/build_systems/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import spack.compiler
1616
import spack.package_base
17+
import spack.util.executable
1718

1819
# Local "type" for type hints
1920
Path = Union[str, pathlib.Path]

lib/spack/spack/build_systems/intel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
install,
2323
)
2424

25+
import spack.builder
2526
import spack.error
2627
from spack.build_environment import dso_suffix
27-
from spack.package_base import InstallError
28+
from spack.error import InstallError
2829
from spack.util.environment import EnvironmentModifications
2930
from spack.util.executable import Executable
3031
from spack.util.prefix import Prefix

lib/spack/spack/build_systems/oneapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import spack.util.path
1616
from spack.build_environment import dso_suffix
1717
from spack.directives import conflicts, license, redistribute, variant
18-
from spack.package_base import InstallError
18+
from spack.error import InstallError
1919
from spack.util.environment import EnvironmentModifications
2020
from spack.util.executable import Executable
2121

0 commit comments

Comments
 (0)