diff options
author | Todd Gamblin <gamblin2@llnl.gov> | 2021-10-28 14:33:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-28 21:33:44 +0000 |
commit | a1216138f6af6985e231fc8d7b2cf6011bb11a00 (patch) | |
tree | b4b5939fbf19cc3933744d223e72a6d5f8541d44 /lib | |
parent | d0e177e7118ebf1b55004e9ae34516af1266ad9a (diff) | |
download | spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.tar.gz spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.tar.bz2 spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.tar.xz spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.zip |
config: fix `SPACK_DISABLE_LOCAL_CONFIG`, remove `$user_config_path` (#27022)
There were some loose ends left in ##26735 that cause errors when
using `SPACK_DISABLE_LOCAL_CONFIG`.
- [x] Fix hard-coded `~/.spack` references in `install_test.py` and `monitor.py`
Also, if `SPACK_DISABLE_LOCAL_CONFIG` is used, there is the issue that
`$user_config_path`, when used in configuration files, makes no sense,
because there is no user config scope.
Since we already have `$user_cache_path` in configuration files, and since there
really shouldn't be *any* data stored in a configuration scope (which is what
you'd configure in `config.yaml`/`bootstrap.yaml`/etc., this just removes
`$user_config_path`.
There will *always* be a `$user_cache_path`, as Spack needs to write files, but
we shouldn't rely on the existence of a particular configuration scope in the
Spack code, as scopes are configurable, both in number and location.
- [x] Remove `$user_config_path` substitution.
- [x] Fix reference to `$user_config_path` in `etc/spack/deaults/bootstrap.yaml`
to refer to `$user_cache_path`, which is where it was intended to be.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/docs/configuration.rst | 8 | ||||
-rw-r--r-- | lib/spack/spack/install_test.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/monitor.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/paths.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/test/config.py | 7 | ||||
-rw-r--r-- | lib/spack/spack/util/path.py | 2 |
6 files changed, 13 insertions, 17 deletions
diff --git a/lib/spack/docs/configuration.rst b/lib/spack/docs/configuration.rst index 5d41f86997..57a1eaeb11 100644 --- a/lib/spack/docs/configuration.rst +++ b/lib/spack/docs/configuration.rst @@ -409,8 +409,6 @@ Spack understands several special variables. These are: <https://docs.python.org/2/library/tempfile.html#tempfile.tempdir>`_ variable. * ``$user``: name of the current user -* ``$user_config_path``: user configuration directory (``~/.spack`` unless - :ref:`overridden <local-config-overrides>`) * ``$user_cache_path``: user cache directory (``~/.spack`` unless :ref:`overridden <local-config-overrides>`) @@ -587,9 +585,9 @@ Spack provides three environment variables that allow you to override or opt out configuration locations: * ``SPACK_USER_CONFIG_PATH``: Override the path to use for the - ``user`` (``~/.spack``) scope. -* ``SPACK_SYSTEM_CONFIG_PATH``: Override the path to use for the ``system`` - (``/etc/spack``) scope. + ``user`` scope (``~/.spack`` by default). +* ``SPACK_SYSTEM_CONFIG_PATH``: Override the path to use for the + ``system`` scope (``/etc/spack`` by default). * ``SPACK_DISABLE_LOCAL_CONFIG``: set this environment variable to completely disable **both** the system and user configuration directories. Spack will only consider its own defaults and ``site`` configuration locations. diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py index 53fd07d7bb..07644f5cc5 100644 --- a/lib/spack/spack/install_test.py +++ b/lib/spack/spack/install_test.py @@ -13,6 +13,7 @@ import llnl.util.filesystem as fs import llnl.util.tty as tty import spack.error +import spack.paths import spack.util.prefix import spack.util.spack_json as sjson from spack.spec import Spec @@ -41,7 +42,8 @@ def get_escaped_text_output(filename): def get_test_stage_dir(): return spack.util.path.canonicalize_path( - spack.config.get('config:test_stage', '~/.spack/test')) + spack.config.get('config:test_stage', spack.paths.default_test_path) + ) def get_all_test_suites(): diff --git a/lib/spack/spack/monitor.py b/lib/spack/spack/monitor.py index d3a66c6d9b..c0df4ea680 100644 --- a/lib/spack/spack/monitor.py +++ b/lib/spack/spack/monitor.py @@ -28,6 +28,7 @@ import spack import spack.config import spack.hash_types as ht import spack.main +import spack.paths import spack.store import spack.util.path import spack.util.spack_json as sjson @@ -143,7 +144,8 @@ class SpackMonitorClient: return save_dir = spack.util.path.canonicalize_path( - spack.config.get('config:monitor_dir', '~/.spack/reports/monitor')) + spack.config.get('config:monitor_dir', spack.paths.default_monitor_path) + ) # Name based on timestamp now = datetime.now().strftime('%Y-%m-%d-%H-%M-%S-%s') diff --git a/lib/spack/spack/paths.py b/lib/spack/spack/paths.py index 70d138a932..6b3543406b 100644 --- a/lib/spack/spack/paths.py +++ b/lib/spack/spack/paths.py @@ -89,8 +89,11 @@ user_cache_path = _get_user_cache_path() #: junit, cdash, etc. reports about builds reports_path = os.path.join(user_cache_path, "reports") +#: installation test (spack test) output +default_test_path = os.path.join(user_cache_path, "test") + #: spack monitor analysis directories -monitor_path = os.path.join(reports_path, "monitor") +default_monitor_path = os.path.join(reports_path, "monitor") #: git repositories fetched to compare commits to versions user_repos_cache_path = os.path.join(user_cache_path, 'git_repos') diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index f2f8626b4f..fd6af8640b 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -432,13 +432,6 @@ def test_substitute_user(mock_low_high_config): ) -def test_substitute_user_config(mock_low_high_config): - user_config_path = spack.paths.user_config_path - assert user_config_path + '/baz' == spack_path.canonicalize_path( - '$user_cache_path/baz' - ) - - def test_substitute_user_cache(mock_low_high_config): user_cache_path = spack.paths.user_cache_path assert user_cache_path + '/baz' == spack_path.canonicalize_path( diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py index 8f76db93bb..19f35a9449 100644 --- a/lib/spack/spack/util/path.py +++ b/lib/spack/spack/util/path.py @@ -30,7 +30,6 @@ replacements = { 'spack': spack.paths.prefix, 'user': getpass.getuser(), 'tempdir': tempfile.gettempdir(), - 'user_config_path': spack.paths.user_config_path, 'user_cache_path': spack.paths.user_cache_path, } @@ -80,7 +79,6 @@ def substitute_config_variables(path): - $spack The Spack instance's prefix - $tempdir Default temporary directory returned by tempfile.gettempdir() - $user The current user's username - - $user_config_path The user configuration directory (~/.spack, unless overridden) - $user_cache_path The user cache directory (~/.spack, unless overridden) These are substituted case-insensitively into the path, and users can |