summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-09-10 17:28:14 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-31 13:48:01 -0800
commit58cb4e5241dc5f1f707e4fbaad59759d4b982535 (patch)
tree71ed8b79ac71e6725f51867701b450d87a153eef /lib
parent5ddbd2fa6c29c3cae4c9cb56dfcfb53f86fce564 (diff)
downloadspack-58cb4e5241dc5f1f707e4fbaad59759d4b982535.tar.gz
spack-58cb4e5241dc5f1f707e4fbaad59759d4b982535.tar.bz2
spack-58cb4e5241dc5f1f707e4fbaad59759d4b982535.tar.xz
spack-58cb4e5241dc5f1f707e4fbaad59759d4b982535.zip
hooks: remove pre_run hook to improve startup time.
- Remove legacy yaml_version_check() hook - Remove the pre_run hook from `hook/__init__.py` and `main.py` We want to discourage the use of pre-run hooks because they have to run at startup. To keep Spack fast, we should do things like this lazily instead of in hooks that require spidering directories full of modules.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/hooks/__init__.py6
-rw-r--r--lib/spack/spack/hooks/yaml_version_check.py39
-rw-r--r--lib/spack/spack/main.py4
3 files changed, 0 insertions, 49 deletions
diff --git a/lib/spack/spack/hooks/__init__.py b/lib/spack/spack/hooks/__init__.py
index 0e2731f848..5a39f242fd 100644
--- a/lib/spack/spack/hooks/__init__.py
+++ b/lib/spack/spack/hooks/__init__.py
@@ -12,7 +12,6 @@
Currently the following hooks are supported:
- * pre_run()
* pre_install(spec)
* post_install(spec)
* pre_uninstall(spec)
@@ -60,11 +59,6 @@ class HookRunner(object):
hook(*args, **kwargs)
-#
-# Define some functions that can be called to fire off hooks.
-#
-pre_run = HookRunner('pre_run')
-
pre_install = HookRunner('pre_install')
post_install = HookRunner('post_install')
diff --git a/lib/spack/spack/hooks/yaml_version_check.py b/lib/spack/spack/hooks/yaml_version_check.py
deleted file mode 100644
index 7a75cb78a8..0000000000
--- a/lib/spack/spack/hooks/yaml_version_check.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
-# Spack Project Developers. See the top-level COPYRIGHT file for details.
-#
-# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-"""Yaml Version Check is a module for ensuring that config file
-formats are compatible with the current version of Spack."""
-import os.path
-import os
-import llnl.util.tty as tty
-import spack.util.spack_yaml as syaml
-import spack.config
-
-
-def pre_run():
- check_compiler_yaml_version()
-
-
-def check_compiler_yaml_version():
- config = spack.config.config
-
- for scope in config.file_scopes:
- file_name = os.path.join(scope.path, 'compilers.yaml')
- data = None
- if os.path.isfile(file_name):
- with open(file_name) as f:
- data = syaml.load_config(f)
-
- if data:
- compilers = data.get('compilers')
- if compilers and len(compilers) > 0:
- if (not isinstance(compilers, list) or
- 'operating_system' not in compilers[0]['compiler']):
- new_file = os.path.join(scope.path, '_old_compilers.yaml')
- tty.warn('%s in out of date compilers format. '
- 'Moved to %s. Spack automatically generate '
- 'a compilers config file '
- % (file_name, new_file))
- os.rename(file_name, new_file)
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index d9cd226195..2a6b774536 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -30,7 +30,6 @@ import spack.architecture
import spack.config
import spack.cmd
import spack.environment as ev
-import spack.hooks
import spack.paths
import spack.repo
import spack.store
@@ -700,9 +699,6 @@ def main(argv=None):
# many operations will fail without a working directory.
set_working_dir()
- # pre-run hooks happen after we know we have a valid working dir
- spack.hooks.pre_run()
-
# now we can actually execute the command.
if args.spack_profile or args.sorted_profile:
_profile_wrapper(command, parser, args, unknown)