spack.schema package¶
This module contains jsonschema files for all of Spack’s YAML formats.
- class spack.schema.DeprecationMessage(message, error)[source]¶
Bases:
NamedTuple
- spack.schema.merge_yaml(dest, source, prepend=False, append=False)[source]¶
Merges source into dest; entries in source take precedence over dest.
This routine may modify dest and should be assigned to dest, in case dest was None to begin with, e.g.:
dest = merge_yaml(dest, source)
In the result, elements from lists from
sourcewill appear before elements of lists fromdest. Likewise, when iterating over keys or items in mergedOrderedDictobjects, keys fromsourcewill appear before keys fromdest.Config file authors can optionally end any attribute in a dict with
::instead of:, and the key will override that of the parent instead of merging.+:will extend the default prepend merge strategy to include string concatenation-:will change the merge strategy to append, it also includes string concatentation
- spack.schema.override(string: str) bool[source]¶
Test if a spack YAML string is an override.
See
spack_yamlfor details. Keys in Spack YAML can end in::, and if they do, their values completely replace lower-precedence configs instead of merging into them.
Submodules¶
spack.schema.bootstrap module¶
Schema for bootstrap.yaml configuration file.
- spack.schema.bootstrap.schema¶
Full schema with metadata
spack.schema.buildcache_spec module¶
Schema for a buildcache spec.yaml file
# `buildinfo` is no longer needed as of Spack 0.21
"buildinfo": {"type": "object"},
"spec": {**spack.schema.spec.spec_node, "additionalProperties": True},
"buildcache_layout_version": {"type": "number"},
}
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack buildcache specfile schema",
"type": "object",
"additionalProperties": True,
"properties": properties,
}
spack.schema.cdash module¶
Schema for cdash.yaml configuration file.
"cdash": {
"type": "object",
"additionalProperties": False,
# "required": ["build-group", "url", "project", "site"],
"required": ["build-group"],
"properties": {
r"build-group": {"type": "string"},
r"url": {"type": "string"},
r"project": {"type": "string"},
r"site": {"type": "string"},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack cdash configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.cdash.schema¶
Full schema with metadata
spack.schema.ci module¶
Schema for gitlab-ci.yaml configuration file.
"type": "array",
"items": {"anyOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}]},
}
# Schema for CI image
image_schema = {
"oneOf": [
{"type": "string"},
{
"type": "object",
"properties": {
"name": {"type": "string"},
"entrypoint": {"type": "array", "items": {"type": "string"}},
},
},
]
}
# Additional attributes are allow
# and will be forwarded directly to the
# CI target YAML for each job.
attributes_schema = {
"type": "object",
"additionalProperties": True,
"properties": {
"image": image_schema,
"tags": {"type": "array", "items": {"type": "string"}},
"variables": {
"type": "object",
"patternProperties": {r"^[\w\-\.]+$": {"type": ["string", "number"]}},
},
"before_script": script_schema,
"script": script_schema,
"after_script": script_schema,
},
}
submapping_schema = {
"type": "object",
"additionalProperties": False,
"required": ["submapping"],
"properties": {
"match_behavior": {"type": "string", "enum": ["first", "merge"], "default": "first"},
"submapping": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": False,
"required": ["match"],
"properties": {
"match": {"type": "array", "items": {"type": "string"}},
"build-job": attributes_schema,
"build-job-remove": attributes_schema,
},
},
},
},
}
dynamic_mapping_schema = {
"type": "object",
"additionalProperties": False,
"required": ["dynamic-mapping"],
"properties": {
"dynamic-mapping": {
"type": "object",
"required": ["endpoint"],
"properties": {
"name": {"type": "string"},
# "endpoint" cannot have http patternProperties constraint since it is required
# Constrain is applied in code
"endpoint": {"type": "string"},
"timeout": {"type": "integer", "minimum": 0},
"verify_ssl": {"type": "boolean", "default": False},
"header": {"type": "object", "additionalProperties": {"type": "string"}},
"allow": {"type": "array", "items": {"type": "string"}},
"require": {"type": "array", "items": {"type": "string"}},
"ignore": {"type": "array", "items": {"type": "string"}},
},
}
},
}
def job_schema(name: str):
return {
"type": "object",
"additionalProperties": False,
"properties": {f"{name}-job": attributes_schema, f"{name}-job-remove": attributes_schema},
}
pipeline_gen_schema = {
"type": "array",
"items": {
"oneOf": [
submapping_schema,
dynamic_mapping_schema,
job_schema("any"),
job_schema("build"),
job_schema("cleanup"),
job_schema("copy"),
job_schema("noop"),
job_schema("reindex"),
job_schema("signing"),
]
},
}
#: Properties for inclusion in other schemas
properties: Dict[str, Any] = {
"ci": {
"type": "object",
"properties": {
"pipeline-gen": pipeline_gen_schema,
"rebuild-index": {"type": "boolean"},
"broken-specs-url": {"type": "string"},
"broken-tests-packages": {"type": "array", "items": {"type": "string"}},
"target": {"type": "string", "default": "gitlab"},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack CI configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.ci.schema¶
Full schema with metadata
spack.schema.compilers module¶
Schema for compilers.yaml configuration file.
"additionalProperties": False,
"properties": {
"cflags": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"cxxflags": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"fflags": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"cppflags": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"ldflags": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"ldlibs": {"anyOf": [{"type": "string"}, {"type": "null"}]},
},
}
extra_rpaths: Dict[str, Any] = {"type": "array", "default": [], "items": {"type": "string"}}
implicit_rpaths: Dict[str, Any] = {
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "boolean"}]
}
#: Properties for inclusion in other schemas
properties: Dict[str, Any] = {
"compilers": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": False,
"properties": {
"compiler": {
"type": "object",
"additionalProperties": False,
"required": ["paths", "spec", "modules", "operating_system"],
"properties": {
"paths": {
"type": "object",
"required": ["cc", "cxx", "f77", "fc"],
"additionalProperties": False,
"properties": {
"cc": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"cxx": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"f77": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"fc": {"anyOf": [{"type": "string"}, {"type": "null"}]},
},
},
"flags": flags,
"spec": {"type": "string"},
"operating_system": {"type": "string"},
"target": {"type": "string"},
"alias": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"modules": {
"anyOf": [
{"type": "null"},
{"type": "array", "items": {"type": "string"}},
]
},
"implicit_rpaths": implicit_rpaths,
"environment": spack.schema.environment.definition,
"extra_rpaths": extra_rpaths,
},
}
},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack compiler configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.compilers.schema¶
Full schema with metadata
spack.schema.concretizer module¶
Schema for concretizer.yaml configuration file.
properties: Dict[str, Any] = {
"concretizer": {
"type": "object",
"additionalProperties": False,
"properties": {
"force": {"type": "boolean", "default": False},
"reuse": {
"oneOf": [
{"type": "boolean"},
{"type": "string", "enum": ["dependencies"]},
{
"type": "object",
"properties": {
"roots": {"type": "boolean"},
"include": LIST_OF_SPECS,
"exclude": LIST_OF_SPECS,
"from": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"local",
"buildcache",
"external",
"environment",
],
},
"path": {"type": "string"},
"include": LIST_OF_SPECS,
"exclude": LIST_OF_SPECS,
},
},
},
},
},
]
},
"enable_node_namespace": {"type": "boolean"},
"targets": {
"type": "object",
"properties": {
"host_compatible": {"type": "boolean"},
"granularity": {"type": "string", "enum": ["generic", "microarchitectures"]},
},
},
"unify": {
"oneOf": [{"type": "boolean"}, {"type": "string", "enum": ["when_possible"]}]
},
"compiler_mixing": {
"oneOf": [{"type": "boolean"}, {"type": "array"}],
"description": "Whether to allow compiler mixing between link/run dependencies",
},
"splice": {
"type": "object",
"additionalProperties": False,
"properties": {
"explicit": {
"type": "array",
"default": [],
"items": {
"type": "object",
"required": ["target", "replacement"],
"additionalProperties": False,
"properties": {
"target": {"type": "string"},
"replacement": {"type": "string"},
"transitive": {"type": "boolean", "default": False},
},
},
},
"automatic": {"type": "boolean"},
},
},
"duplicates": {
"type": "object",
"properties": {
"strategy": {"type": "string", "enum": ["none", "minimal", "full"]},
"max_dupes": {
"type": "object",
"additionalProperties": {"type": "integer", "minimum": 1},
},
},
},
"static_analysis": {"type": "boolean"},
"timeout": {"type": "integer", "minimum": 0},
"error_on_timeout": {"type": "boolean"},
"os_compatible": {"type": "object", "additionalProperties": {"type": "array"}},
"concretization_cache": {
"type": "object",
"properties": {
"enable": {"type": "boolean"},
"url": {"type": "string"},
"entry_limit": {"type": "integer", "minimum": 0},
},
},
"externals": {
"type": "object",
"properties": {
"completion": {
"type": "string",
"enum": ["architecture_only", "default_variants"],
}
},
},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack concretizer configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.concretizer.schema¶
Full schema with metadata
spack.schema.config module¶
Schema for config.yaml configuration file.
"type": "object",
"default": {},
"properties": {
"flags": {
"type": "object",
"properties": {
"keep_werror": {"type": "string", "enum": ["all", "specific", "none"]}
},
},
"shared_linking": {
"anyOf": [
{"type": "string", "enum": ["rpath", "runpath"]},
{
"type": "object",
"properties": {
"type": {"type": "string", "enum": ["rpath", "runpath"]},
"bind": {"type": "boolean"},
"missing_library_policy": {"enum": ["error", "warn", "ignore"]},
},
},
]
},
"install_tree": {
"type": "object",
"properties": {
"root": {"type": "string"},
"padded_length": {
"oneOf": [{"type": "integer", "minimum": 0}, {"type": "boolean"}]
},
**spack.schema.projections.properties,
},
},
"install_hash_length": {"type": "integer", "minimum": 1},
"build_stage": {
"oneOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}]
},
"stage_name": {"type": "string"},
"develop_stage_link": {"type": "string"},
"test_stage": {"type": "string"},
"extensions": {"type": "array", "items": {"type": "string"}},
"template_dirs": {"type": "array", "items": {"type": "string"}},
"license_dir": {"type": "string"},
"source_cache": {"type": "string"},
"misc_cache": {"type": "string"},
"environments_root": {"type": "string"},
"connect_timeout": {"type": "integer", "minimum": 0},
"verify_ssl": {"type": "boolean"},
"ssl_certs": {"type": "string"},
"suppress_gpg_warnings": {"type": "boolean"},
"debug": {"type": "boolean"},
"checksum": {"type": "boolean"},
"deprecated": {"type": "boolean"},
"locks": {"type": "boolean"},
"dirty": {"type": "boolean"},
"build_language": {"type": "string"},
"build_jobs": {"type": "integer", "minimum": 1},
"concurrent_packages": {"type": "integer", "minimum": 0},
"ccache": {"type": "boolean"},
"db_lock_timeout": {"type": "integer", "minimum": 1},
"package_lock_timeout": {
"anyOf": [{"type": "integer", "minimum": 1}, {"type": "null"}]
},
"allow_sgid": {"type": "boolean"},
"install_status": {"type": "boolean"},
"binary_index_root": {"type": "string"},
"url_fetch_method": {
"anyOf": [{"enum": ["urllib", "curl"]}, {"type": "string", "pattern": r"^curl "}]
},
"additional_external_search_paths": {"type": "array", "items": {"type": "string"}},
"binary_index_ttl": {"type": "integer", "minimum": 0},
"aliases": {"type": "object", "additionalProperties": {"type": "string"}},
"installer": {"type": "string", "enum": ["old", "new"]},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack core configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
def update(data: dict) -> bool:
"""Update the data in place to remove deprecated properties.
Args:
data: dictionary to be updated
Returns: True if data was changed, False otherwise
"""
changed = False
data = data["config"]
shared_linking = data.get("shared_linking", None)
if isinstance(shared_linking, str):
# deprecated short-form shared_linking: rpath/runpath
# add value as `type` in updated shared_linking
data["shared_linking"] = {"type": shared_linking, "bind": False}
changed = True
return changed
- spack.schema.config.schema¶
Full schema with metadata
spack.schema.container module¶
Schema for the container subsection of Spack environments.
- spack.schema.container.container_schema¶
Schema for the container attribute included in Spack environments
spack.schema.cray_manifest module¶
Schema for Cray descriptive manifest: this describes a set of installed packages on the system and also specifies dependency relationships between them (so this provides more information than external entries in packages configuration).
This does not specify a configuration - it is an input format that is consumed and transformed into Spack DB records.
spack.schema.database_index module¶
Schema for database index.json file
"required": ["installs", "version"],
"additionalProperties": False,
"properties": {
"installs": {
"type": "object",
"patternProperties": {
r"^[a-z0-9]{32}$": {
"type": "object",
"properties": {
"spec": spack.schema.spec.spec_node,
"path": {"oneOf": [{"type": "string"}, {"type": "null"}]},
"installed": {"type": "boolean"},
"ref_count": {"type": "integer", "minimum": 0},
"explicit": {"type": "boolean"},
"installation_time": {"type": "number"},
},
}
},
},
"version": {"type": "string"},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack spec schema",
"type": "object",
"required": ["database"],
"additionalProperties": False,
"properties": properties,
}
- spack.schema.database_index.schema¶
Full schema with metadata
spack.schema.definitions module¶
Schema for definitions
"definitions": {
"type": "array",
"default": [],
"items": {
"type": "object",
"properties": {"when": {"type": "string"}},
"additionalProperties": spec_list_schema,
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack definitions configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.definitions.schema¶
Full schema with metadata
spack.schema.develop module¶
- spack.schema.develop.schema¶
Full schema with metadata
spack.schema.env module¶
Schema for env.yaml configuration file.
include_concrete = {"type": "array", "default": [], "items": {"type": "string"}}
properties: Dict[str, Any] = {
"spack": {
"type": "object",
"default": {},
"additionalProperties": False,
"properties": {
# merged configuration scope schemas
**spack.schema.merged.properties,
# extra environment schema properties
"specs": spec_list_schema,
"include_concrete": include_concrete,
},
}
}
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack environment file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
def update(data):
"""Update the data in place to remove deprecated properties.
Args:
data (dict): dictionary to be updated
Returns:
True if data was changed, False otherwise
"""
# There are not currently any deprecated attributes in this section
# that have not been removed
return False
- spack.schema.env.TOP_LEVEL_KEY¶
Top level key in a manifest file
spack.schema.env_vars module¶
Schema for env_vars.yaml configuration file.
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack env_vars configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.env_vars.schema¶
Full schema with metadata
spack.schema.environment module¶
Schema for environment modifications. Meant for inclusion in other schemas.
spack.schema.include module¶
Schema for include.yaml configuration file.
properties: Dict[str, Any] = {
"include": {
"type": "array",
"default": [],
"additionalProperties": False,
"items": {
"anyOf": [
# local, required path
{"type": "string"},
# local or remote paths that may be optional or conditional
{
"type": "object",
"properties": {
"when": {"type": "string"},
"name": {"type": "string"},
"path_override_env_var": {"type": "string"},
"path": {"type": "string"},
"sha256": {"type": "string"},
"optional": {"type": "boolean"},
"prefer_modify": {"type": "boolean"},
},
"required": ["path"],
"additionalProperties": False,
},
# remote git paths that may be optional or conditional
{
"type": "object",
"properties": {
"git": {"type": "string"},
"branch": {"type": "string"},
"commit": {"type": "string"},
"tag": {"type": "string"},
"paths": {"type": "array", "items": {"type": "string"}},
"when": {"type": "string"},
"optional": {"type": "boolean"},
},
"required": ["git", "paths"],
"additionalProperties": False,
},
]
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack include configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.include.schema¶
Full schema with metadata
spack.schema.merged module¶
Schema for configuration merged into one file.
properties: Dict[str, Any] = {
**spack.schema.bootstrap.properties,
**spack.schema.cdash.properties,
**spack.schema.compilers.properties,
**spack.schema.concretizer.properties,
**spack.schema.config.properties,
**spack.schema.container.properties,
**spack.schema.ci.properties,
**spack.schema.definitions.properties,
**spack.schema.develop.properties,
**spack.schema.env_vars.properties,
**spack.schema.include.properties,
**spack.schema.mirrors.properties,
**spack.schema.modules.properties,
**spack.schema.packages.properties,
**spack.schema.repos.properties,
**spack.schema.toolchains.properties,
**spack.schema.upstreams.properties,
**spack.schema.view.properties,
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack merged configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.merged.schema¶
Full schema with metadata
spack.schema.mirrors module¶
Schema for mirrors.yaml configuration file.
connection = {
"url": {"type": "string"},
"access_pair": {
"type": "object",
"required": ["secret_variable"],
# Only allow id or id_variable to be set, not both
"oneOf": [{"required": ["id"]}, {"required": ["id_variable"]}],
"properties": {
"id": {"type": "string"},
"id_variable": {"type": "string"},
"secret_variable": {"type": "string"},
},
},
"profile": {"type": ["string", "null"]},
"endpoint_url": {"type": ["string", "null"]},
"access_token_variable": {"type": ["string", "null"]},
}
#: Mirror connection inside pull/push keys
fetch_and_push = {
"anyOf": [
{"type": "string"},
{"type": "object", "additionalProperties": False, "properties": {**connection}},
]
}
#: Mirror connection when no pull/push keys are set
mirror_entry = {
"type": "object",
"additionalProperties": False,
"anyOf": [{"required": ["url"]}, {"required": ["fetch"]}, {"required": ["pull"]}],
"properties": {
"source": {"type": "boolean"},
"binary": {"type": "boolean"},
"signed": {"type": "boolean"},
"fetch": fetch_and_push,
"push": fetch_and_push,
"autopush": {"type": "boolean"},
**connection,
},
}
#: Properties for inclusion in other schemas
properties: Dict[str, Any] = {
"mirrors": {
"type": "object",
"default": {},
"additionalProperties": {"anyOf": [{"type": "string"}, mirror_entry]},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack mirror configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.mirrors.connection¶
Common properties for connection specification
- spack.schema.mirrors.fetch_and_push¶
Mirror connection inside pull/push keys
- spack.schema.mirrors.mirror_entry¶
Mirror connection when no pull/push keys are set
- spack.schema.mirrors.schema¶
Full schema with metadata
spack.schema.modules module¶
Schema for modules.yaml configuration file.
array_of_strings = {"type": "array", "default": [], "items": {"type": "string"}}
dependency_selection = {"type": "string", "enum": ["none", "run", "direct", "all"]}
module_file_configuration = {
"type": "object",
"default": {},
"additionalProperties": False,
"properties": {
"filter": {
"type": "object",
"default": {},
"additionalProperties": False,
"properties": {
"exclude_env_vars": {"type": "array", "default": [], "items": {"type": "string"}}
},
},
"template": {"type": "string"},
"autoload": dependency_selection,
"prerequisites": dependency_selection,
"conflict": array_of_strings,
"load": array_of_strings,
"suffixes": {
"type": "object",
"additionalKeysAreSpecs": True,
"additionalProperties": {"type": "string"}, # key
},
"environment": spack.schema.environment.definition,
},
}
projections_scheme = spack.schema.projections.properties["projections"]
common_props = {
"verbose": {"type": "boolean", "default": False},
"hash_length": {"type": "integer", "minimum": 0, "default": 7},
"include": array_of_strings,
"exclude": array_of_strings,
"exclude_implicits": {"type": "boolean", "default": False},
"defaults": array_of_strings,
"hide_implicits": {"type": "boolean", "default": False},
"naming_scheme": {"type": "string"},
"projections": projections_scheme,
"all": module_file_configuration,
}
tcl_configuration = {
"type": "object",
"default": {},
"additionalKeysAreSpecs": True,
"properties": {**common_props},
"additionalProperties": module_file_configuration,
}
lmod_configuration = {
"type": "object",
"default": {},
"additionalKeysAreSpecs": True,
"properties": {
**common_props,
"core_compilers": array_of_strings,
"hierarchy": array_of_strings,
"core_specs": array_of_strings,
"filter_hierarchy_specs": {
"type": "object",
"additionalKeysAreSpecs": True,
"additionalProperties": array_of_strings,
},
},
"additionalProperties": module_file_configuration,
}
module_config_properties = {
"use_view": {"anyOf": [{"type": "string"}, {"type": "boolean"}]},
"arch_folder": {"type": "boolean"},
"roots": {
"type": "object",
"properties": {"tcl": {"type": "string"}, "lmod": {"type": "string"}},
},
"enable": {
"type": "array",
"default": [],
"items": {"type": "string", "enum": ["tcl", "lmod"]},
},
"lmod": lmod_configuration,
"tcl": tcl_configuration,
"prefix_inspections": {
"type": "object",
# prefix-relative path to be inspected for existence
"additionalProperties": array_of_strings,
},
}
# Properties for inclusion into other schemas (requires definitions)
properties: Dict[str, Any] = {
"modules": {
"type": "object",
"properties": {
"prefix_inspections": {
"type": "object",
# prefix-relative path to be inspected for existence
"additionalProperties": array_of_strings,
}
},
"additionalProperties": {
"type": "object",
"default": {},
"additionalProperties": False,
"properties": module_config_properties,
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack module file configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.modules.array_of_strings¶
Definitions for parts of module schema
- spack.schema.modules.schema¶
Full schema with metadata
spack.schema.packages module¶
Schema for packages.yaml configuration files.
permissions = {
"type": "object",
"additionalProperties": False,
"properties": {
"read": {"type": "string", "enum": ["user", "group", "world"]},
"write": {"type": "string", "enum": ["user", "group", "world"]},
"group": {"type": "string"},
},
}
variants = {"oneOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}]}
requirements = {
"oneOf": [
# 'require' can be a list of requirement_groups.
# each requirement group is a list of one or more
# specs. Either at least one or exactly one spec
# in the group must be satisfied (depending on
# whether you use "any_of" or "one_of",
# repectively)
{
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"additionalProperties": False,
"properties": {
"one_of": {"type": "array", "items": {"type": "string"}},
"any_of": {"type": "array", "items": {"type": "string"}},
"spec": {"type": "string"},
"message": {"type": "string"},
"when": {"type": "string"},
},
},
{"type": "string"},
]
},
},
# Shorthand for a single requirement group with
# one member
{"type": "string"},
]
}
prefer_and_conflict = {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"additionalProperties": False,
"properties": {
"spec": {"type": "string"},
"message": {"type": "string"},
"when": {"type": "string"},
},
},
{"type": "string"},
]
},
}
permissions = {
"type": "object",
"additionalProperties": False,
"properties": {
"read": {"type": "string", "enum": ["user", "group", "world"]},
"write": {"type": "string", "enum": ["user", "group", "world"]},
"group": {"type": "string"},
},
}
package_attributes = {
"type": "object",
"additionalProperties": False,
"patternProperties": {r"^[a-zA-Z_]\w*$": {}},
}
REQUIREMENT_URL = "https://spack.readthedocs.io/en/latest/packages_yaml.html#package-requirements"
#: Properties for inclusion in other schemas
properties: Dict[str, Any] = {
"packages": {
"type": "object",
"default": {},
"properties": {
"all": { # package name
"type": "object",
"default": {},
"additionalProperties": False,
"properties": {
"require": requirements,
"prefer": prefer_and_conflict,
"conflict": prefer_and_conflict,
"target": {
"type": "array",
"default": [],
# target names
"items": {"type": "string"},
},
"compiler": {
"type": "array",
"default": [],
"items": {"type": "string"},
}, # compiler specs
"buildable": {"type": "boolean", "default": True},
"permissions": permissions,
# If 'get_full_repo' is promoted to a Package-level
# attribute, it could be useful to set it here
"package_attributes": package_attributes,
"providers": {
"type": "object",
"default": {},
"additionalProperties": {
"type": "array",
"default": [],
"items": {"type": "string"},
},
},
"variants": variants,
},
"deprecatedProperties": [
{
"names": ["compiler"],
"message": "The packages:all:compiler preference has been deprecated in "
"Spack v1.0, and is currently ignored. It will be removed from config in "
"Spack v1.2.",
"error": False,
}
],
}
},
"additionalProperties": { # package name
"type": "object",
"default": {},
"additionalProperties": False,
"properties": {
"require": requirements,
"prefer": prefer_and_conflict,
"conflict": prefer_and_conflict,
"version": {
"type": "array",
"default": [],
# version strings
"items": {"anyOf": [{"type": "string"}, {"type": "number"}]},
},
"buildable": {"type": "boolean", "default": True},
"permissions": permissions,
# If 'get_full_repo' is promoted to a Package-level
# attribute, it could be useful to set it here
"package_attributes": package_attributes,
"variants": variants,
"externals": {
"type": "array",
"items": {
"type": "object",
"properties": {
"spec": {"type": "string"},
"prefix": {"type": "string"},
"modules": {"type": "array", "items": {"type": "string"}},
"id": {"type": "string"},
"extra_attributes": {
"type": "object",
"additionalProperties": {"type": "string"},
"properties": {
"compilers": {
"type": "object",
"patternProperties": {r"^\w": {"type": "string"}},
},
"environment": spack.schema.environment.definition,
"extra_rpaths": extra_rpaths,
"implicit_rpaths": implicit_rpaths,
"flags": flags,
},
},
"dependencies": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "string"},
"spec": {"type": "string"},
"deptypes": {
"oneOf": [
{"type": "string"},
{"type": "array", "items": {"type": "string"}},
]
},
"virtuals": {"type": "string"},
},
},
},
},
"additionalProperties": False,
"required": ["spec"],
},
},
},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack package configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
def update(data):
data = data["packages"]
changed = False
for key in data:
version = data[key].get("version")
if not version or all(isinstance(v, str) for v in version):
continue
data[key]["version"] = [str(v) for v in version]
changed = True
return changed
- spack.schema.packages.schema¶
Full schema with metadata
spack.schema.projections module¶
Schema for projections.yaml configuration file.
"projections": {
"type": "object",
"properties": {"all": {"type": "string"}},
"additionalKeysAreSpecs": True,
"additionalProperties": {"type": "string"},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack view projection configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.projections.schema¶
Full schema with metadata
spack.schema.repos module¶
Schema for repos.yaml configuration file.
# old format: array of strings
"type": "array",
"items": {
"type": "string",
"description": "Path to a Spack package repository directory",
},
},
{
# new format: object with named repositories
"type": "object",
"additionalProperties": {
"oneOf": [
{
# local path
"type": "string",
"description": "Path to a Spack package repository directory",
},
{
# remote git repository
"type": "object",
"properties": {
"git": {"type": "string"},
"branch": {"type": "string"},
"commit": {"type": "string"},
"tag": {"type": "string"},
"destination": {"type": "string"},
"paths": {"type": "array", "items": {"type": "string"}},
},
"additionalProperties": False,
},
]
},
},
],
"default": {},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack repository configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
def update(data: Dict[str, Any]) -> bool:
"""Update the repos.yaml configuration data to the new format."""
if not isinstance(data["repos"], list):
return False
from spack.llnl.util import tty
from spack.repo import from_path
# Convert old format [paths...] to new format {namespace: path, ...}
repos = {}
for path in data["repos"]:
try:
repo = from_path(path)
except Exception as e:
tty.warn(f"package repository {path} is disabled due to: {e}")
continue
if repo.namespace is not None:
repos[repo.namespace] = path
data["repos"] = repos
return True
- spack.schema.repos.schema¶
Full schema with metadata
spack.schema.spec module¶
Schema for a spec found in spec descriptor or database index.json files
{
"type": "string",
"description": 'Target as a string (e.g. "zen2" or "haswell:broadwell") used in '
"abstract specs",
},
{
"type": "object",
"additionalProperties": False,
"required": ["name", "vendor", "features", "generation", "parents"],
"properties": {
"name": {"type": "string"},
"vendor": {"type": "string"},
"features": {"type": "array", "items": {"type": "string"}},
"generation": {"type": "integer"},
"parents": {"type": "array", "items": {"type": "string"}},
"cpupart": {"type": "string"},
},
"description": "Target as an object with detailed fields, used in concrete specs",
},
],
}
arch = {
"type": "object",
"additionalProperties": False,
"properties": {
"platform": {
"type": ["string", "null"],
"description": 'Target platform (e.g. "linux" or "darwin"). May be null for abstract '
"specs",
},
"platform_os": {
"type": ["string", "null"],
"description": 'Target operating system (e.g. "ubuntu24.04"). May be '
"null for abstract specs",
},
"target": target,
},
}
#: Corresponds to specfile format v1
dependencies_v1 = {
"type": "object",
"description": "Specfile v1 style dependencies specification (package name to dependency "
"info)",
"additionalProperties": {
"type": "object",
"properties": {
"hash": {"type": "string", "description": "Unique identifier of the dependency"},
"type": {
"type": "array",
"items": {"enum": ["build", "link", "run", "test"]},
"description": "Dependency types",
},
},
},
}
#: Corresponds to specfile format v2-v3
dependencies_v2_v3 = {
"type": "array",
"description": "Specfile v2-v3 style dependencies specification (array of dependencies)",
"items": {
"type": "object",
"additionalProperties": False,
"required": ["name", "hash", "type"],
"properties": {
"name": {"type": "string", "description": "Name of the dependency package"},
"hash": {"type": "string", "description": "Unique identifier of the dependency"},
"type": {
"type": "array",
"items": {"enum": ["build", "link", "run", "test"]},
"description": "Dependency types",
},
},
},
}
#: Corresponds to specfile format v4+
dependencies_v4_plus = {
"type": "array",
"description": "Specfile v4+ style dependencies specification (array of dependencies)",
"items": {
"type": "object",
"additionalProperties": False,
"required": ["name", "hash", "parameters"],
"properties": {
"name": {"type": "string", "description": "Name of the dependency package"},
"hash": {"type": "string", "description": "Unique identifier of the dependency"},
"parameters": {
"type": "object",
"additionalProperties": False,
"required": ["deptypes", "virtuals"],
"properties": {
"deptypes": {
"type": "array",
"items": {"enum": ["build", "link", "run", "test"]},
"description": "Dependency types",
},
"virtuals": {
"type": "array",
"items": {"type": "string"},
"description": "Virtual dependencies used by the parent",
},
"direct": {
"type": "boolean",
"description": "Whether the dependency is direct (only on abstract specs)",
},
},
},
},
},
}
dependencies = {"oneOf": [dependencies_v1, dependencies_v2_v3, dependencies_v4_plus]}
build_spec = {
"type": "object",
"additionalProperties": False,
"required": ["name", "hash"],
"properties": {"name": {"type": "string"}, "hash": {"type": "string"}},
"description": "Records the origin spec as it was built (used in splicing)",
}
#: Schema for a single spec node (used in both spec files and database entries)
spec_node = {
"type": "object",
"additionalProperties": False,
"required": ["name"],
"properties": {
"name": {
"type": ["string", "null"],
"description": "Name is a string for concrete specs, but may be null for abstract "
"specs",
},
"hash": {"type": "string", "description": "The DAG hash, which identifies the spec"},
"package_hash": {"type": "string", "description": "The package hash (concrete specs)"},
"full_hash": {
"type": "string",
"description": "This hash was used on some specs prior to 0.18",
},
"build_hash": {
"type": "string",
"description": "This hash was used on some specs prior to 0.18",
},
"version": {"type": "string", "description": "A single, concrete version (e.g. @=1.2)"},
"versions": {
"type": "array",
"items": {"type": "string"},
"description": "Abstract version (e.g. @1.2)",
},
"propagate": {
"type": "array",
"items": {"type": "string"},
"description": "List of variants to propagate (for abstract specs)",
},
"abstract": {
"type": "array",
"items": {"type": "string"},
"description": "List of multi-valued variants that are abstract, i.e. foo=bar,baz "
"instead of foo:=bar,baz (for abstract specs)",
},
"concrete": {
"type": "boolean",
"description": "Whether the spec is concrete or not, when omitted defaults to true",
},
"arch": arch,
"compiler": {
"type": "object",
"additionalProperties": False,
"properties": {"name": {"type": "string"}, "version": {"type": "string"}},
"description": "Compiler name and version (in spec file v5 listed as normal "
"dependencies)",
},
"namespace": {"type": "string", "description": "Package repository namespace"},
"parameters": {
"type": "object",
"additionalProperties": True,
"description": "Variants and other parameters",
"properties": {
"patches": {"type": "array", "items": {"type": "string"}},
"cflags": {"type": "array", "items": {"type": "string"}},
"cppflags": {"type": "array", "items": {"type": "string"}},
"cxxflags": {"type": "array", "items": {"type": "string"}},
"fflags": {"type": "array", "items": {"type": "string"}},
"ldflags": {"type": "array", "items": {"type": "string"}},
"ldlibs": {"type": "array", "items": {"type": "string"}},
},
},
"patches": {
"type": "array",
"items": {"type": "string"},
"description": "List of patches, similar to the patches variant under parameters",
},
"dependencies": dependencies,
"build_spec": build_spec,
"external": {
"type": "object",
"additionalProperties": False,
"description": "If path or module (or both) are set, the spec is an external "
"system-installed package",
"properties": {
"path": {
"type": ["string", "null"],
"description": "Install prefix on the system, e.g. /usr",
},
"module": {
"anyOf": [{"type": "array", "items": {"type": "string"}}, {"type": "null"}],
"description": 'List of module names, e.g. ["pkg/1.2"]',
},
"extra_attributes": {
"type": "object",
"description": "Package.py specific attributes to use the external package, "
"such as paths to compiler executables",
},
},
},
"annotations": {
"type": "object",
"properties": {
"original_specfile_version": {"type": "number"},
"compiler": {"type": "string"},
},
"required": ["original_specfile_version"],
"additionalProperties": False,
"description": "Currently used to preserve compiler information of old specs when "
"upgrading to a newer spec format",
},
},
}
#: Properties for inclusion in other schemas
properties: Dict[str, Any] = {
"spec": {
"type": "object",
"additionalProperties": False,
"required": ["_meta", "nodes"],
"properties": {
"_meta": {
"type": "object",
"properties": {"version": {"type": "number"}},
"description": "Spec schema version metadata, used for parsing spec files",
},
"nodes": {
"type": "array",
"items": spec_node,
"description": "List of spec nodes which, combined with dependencies, induce a "
"DAG",
},
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack spec schema",
"type": "object",
"additionalProperties": False,
"required": ["spec"],
"properties": properties,
}
- spack.schema.spec.dependencies_v1¶
Corresponds to specfile format v1
- spack.schema.spec.dependencies_v2_v3¶
Corresponds to specfile format v2-v3
- spack.schema.spec.dependencies_v4_plus¶
Corresponds to specfile format v4+
- spack.schema.spec.schema¶
Full schema with metadata
- spack.schema.spec.spec_node¶
Schema for a single spec node (used in both spec files and database entries)
spack.schema.spec_list module¶
spack.schema.toolchains module¶
Schema for toolchains.yaml configuration file.
properties: Dict[str, Any] = {
"toolchains": {
"type": "object",
"default": {},
"additionalProperties": {
"oneOf": [
{"type": "string"},
{
"type": "array",
"items": {
"type": "object",
"properties": {"spec": {"type": "string"}, "when": {"type": "string"}},
},
},
]
},
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack toolchain configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.toolchains.schema¶
Full schema with metadata
spack.schema.upstreams module¶
- spack.schema.upstreams.schema¶
Full schema with metadata
spack.schema.url_buildcache_manifest module¶
Schema for buildcache entry manifest file
properties: Dict[str, Any] = {
"version": {"type": "integer"},
"data": {
"type": "array",
"items": {
"type": "object",
"required": [
"contentLength",
"mediaType",
"compression",
"checksumAlgorithm",
"checksum",
],
"properties": {
"contentLength": {"type": "integer"},
"mediaType": {"type": "string"},
"compression": {"type": "string"},
"checksumAlgorithm": {"type": "string"},
"checksum": {"type": "string"},
},
"additionalProperties": True,
},
},
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Buildcache manifest schema",
"type": "object",
"required": ["version", "data"],
"additionalProperties": True,
"properties": properties,
}
- spack.schema.url_buildcache_manifest.schema¶
Full schema with metadata
spack.schema.view module¶
Schema for view
projections_scheme = spack.schema.projections.properties["projections"]
#: Properties for inclusion in other schemas
properties: Dict[str, Any] = {
"view": {
"anyOf": [
{"type": "boolean"},
{"type": "string"},
{
"type": "object",
"additionalProperties": {
"required": ["root"],
"additionalProperties": False,
"properties": {
"root": {"type": "string"},
"link": {"enum": ["roots", "all", "run"]},
"link_type": {"type": "string"},
"select": {"type": "array", "items": {"type": "string"}},
"exclude": {"type": "array", "items": {"type": "string"}},
"projections": projections_scheme,
},
},
},
]
}
}
#: Full schema with metadata
schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Spack view configuration file schema",
"type": "object",
"additionalProperties": False,
"properties": properties,
}
- spack.schema.view.schema¶
Full schema with metadata