Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/feelpp/spack into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhomm committed Sep 14, 2024
2 parents 18aefab + d2e094d commit 6beea2a
Show file tree
Hide file tree
Showing 79 changed files with 659 additions and 369 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Ubuntu 20.04",
"image": "ghcr.io/spack/ubuntu20.04-runner-amd64-gcc-11.4:2023.08.01",
"postCreateCommand": "./.devcontainer/postCreateCommand.sh"
}
5 changes: 5 additions & 0 deletions .devcontainer/ubuntu22.04/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Ubuntu 22.04",
"image": "ghcr.io/spack/ubuntu-22.04:v2024-05-07",
"postCreateCommand": "./.devcontainer/postCreateCommand.sh"
}
4 changes: 2 additions & 2 deletions lib/spack/docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ sphinx-rtd-theme==2.0.0
python-levenshtein==0.25.1
docutils==0.20.1
pygments==2.18.0
urllib3==2.2.2
pytest==8.3.2
urllib3==2.2.3
pytest==8.3.3
isort==5.13.2
black==24.8.0
flake8==7.1.1
Expand Down
88 changes: 87 additions & 1 deletion lib/spack/spack/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ def _search_duplicate_compilers(error_cls):
import pickle
import re
import warnings
from typing import Iterable, List, Set, Tuple
from urllib.request import urlopen

import llnl.util.lang

import spack.config
import spack.patch
import spack.paths
import spack.repo
import spack.spec
import spack.util.crypto
Expand All @@ -73,7 +75,9 @@ def __init__(self, summary, details):
self.details = tuple(details)

def __str__(self):
return self.summary + "\n" + "\n".join([" " + detail for detail in self.details])
if self.details:
return f"{self.summary}\n" + "\n".join(f" {detail}" for detail in self.details)
return self.summary

def __eq__(self, other):
if self.summary != other.summary or self.details != other.details:
Expand Down Expand Up @@ -679,6 +683,88 @@ def _ensure_env_methods_are_ported_to_builders(pkgs, error_cls):
return errors


class DeprecatedMagicGlobals(ast.NodeVisitor):
def __init__(self, magic_globals: Iterable[str]):
super().__init__()

self.magic_globals: Set[str] = set(magic_globals)

# State to track whether we're in a class function
self.depth: int = 0
self.in_function: bool = False
self.path = (ast.Module, ast.ClassDef, ast.FunctionDef)

# Defined locals in the current function (heuristically at least)
self.locals: Set[str] = set()

# List of (name, lineno) tuples for references to magic globals
self.references_to_globals: List[Tuple[str, int]] = []

def descend_in_function_def(self, node: ast.AST) -> None:
if not isinstance(node, self.path[self.depth]):
return
self.depth += 1
if self.depth == len(self.path):
self.in_function = True
super().generic_visit(node)
if self.depth == len(self.path):
self.in_function = False
self.locals.clear()
self.depth -= 1

def generic_visit(self, node: ast.AST) -> None:
# Recurse into function definitions
if self.depth < len(self.path):
return self.descend_in_function_def(node)
elif not self.in_function:
return
elif isinstance(node, ast.Global):
for name in node.names:
if name in self.magic_globals:
self.references_to_globals.append((name, node.lineno))
elif isinstance(node, ast.Assign):
# visit the rhs before lhs
super().visit(node.value)
for target in node.targets:
super().visit(target)
elif isinstance(node, ast.Name) and node.id in self.magic_globals:
if isinstance(node.ctx, ast.Load) and node.id not in self.locals:
self.references_to_globals.append((node.id, node.lineno))
elif isinstance(node.ctx, ast.Store):
self.locals.add(node.id)
else:
super().generic_visit(node)


@package_properties
def _uses_deprecated_globals(pkgs, error_cls):
"""Ensure that packages do not use deprecated globals"""
errors = []

for pkg_name in pkgs:
# some packages scheduled to be removed in v0.23 are not worth fixing.
pkg_cls = spack.repo.PATH.get_pkg_class(pkg_name)
if all(v.get("deprecated", False) for v in pkg_cls.versions.values()):
continue

file = spack.repo.PATH.filename_for_package_name(pkg_name)
tree = ast.parse(open(file).read())
visitor = DeprecatedMagicGlobals(("std_cmake_args",))
visitor.visit(tree)
if visitor.references_to_globals:
errors.append(
error_cls(
f"Package '{pkg_name}' uses deprecated globals",
[
f"{file}:{line} references '{name}'"
for name, line in visitor.references_to_globals
],
)
)

return errors


@package_https_directives
def _linting_package_file(pkgs, error_cls):
"""Check for correctness of links"""
Expand Down
14 changes: 5 additions & 9 deletions lib/spack/spack/cmd/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,11 @@ def audit(parser, args):
def _process_reports(reports):
for check, errors in reports:
if errors:
msg = "{0}: {1} issue{2} found".format(
check, len(errors), "" if len(errors) == 1 else "s"
)
header = "@*b{" + msg + "}"
print(cl.colorize(header))
status = f"{len(errors)} issue{'' if len(errors) == 1 else 's'} found"
print(cl.colorize(f"{check}: @*r{{{status}}}"))
numdigits = len(str(len(errors)))
for idx, error in enumerate(errors):
print(str(idx + 1) + ". " + str(error))
print(f"{idx + 1:>{numdigits}}. {error}")
raise SystemExit(1)
else:
msg = "{0}: 0 issues found.".format(check)
header = "@*b{" + msg + "}"
print(cl.colorize(header))
print(cl.colorize(f"{check}: @*g{{passed}}"))
11 changes: 11 additions & 0 deletions lib/spack/spack/cmd/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def setup_parser(subparser):
options = [
("--detectable", print_detectable.__doc__),
("--maintainers", print_maintainers.__doc__),
("--namespace", print_namespace.__doc__),
("--no-dependencies", "do not " + print_dependencies.__doc__),
("--no-variants", "do not " + print_variants.__doc__),
("--no-versions", "do not " + print_versions.__doc__),
Expand Down Expand Up @@ -189,6 +190,15 @@ def print_maintainers(pkg, args):
color.cprint(section_title("Maintainers: ") + mnt)


def print_namespace(pkg, args):
"""output package namespace"""

repo = spack.repo.PATH.get_repo(pkg.namespace)
color.cprint("")
color.cprint(section_title("Namespace:"))
color.cprint(f" @c{{{repo.namespace}}} at {repo.root}")


def print_phases(pkg, args):
"""output installation phases"""

Expand Down Expand Up @@ -522,6 +532,7 @@ def info(parser, args):
# Now output optional information in expected order
sections = [
(args.all or args.maintainers, print_maintainers),
(args.all or args.namespace, print_namespace),
(args.all or args.detectable, print_detectable),
(args.all or args.tags, print_tags),
(args.all or not args.no_versions, print_versions),
Expand Down
5 changes: 2 additions & 3 deletions lib/spack/spack/container/writers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ def __call__(self):
return t.render(**self.to_dict())


import spack.container.writers.docker # noqa: E402

# Import after function definition all the modules in this package,
# so that registration of writers will happen automatically
import spack.container.writers.singularity # noqa: E402
from . import docker # noqa: F401 E402
from . import singularity # noqa: F401 E402
1 change: 0 additions & 1 deletion lib/spack/spack/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import spack.config
import spack.error
import spack.fetch_strategy
import spack.mirror
import spack.oci.image
import spack.repo
import spack.spec
Expand Down
3 changes: 1 addition & 2 deletions lib/spack/spack/modules/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import spack.deptypes as dt
import spack.environment
import spack.error
import spack.modules.common
import spack.paths
import spack.projections as proj
import spack.repo
Expand Down Expand Up @@ -352,7 +351,7 @@ def get_module(module_type, spec, get_full_path, module_set_name="default", requ
except spack.repo.UnknownPackageError:
upstream, record = spack.store.STORE.db.query_by_spec_hash(spec.dag_hash())
if upstream:
module = spack.modules.common.upstream_module_index.upstream_module(spec, module_type)
module = upstream_module_index.upstream_module(spec, module_type)
if not module:
return None

Expand Down
5 changes: 2 additions & 3 deletions lib/spack/spack/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import spack.paths
import spack.resource
import spack.spec
import spack.stage
import spack.util.crypto
import spack.util.lock
import spack.util.path as sup
Expand Down Expand Up @@ -981,8 +980,8 @@ def interactive_version_filter(
data = buffer.getvalue().encode("utf-8")

short_hash = hashlib.sha1(data).hexdigest()[:7]
filename = f"{spack.stage.stage_prefix}versions-{short_hash}.txt"
filepath = os.path.join(spack.stage.get_stage_root(), filename)
filename = f"{stage_prefix}versions-{short_hash}.txt"
filepath = os.path.join(get_stage_root(), filename)

# Write contents
with open(filepath, "wb") as f:
Expand Down
1 change: 0 additions & 1 deletion lib/spack/spack/test/cmd/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_it_just_runs(pkg):
"mpilander",
"mvapich2",
"openmpi",
"[email protected]",
"[email protected]:",
"[email protected]:",
"spectrum-mpi",
Expand Down
2 changes: 1 addition & 1 deletion share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ e4s-neoverse_v1-build:

e4s-rocm-external-generate:
extends: [ ".e4s-rocm-external", ".generate-x86_64"]
image: ecpe4s/ubuntu22.04-runner-amd64-gcc-11.4-rocm6.1.2:2024.07.22
image: ecpe4s/ubuntu22.04-runner-amd64-gcc-11.4-rocm6.2.0:2024.09.11

e4s-rocm-external-build:
extends: [ ".e4s-rocm-external", ".build" ]
Expand Down
Loading

0 comments on commit 6beea2a

Please sign in to comment.