Add license dir to config (#30135)
* Change license dir from hard-coded to a configurable item * Change config item to be a string not an array Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
This commit is contained in:
parent
2c211d95ee
commit
1f6b880fff
@ -33,6 +33,9 @@ config:
|
|||||||
template_dirs:
|
template_dirs:
|
||||||
- $spack/share/spack/templates
|
- $spack/share/spack/templates
|
||||||
|
|
||||||
|
# Directory where licenses should be located
|
||||||
|
license_dir: $spack/etc/spack/licenses
|
||||||
|
|
||||||
# Temporary locations Spack can try to use for builds.
|
# Temporary locations Spack can try to use for builds.
|
||||||
#
|
#
|
||||||
# Recommended options are given below.
|
# Recommended options are given below.
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
#: Path to the default configuration
|
#: Path to the default configuration
|
||||||
configuration_defaults_path = (
|
configuration_defaults_path = (
|
||||||
'defaults', os.path.join(spack.paths.etc_path, 'spack', 'defaults')
|
'defaults', os.path.join(spack.paths.etc_path, 'defaults')
|
||||||
)
|
)
|
||||||
|
|
||||||
#: Hard-coded default values for some key configuration options.
|
#: Hard-coded default values for some key configuration options.
|
||||||
@ -104,6 +104,7 @@
|
|||||||
'build_jobs': min(16, cpus_available()),
|
'build_jobs': min(16, cpus_available()),
|
||||||
'build_stage': '$tempdir/spack-stage',
|
'build_stage': '$tempdir/spack-stage',
|
||||||
'concretizer': 'clingo',
|
'concretizer': 'clingo',
|
||||||
|
'license_dir': spack.paths.default_license_dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,7 +816,7 @@ def _config():
|
|||||||
# 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.
|
||||||
configuration_paths.append(
|
configuration_paths.append(
|
||||||
('site', os.path.join(spack.paths.etc_path, 'spack')),
|
('site', os.path.join(spack.paths.etc_path)),
|
||||||
)
|
)
|
||||||
|
|
||||||
# User configuration can override both spack defaults and site config
|
# User configuration can override both spack defaults and site config
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
import spack.store
|
import spack.store
|
||||||
import spack.url
|
import spack.url
|
||||||
import spack.util.environment
|
import spack.util.environment
|
||||||
|
import spack.util.path
|
||||||
import spack.util.web
|
import spack.util.web
|
||||||
from spack.filesystem_view import YamlFilesystemView
|
from spack.filesystem_view import YamlFilesystemView
|
||||||
from spack.install_test import TestFailure, TestSuite
|
from spack.install_test import TestFailure, TestSuite
|
||||||
@ -60,7 +61,6 @@
|
|||||||
from spack.stage import ResourceStage, Stage, StageComposite, stage_prefix
|
from spack.stage import ResourceStage, Stage, StageComposite, stage_prefix
|
||||||
from spack.util.executable import ProcessError, which
|
from spack.util.executable import ProcessError, which
|
||||||
from spack.util.package_hash import package_hash
|
from spack.util.package_hash import package_hash
|
||||||
from spack.util.path import win_exe_ext
|
|
||||||
from spack.util.prefix import Prefix
|
from spack.util.prefix import Prefix
|
||||||
from spack.version import Version
|
from spack.version import Version
|
||||||
|
|
||||||
@ -200,9 +200,9 @@ def __init__(cls, name, bases, attr_dict):
|
|||||||
def platform_executables(self):
|
def platform_executables(self):
|
||||||
def to_windows_exe(exe):
|
def to_windows_exe(exe):
|
||||||
if exe.endswith('$'):
|
if exe.endswith('$'):
|
||||||
exe = exe.replace('$', '%s$' % win_exe_ext())
|
exe = exe.replace('$', '%s$' % spack.util.path.win_exe_ext())
|
||||||
else:
|
else:
|
||||||
exe += win_exe_ext()
|
exe += spack.util.path.win_exe_ext()
|
||||||
return exe
|
return exe
|
||||||
plat_exe = []
|
plat_exe = []
|
||||||
if hasattr(self, 'executables'):
|
if hasattr(self, 'executables'):
|
||||||
@ -438,6 +438,11 @@ def name(self):
|
|||||||
self._name = self._name[self._name.rindex('.') + 1:]
|
self._name = self._name[self._name.rindex('.') + 1:]
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def global_license_dir(self):
|
||||||
|
"""Returns the directory where license files for all packages are stored."""
|
||||||
|
return spack.util.path.canonicalize_path(spack.config.get('config:license_dir'))
|
||||||
|
|
||||||
|
|
||||||
def run_before(*phases):
|
def run_before(*phases):
|
||||||
"""Registers a method of a package to be run before a given phase"""
|
"""Registers a method of a package to be run before a given phase"""
|
||||||
@ -938,9 +943,8 @@ def name(self):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def global_license_dir(self):
|
def global_license_dir(self):
|
||||||
"""Returns the directory where global license files for all
|
"""Returns the directory where global license files are stored."""
|
||||||
packages are stored."""
|
return type(self).global_license_dir
|
||||||
return os.path.join(spack.paths.prefix, 'etc', 'spack', 'licenses')
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def global_license_file(self):
|
def global_license_file(self):
|
||||||
|
@ -43,8 +43,12 @@
|
|||||||
hooks_path = os.path.join(module_path, "hooks")
|
hooks_path = os.path.join(module_path, "hooks")
|
||||||
opt_path = os.path.join(prefix, "opt")
|
opt_path = os.path.join(prefix, "opt")
|
||||||
share_path = os.path.join(prefix, "share", "spack")
|
share_path = os.path.join(prefix, "share", "spack")
|
||||||
etc_path = os.path.join(prefix, "etc")
|
etc_path = os.path.join(prefix, "etc", "spack")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Things in $spack/etc/spack
|
||||||
|
#
|
||||||
|
default_license_dir = os.path.join(etc_path, "licenses")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Things in $spack/var/spack
|
# Things in $spack/var/spack
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
'type': 'array',
|
'type': 'array',
|
||||||
'items': {'type': 'string'}
|
'items': {'type': 'string'}
|
||||||
},
|
},
|
||||||
|
'license_dir': {'type': 'string'},
|
||||||
'source_cache': {'type': 'string'},
|
'source_cache': {'type': 'string'},
|
||||||
'misc_cache': {'type': 'string'},
|
'misc_cache': {'type': 'string'},
|
||||||
'connect_timeout': {'type': 'integer', 'minimum': 0},
|
'connect_timeout': {'type': 'integer', 'minimum': 0},
|
||||||
|
@ -78,13 +78,13 @@ def config_directory(tmpdir_factory):
|
|||||||
tmpdir = tmpdir_factory.mktemp('test_configs')
|
tmpdir = tmpdir_factory.mktemp('test_configs')
|
||||||
# restore some sane defaults for packages and config
|
# restore some sane defaults for packages and config
|
||||||
config_path = py.path.local(spack.paths.etc_path)
|
config_path = py.path.local(spack.paths.etc_path)
|
||||||
modules_yaml = config_path.join('spack', 'defaults', 'modules.yaml')
|
modules_yaml = config_path.join('defaults', 'modules.yaml')
|
||||||
os_modules_yaml = config_path.join('spack', 'defaults', '%s' %
|
os_modules_yaml = config_path.join('defaults', '%s' %
|
||||||
platform.system().lower(),
|
platform.system().lower(),
|
||||||
'modules.yaml')
|
'modules.yaml')
|
||||||
packages_yaml = config_path.join('spack', 'defaults', 'packages.yaml')
|
packages_yaml = config_path.join('defaults', 'packages.yaml')
|
||||||
config_yaml = config_path.join('spack', 'defaults', 'config.yaml')
|
config_yaml = config_path.join('defaults', 'config.yaml')
|
||||||
repos_yaml = config_path.join('spack', 'defaults', 'repos.yaml')
|
repos_yaml = config_path.join('defaults', 'repos.yaml')
|
||||||
tmpdir.ensure('site', dir=True)
|
tmpdir.ensure('site', dir=True)
|
||||||
tmpdir.ensure('user', dir=True)
|
tmpdir.ensure('user', dir=True)
|
||||||
tmpdir.ensure('site/%s' % platform.system().lower(), dir=True)
|
tmpdir.ensure('site/%s' % platform.system().lower(), dir=True)
|
||||||
|
@ -32,7 +32,7 @@ def _platform_executables(monkeypatch):
|
|||||||
def _win_exe_ext():
|
def _win_exe_ext():
|
||||||
return '.bat'
|
return '.bat'
|
||||||
|
|
||||||
monkeypatch.setattr(spack.package, 'win_exe_ext', _win_exe_ext)
|
monkeypatch.setattr(spack.util.path, 'win_exe_ext', _win_exe_ext)
|
||||||
|
|
||||||
|
|
||||||
def define_plat_exe(exe):
|
def define_plat_exe(exe):
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
import spack.environment as ev
|
import spack.environment as ev
|
||||||
import spack.main
|
import spack.main
|
||||||
import spack.paths
|
import spack.paths
|
||||||
|
import spack.repo
|
||||||
import spack.schema.compilers
|
import spack.schema.compilers
|
||||||
import spack.schema.config
|
import spack.schema.config
|
||||||
import spack.schema.env
|
import spack.schema.env
|
||||||
@ -1157,6 +1158,19 @@ def test_bad_path_double_override(config):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_license_dir_config(mutable_config, mock_packages):
|
||||||
|
"""Ensure license directory is customizable"""
|
||||||
|
assert spack.config.get("config:license_dir") == spack.paths.default_license_dir
|
||||||
|
assert spack.package.Package.global_license_dir == spack.paths.default_license_dir
|
||||||
|
assert spack.repo.get("a").global_license_dir == spack.paths.default_license_dir
|
||||||
|
|
||||||
|
rel_path = os.path.join(os.path.sep, "foo", "bar", "baz")
|
||||||
|
spack.config.set("config:license_dir", rel_path)
|
||||||
|
assert spack.config.get("config:license_dir") == rel_path
|
||||||
|
assert spack.package.Package.global_license_dir == rel_path
|
||||||
|
assert spack.repo.get("a").global_license_dir == rel_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.regression('22547')
|
@pytest.mark.regression('22547')
|
||||||
def test_single_file_scope_cache_clearing(env_yaml):
|
def test_single_file_scope_cache_clearing(env_yaml):
|
||||||
scope = spack.config.SingleFileScope(
|
scope = spack.config.SingleFileScope(
|
||||||
|
@ -576,7 +576,7 @@ def default_config():
|
|||||||
|
|
||||||
This ensures we can test the real default configuration without having
|
This ensures we can test the real default configuration without having
|
||||||
tests fail when the user overrides the defaults that we test against."""
|
tests fail when the user overrides the defaults that we test against."""
|
||||||
defaults_path = os.path.join(spack.paths.etc_path, 'spack', 'defaults')
|
defaults_path = os.path.join(spack.paths.etc_path, 'defaults')
|
||||||
if is_windows:
|
if is_windows:
|
||||||
defaults_path = os.path.join(defaults_path, "windows")
|
defaults_path = os.path.join(defaults_path, "windows")
|
||||||
with spack.config.use_configuration(defaults_path) as defaults_config:
|
with spack.config.use_configuration(defaults_path) as defaults_config:
|
||||||
|
Loading…
Reference in New Issue
Block a user