System config (#4518)
* Code changes to enable system config scope in /etc Files will go in either /etc/spack or /etc/spack/<platform> Required minor changes to conftest. * Updated documentation to match new config scope
This commit is contained in:
parent
5c01fadc59
commit
541496dfe1
5 changed files with 40 additions and 20 deletions
|
@ -45,20 +45,27 @@ Configuration Scopes
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
Spack pulls configuration data from files in several directories. There
|
Spack pulls configuration data from files in several directories. There
|
||||||
are three configuration scopes. From lowest to highest:
|
are four configuration scopes. From lowest to highest:
|
||||||
|
|
||||||
1. **defaults**: Stored in ``$(prefix)/etc/spack/defaults/``. These are
|
#. **defaults**: Stored in ``$(prefix)/etc/spack/defaults/``. These are
|
||||||
the "factory" settings. Users should generally not modify the settings
|
the "factory" settings. Users should generally not modify the settings
|
||||||
here, but should override them in other configuration scopes. The
|
here, but should override them in other configuration scopes. The
|
||||||
defaults here will change from version to version of Spack.
|
defaults here will change from version to version of Spack.
|
||||||
|
|
||||||
2. **site**: Stored in ``$(prefix)/etc/spack/``. Settings here affect
|
#. **system**: Stored in ``/etc/spack``. These are settings for this
|
||||||
|
machine, or for all machines on which this file system is
|
||||||
|
mounted. The site scope can be used for settings idiosyncratic to a
|
||||||
|
particular machine, such as the locations of compilers or external
|
||||||
|
packages. These settings are presumably controlled by someone with
|
||||||
|
root access on the machine.
|
||||||
|
|
||||||
|
#. **site**: Stored in ``$(prefix)/etc/spack/``. Settings here affect
|
||||||
only *this instance* of Spack, and they override defaults. The site
|
only *this instance* of Spack, and they override defaults. The site
|
||||||
scope can can be used for per-project settings (one spack instance per
|
scope can can be used for per-project settings (one spack instance per
|
||||||
project) or for site-wide settings on a multi-user machine (e.g., for
|
project) or for site-wide settings on a multi-user machine (e.g., for
|
||||||
a common spack instance).
|
a common spack instance).
|
||||||
|
|
||||||
3. **user**: Stored in the home directory: ``~/.spack/``. These settings
|
#. **user**: Stored in the home directory: ``~/.spack/``. These settings
|
||||||
affect all instances of Spack and take the highest precedence.
|
affect all instances of Spack and take the highest precedence.
|
||||||
|
|
||||||
Each configuration directory may contain several configuration files,
|
Each configuration directory may contain several configuration files,
|
||||||
|
@ -78,22 +85,25 @@ Platform-specific scopes
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
For each scope above, there can *also* be platform-specific settings.
|
For each scope above, there can *also* be platform-specific settings.
|
||||||
For example, on Blue Gene/Q machines, Spack needs to know the location of
|
For example, on Blue Gene/Q machines, Spack needs to know the location
|
||||||
cross-compilers for the compute nodes. This configuration is in
|
of cross-compilers for the compute nodes. This configuration is in
|
||||||
``etc/spack/defaults/bgq/compilers.yaml``. It will take precedence over
|
``etc/spack/defaults/bgq/compilers.yaml``. It will take precedence
|
||||||
settings in the ``defaults`` scope, but can still be overridden by
|
over settings in the ``defaults`` scope, but can still be overridden
|
||||||
settings in ``site``, ``site/bgq``, ``user``, or ``user/bgq``. So, the
|
by settings in ``system``, ``system/bgq``, ``site``, ``site/bgq``,
|
||||||
full scope precedence is:
|
``user``, or ``user/bgq``. So, the full scope precedence is:
|
||||||
|
|
||||||
1. ``defaults``
|
1. ``defaults``
|
||||||
2. ``defaults/<platform>``
|
2. ``defaults/<platform>``
|
||||||
3. ``site``
|
3. ``system``
|
||||||
4. ``site/<platform>``
|
4. ``system/<platform>``
|
||||||
5. ``user``
|
5. ``site``
|
||||||
6. ``user/<platform>``
|
6. ``site/<platform>``
|
||||||
|
7. ``user``
|
||||||
|
8. ``user/<platform>``
|
||||||
|
|
||||||
You can get the name to use for ``<platform>`` by running ``spack arch
|
You can get the name to use for ``<platform>`` by running ``spack arch
|
||||||
--platform``.
|
--platform``. The system config scope has a ``<platform>`` section for
|
||||||
|
sites at which ``/etc`` is mounted on multiple heterogeneous machines.
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
Scope precedence
|
Scope precedence
|
||||||
|
|
|
@ -64,9 +64,9 @@
|
||||||
user_config_path = os.path.expanduser('~/.spack')
|
user_config_path = os.path.expanduser('~/.spack')
|
||||||
|
|
||||||
prefix = spack_root
|
prefix = spack_root
|
||||||
opt_path = join_path(prefix, "opt")
|
opt_path = join_path(prefix, "opt")
|
||||||
etc_path = join_path(prefix, "etc")
|
etc_path = join_path(prefix, "etc")
|
||||||
|
system_etc_path = '/etc'
|
||||||
|
|
||||||
# GPG paths.
|
# GPG paths.
|
||||||
gpg_keys_path = join_path(var_path, "gpg")
|
gpg_keys_path = join_path(var_path, "gpg")
|
||||||
|
|
|
@ -100,7 +100,8 @@ def init_compiler_config():
|
||||||
# Check the site config and update the user config if
|
# Check the site config and update the user config if
|
||||||
# nothing is configured at the site level.
|
# nothing is configured at the site level.
|
||||||
site_config = spack.config.get_config('compilers', scope='site')
|
site_config = spack.config.get_config('compilers', scope='site')
|
||||||
if not site_config:
|
sys_config = spack.config.get_config('compilers', scope='system')
|
||||||
|
if not site_config and not sys_config:
|
||||||
init_compiler_config()
|
init_compiler_config()
|
||||||
config = spack.config.get_config('compilers', scope=scope)
|
config = spack.config.get_config('compilers', scope=scope)
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
configuration system behaves. The scopes are:
|
configuration system behaves. The scopes are:
|
||||||
|
|
||||||
#. ``default``
|
#. ``default``
|
||||||
|
#. ``system``
|
||||||
#. ``site``
|
#. ``site``
|
||||||
#. ``user``
|
#. ``user``
|
||||||
|
|
||||||
|
@ -211,11 +212,17 @@ def __repr__(self):
|
||||||
_platform = spack.architecture.platform().name
|
_platform = spack.architecture.platform().name
|
||||||
|
|
||||||
"""Default configuration scope is the lowest-level scope. These are
|
"""Default configuration scope is the lowest-level scope. These are
|
||||||
versioned with Spack and can be overridden by sites or users."""
|
versioned with Spack and can be overridden by systems, sites or users."""
|
||||||
_defaults_path = os.path.join(spack.etc_path, 'spack', 'defaults')
|
_defaults_path = os.path.join(spack.etc_path, 'spack', 'defaults')
|
||||||
ConfigScope('defaults', _defaults_path)
|
ConfigScope('defaults', _defaults_path)
|
||||||
ConfigScope('defaults/%s' % _platform, os.path.join(_defaults_path, _platform))
|
ConfigScope('defaults/%s' % _platform, os.path.join(_defaults_path, _platform))
|
||||||
|
|
||||||
|
"""System configuration is per machine.
|
||||||
|
No system-level configs should be checked into spack by default"""
|
||||||
|
_system_path = os.path.join(spack.system_etc_path, 'spack')
|
||||||
|
ConfigScope('system', _system_path)
|
||||||
|
ConfigScope('system/%s' % _platform, os.path.join(_system_path, _platform))
|
||||||
|
|
||||||
"""Site configuration is per spack instance, for sites or projects.
|
"""Site configuration is per spack instance, for sites or projects.
|
||||||
No site-level configs should be checked into spack by default."""
|
No site-level configs should be checked into spack by default."""
|
||||||
_site_path = os.path.join(spack.etc_path, 'spack')
|
_site_path = os.path.join(spack.etc_path, 'spack')
|
||||||
|
@ -398,6 +405,7 @@ def get_config(section, scope=None):
|
||||||
|
|
||||||
for scope in scopes:
|
for scope in scopes:
|
||||||
# read potentially cached data from the scope.
|
# read potentially cached data from the scope.
|
||||||
|
|
||||||
data = scope.get_section(section)
|
data = scope.get_section(section)
|
||||||
|
|
||||||
# Skip empty configs
|
# Skip empty configs
|
||||||
|
|
|
@ -173,6 +173,7 @@ def config(configuration_dir):
|
||||||
real_scope = spack.config.config_scopes
|
real_scope = spack.config.config_scopes
|
||||||
spack.config.config_scopes = ordereddict_backport.OrderedDict()
|
spack.config.config_scopes = ordereddict_backport.OrderedDict()
|
||||||
spack.config.ConfigScope('site', str(configuration_dir.join('site')))
|
spack.config.ConfigScope('site', str(configuration_dir.join('site')))
|
||||||
|
spack.config.ConfigScope('system', str(configuration_dir.join('system')))
|
||||||
spack.config.ConfigScope('user', str(configuration_dir.join('user')))
|
spack.config.ConfigScope('user', str(configuration_dir.join('user')))
|
||||||
Config = collections.namedtuple('Config', ['real', 'mock'])
|
Config = collections.namedtuple('Config', ['real', 'mock'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue