Add package class hook for SNL work
This commit is contained in:
parent
9c575ef310
commit
2fafba4395
@ -989,6 +989,15 @@ def detect_dev_src_change(self) -> bool:
|
||||
assert dev_path_var and record, "dev_path variant and record must be present"
|
||||
return fsys.recursive_mtime_greater_than(dev_path_var.value, record.installation_time)
|
||||
|
||||
def resolve_binary_provenance(self):
|
||||
"""
|
||||
Method to ensure concrete spec has binary provenance.
|
||||
Base implementation will look up git commits when appropriate.
|
||||
Packages may override this implementation for custom implementations
|
||||
"""
|
||||
# TODO in follow on PR adding here so SNL team can begin work ahead of spack core
|
||||
pass
|
||||
|
||||
def all_urls_for_version(self, version: StandardVersion) -> List[str]:
|
||||
"""Return all URLs derived from version_urls(), url, urls, and
|
||||
list_url (if it contains a version) in a package in that order.
|
||||
|
@ -4185,6 +4185,42 @@ def execute_explicit_splices(self):
|
||||
return specs
|
||||
|
||||
|
||||
def _specs_with_commits(spec):
|
||||
# StandardVersions paired to git branches or tags and GitVersions
|
||||
if not spec.version.needs_commit:
|
||||
return
|
||||
spec.package.resolve_binary_provenance()
|
||||
|
||||
# method above is in charge of assigning the commit variant
|
||||
has_commit_var = "commit" in spec.variants
|
||||
has_git_version = isinstance(spec.version, vn.GitVersion)
|
||||
|
||||
if not (has_commit_var or has_git_version):
|
||||
return
|
||||
|
||||
# Specs with commit variants
|
||||
# - variant value satsifies commit regex
|
||||
# - paired to a GitVersion or version that is associated with a branch/tag
|
||||
# - variant value should match GitVersion's commit value
|
||||
if has_commit_var:
|
||||
invalid_commit_msg = (
|
||||
f"Internal Error: {spec.name}'s assigned commit {spec.variants['commit'].value}"
|
||||
" does not meet commit syntax requirements."
|
||||
)
|
||||
|
||||
# TODO probably want a more specific function just for sha validation
|
||||
assert vn.is_git_version(spec.variants["commit"].value), invalid_commit_msg
|
||||
|
||||
# Specs with GitVersions
|
||||
# - must have a commit variant, or add it here
|
||||
# - must have a commit on the GitVersion (enforce after look up implemented)
|
||||
if has_git_version:
|
||||
if not spec.version.commit_sha:
|
||||
# TODO(psakiev) this will be a failure when commit look up is automated
|
||||
return
|
||||
spec.variants["commit"] = vt.SingleValuedVariant("commit", spec.version.commit_sha)
|
||||
|
||||
|
||||
def _inject_patches_variant(root: spack.spec.Spec) -> None:
|
||||
# This dictionary will store object IDs rather than Specs as keys
|
||||
# since the Spec __hash__ will change as patches are added to them
|
||||
|
@ -391,6 +391,9 @@ def isdevelop(self) -> bool:
|
||||
isinstance(p, VersionStrComponent) and isinstance(p.data, int) for p in self.version[0]
|
||||
)
|
||||
|
||||
def needs_commit(self) -> bool:
|
||||
return bool(self.get("branch") or self.get("tag"))
|
||||
|
||||
def is_prerelease(self) -> bool:
|
||||
return self.version[1][0] != FINAL
|
||||
|
||||
@ -716,6 +719,9 @@ def __hash__(self):
|
||||
def __contains__(self, other: object) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
def needs_commit(self) -> bool:
|
||||
return True
|
||||
|
||||
@property
|
||||
def ref_lookup(self):
|
||||
if self._ref_lookup:
|
||||
|
Loading…
Reference in New Issue
Block a user