From 0107792a9e11a6eaa923bd30460ebc3412981533 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 21 May 2025 11:25:02 +0200 Subject: [PATCH] archspec: change module from archspec to _vendoring.archspec (#50450) --- lib/spack/docs/conf.py | 2 +- .../_vendoring/_pyrsistent_version.pyi | 1 - lib/spack/external/_vendoring/altgraph.pyi | 1 - .../cpuid => _vendoring/archspec}/LICENSE | 0 .../{ => _vendoring}/archspec/LICENSE-APACHE | 0 .../{ => _vendoring}/archspec/LICENSE-MIT | 0 .../{ => _vendoring}/archspec/__init__.py | 2 +- .../{ => _vendoring}/archspec/__main__.py | 0 .../external/{ => _vendoring}/archspec/cli.py | 10 +- .../{ => _vendoring}/archspec/cpu/__init__.py | 0 .../{ => _vendoring}/archspec/cpu/alias.py | 0 .../{ => _vendoring}/archspec/cpu/detect.py | 0 .../archspec/cpu/microarchitecture.py | 8 +- .../{ => _vendoring}/archspec/cpu/schema.py | 0 .../archspec/json}/COPYRIGHT | 0 .../archspec/json/LICENSE-APACHE | 0 .../archspec/json/LICENSE-MIT | 0 .../{ => _vendoring}/archspec/json/NOTICE | 0 .../{ => _vendoring}/archspec/json/README.md | 0 .../archspec/json/cpu/cpuid.json | 0 .../archspec/json/cpu/cpuid_schema.json | 0 .../archspec/json/cpu/microarchitectures.json | 0 .../json/cpu/microarchitectures_schema.json | 0 .../_vendoring/archspec/vendor/cpuid/LICENSE | 20 ++ .../archspec/vendor/cpuid/README.md | 0 .../archspec/vendor/cpuid/cpuid.py | 0 .../archspec/vendor/cpuid/example.py | 0 lib/spack/external/_vendoring/jsonschema.pyi | 1 - lib/spack/external/_vendoring/macholib.pyi | 1 - .../_vendoring/pyrsistent/__init__.pyi | 213 ------------------ lib/spack/external/_vendoring/ruamel.pyi | 1 - .../external/_vendoring/six/__init__.pyi | 1 - .../_vendoring/six/moves/__init__.pyi | 1 - .../_vendoring/six/moves/configparser.pyi | 1 - lib/spack/external/archspec/README.md | 81 ------- lib/spack/external/archspec/json/COPYRIGHT | 22 -- lib/spack/external/vendor.txt | 1 + lib/spack/spack/bootstrap/_common.py | 7 +- lib/spack/spack/bootstrap/clingo.py | 4 +- lib/spack/spack/bootstrap/environment.py | 6 +- lib/spack/spack/build_environment.py | 8 +- lib/spack/spack/cmd/arch.py | 6 +- lib/spack/spack/compilers/config.py | 4 +- lib/spack/spack/main.py | 6 +- lib/spack/spack/platforms/_platform.py | 8 +- lib/spack/spack/platforms/test.py | 4 +- lib/spack/spack/solver/asp.py | 12 +- lib/spack/spack/solver/input_analysis.py | 12 +- lib/spack/spack/spec.py | 13 +- lib/spack/spack/test/architecture.py | 6 +- lib/spack/spack/test/build_environment.py | 8 +- lib/spack/spack/test/build_systems.py | 6 +- .../test/concretization/compiler_runtimes.py | 9 +- lib/spack/spack/test/concretization/core.py | 19 +- lib/spack/spack/test/conftest.py | 23 +- lib/spack/spack/test/cray_manifest.py | 5 +- lib/spack/spack/test/modules/lmod.py | 6 +- lib/spack/spack/test/modules/tcl.py | 6 +- pyproject.toml | 19 +- .../builtin/build_systems/python.py | 4 +- .../packages/compiler_wrapper/package.py | 7 +- .../builtin_mock/build_systems/python.py | 4 +- .../packages/compiler_wrapper/package.py | 7 +- 63 files changed, 145 insertions(+), 441 deletions(-) delete mode 100644 lib/spack/external/_vendoring/_pyrsistent_version.pyi delete mode 100644 lib/spack/external/_vendoring/altgraph.pyi rename lib/spack/external/{archspec/vendor/cpuid => _vendoring/archspec}/LICENSE (100%) rename lib/spack/external/{ => _vendoring}/archspec/LICENSE-APACHE (100%) rename lib/spack/external/{ => _vendoring}/archspec/LICENSE-MIT (100%) rename lib/spack/external/{ => _vendoring}/archspec/__init__.py (67%) rename lib/spack/external/{ => _vendoring}/archspec/__main__.py (100%) rename lib/spack/external/{ => _vendoring}/archspec/cli.py (86%) rename lib/spack/external/{ => _vendoring}/archspec/cpu/__init__.py (100%) rename lib/spack/external/{ => _vendoring}/archspec/cpu/alias.py (100%) rename lib/spack/external/{ => _vendoring}/archspec/cpu/detect.py (100%) rename lib/spack/external/{ => _vendoring}/archspec/cpu/microarchitecture.py (98%) rename lib/spack/external/{ => _vendoring}/archspec/cpu/schema.py (100%) rename lib/spack/external/{archspec => _vendoring/archspec/json}/COPYRIGHT (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/LICENSE-APACHE (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/LICENSE-MIT (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/NOTICE (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/README.md (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/cpu/cpuid.json (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/cpu/cpuid_schema.json (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/cpu/microarchitectures.json (100%) rename lib/spack/external/{ => _vendoring}/archspec/json/cpu/microarchitectures_schema.json (100%) create mode 100644 lib/spack/external/_vendoring/archspec/vendor/cpuid/LICENSE rename lib/spack/external/{ => _vendoring}/archspec/vendor/cpuid/README.md (100%) rename lib/spack/external/{ => _vendoring}/archspec/vendor/cpuid/cpuid.py (100%) rename lib/spack/external/{ => _vendoring}/archspec/vendor/cpuid/example.py (100%) delete mode 100644 lib/spack/external/_vendoring/jsonschema.pyi delete mode 100644 lib/spack/external/_vendoring/macholib.pyi delete mode 100644 lib/spack/external/_vendoring/pyrsistent/__init__.pyi delete mode 100644 lib/spack/external/_vendoring/ruamel.pyi delete mode 100644 lib/spack/external/_vendoring/six/__init__.pyi delete mode 100644 lib/spack/external/_vendoring/six/moves/__init__.pyi delete mode 100644 lib/spack/external/_vendoring/six/moves/configparser.pyi delete mode 100644 lib/spack/external/archspec/README.md delete mode 100644 lib/spack/external/archspec/json/COPYRIGHT diff --git a/lib/spack/docs/conf.py b/lib/spack/docs/conf.py index 9541fe6ad11..1a783ca5516 100644 --- a/lib/spack/docs/conf.py +++ b/lib/spack/docs/conf.py @@ -228,7 +228,7 @@ def setup(sphinx): ("py:class", "spack.install_test.Pb"), ("py:class", "spack.filesystem_view.SimpleFilesystemView"), ("py:class", "spack.traverse.EdgeAndDepth"), - ("py:class", "archspec.cpu.microarchitecture.Microarchitecture"), + ("py:class", "_vendoring.archspec.cpu.microarchitecture.Microarchitecture"), ("py:class", "spack.compiler.CompilerCache"), # TypeVar that is not handled correctly ("py:class", "llnl.util.lang.T"), diff --git a/lib/spack/external/_vendoring/_pyrsistent_version.pyi b/lib/spack/external/_vendoring/_pyrsistent_version.pyi deleted file mode 100644 index 873cc62efdd..00000000000 --- a/lib/spack/external/_vendoring/_pyrsistent_version.pyi +++ /dev/null @@ -1 +0,0 @@ -from _pyrsistent_version import * \ No newline at end of file diff --git a/lib/spack/external/_vendoring/altgraph.pyi b/lib/spack/external/_vendoring/altgraph.pyi deleted file mode 100644 index 0d67a24e016..00000000000 --- a/lib/spack/external/_vendoring/altgraph.pyi +++ /dev/null @@ -1 +0,0 @@ -from altgraph import * \ No newline at end of file diff --git a/lib/spack/external/archspec/vendor/cpuid/LICENSE b/lib/spack/external/_vendoring/archspec/LICENSE similarity index 100% rename from lib/spack/external/archspec/vendor/cpuid/LICENSE rename to lib/spack/external/_vendoring/archspec/LICENSE diff --git a/lib/spack/external/archspec/LICENSE-APACHE b/lib/spack/external/_vendoring/archspec/LICENSE-APACHE similarity index 100% rename from lib/spack/external/archspec/LICENSE-APACHE rename to lib/spack/external/_vendoring/archspec/LICENSE-APACHE diff --git a/lib/spack/external/archspec/LICENSE-MIT b/lib/spack/external/_vendoring/archspec/LICENSE-MIT similarity index 100% rename from lib/spack/external/archspec/LICENSE-MIT rename to lib/spack/external/_vendoring/archspec/LICENSE-MIT diff --git a/lib/spack/external/archspec/__init__.py b/lib/spack/external/_vendoring/archspec/__init__.py similarity index 67% rename from lib/spack/external/archspec/__init__.py rename to lib/spack/external/_vendoring/archspec/__init__.py index 2930ad719e4..2425354e623 100644 --- a/lib/spack/external/archspec/__init__.py +++ b/lib/spack/external/_vendoring/archspec/__init__.py @@ -1,3 +1,3 @@ """Init file to avoid namespace packages""" -__version__ = "0.2.4" +__version__ = "0.2.5" diff --git a/lib/spack/external/archspec/__main__.py b/lib/spack/external/_vendoring/archspec/__main__.py similarity index 100% rename from lib/spack/external/archspec/__main__.py rename to lib/spack/external/_vendoring/archspec/__main__.py diff --git a/lib/spack/external/archspec/cli.py b/lib/spack/external/_vendoring/archspec/cli.py similarity index 86% rename from lib/spack/external/archspec/cli.py rename to lib/spack/external/_vendoring/archspec/cli.py index eaddaf5d77b..edd4fd30e88 100755 --- a/lib/spack/external/archspec/cli.py +++ b/lib/spack/external/_vendoring/archspec/cli.py @@ -9,8 +9,8 @@ import argparse import typing -import archspec -import archspec.cpu +import _vendoring.archspec +import _vendoring.archspec.cpu def _make_parser() -> argparse.ArgumentParser: @@ -24,7 +24,7 @@ def _make_parser() -> argparse.ArgumentParser: "-V", help="Show the version and exit.", action="version", - version=f"archspec, version {archspec.__version__}", + version=f"archspec, version {_vendoring.archspec.__version__}", ) parser.add_argument("--help", "-h", help="Show the help and exit.", action="help") @@ -45,9 +45,9 @@ def _make_parser() -> argparse.ArgumentParser: def cpu() -> int: - """Run the `archspec cpu` subcommand.""" + """Run the `_vendoring.archspec.cpu` subcommand.""" try: - print(archspec.cpu.host()) + print(_vendoring.archspec.cpu.host()) except FileNotFoundError as exc: print(exc) return 1 diff --git a/lib/spack/external/archspec/cpu/__init__.py b/lib/spack/external/_vendoring/archspec/cpu/__init__.py similarity index 100% rename from lib/spack/external/archspec/cpu/__init__.py rename to lib/spack/external/_vendoring/archspec/cpu/__init__.py diff --git a/lib/spack/external/archspec/cpu/alias.py b/lib/spack/external/_vendoring/archspec/cpu/alias.py similarity index 100% rename from lib/spack/external/archspec/cpu/alias.py rename to lib/spack/external/_vendoring/archspec/cpu/alias.py diff --git a/lib/spack/external/archspec/cpu/detect.py b/lib/spack/external/_vendoring/archspec/cpu/detect.py similarity index 100% rename from lib/spack/external/archspec/cpu/detect.py rename to lib/spack/external/_vendoring/archspec/cpu/detect.py diff --git a/lib/spack/external/archspec/cpu/microarchitecture.py b/lib/spack/external/_vendoring/archspec/cpu/microarchitecture.py similarity index 98% rename from lib/spack/external/archspec/cpu/microarchitecture.py rename to lib/spack/external/_vendoring/archspec/cpu/microarchitecture.py index bb85b9f37c0..17918753d3b 100644 --- a/lib/spack/external/archspec/cpu/microarchitecture.py +++ b/lib/spack/external/_vendoring/archspec/cpu/microarchitecture.py @@ -8,9 +8,9 @@ import re import warnings -import archspec -import archspec.cpu.alias -import archspec.cpu.schema +import _vendoring.archspec +import _vendoring.archspec.cpu.alias +import _vendoring.archspec.cpu.schema from .alias import FEATURE_ALIASES from .schema import LazyDictionary @@ -384,7 +384,7 @@ def fill_target_from_dict(name, data, targets): ) known_targets = {} - data = archspec.cpu.schema.TARGETS_JSON["microarchitectures"] + data = _vendoring.archspec.cpu.schema.TARGETS_JSON["microarchitectures"] for name in data: if name in known_targets: # name was already brought in as ancestor to a target diff --git a/lib/spack/external/archspec/cpu/schema.py b/lib/spack/external/_vendoring/archspec/cpu/schema.py similarity index 100% rename from lib/spack/external/archspec/cpu/schema.py rename to lib/spack/external/_vendoring/archspec/cpu/schema.py diff --git a/lib/spack/external/archspec/COPYRIGHT b/lib/spack/external/_vendoring/archspec/json/COPYRIGHT similarity index 100% rename from lib/spack/external/archspec/COPYRIGHT rename to lib/spack/external/_vendoring/archspec/json/COPYRIGHT diff --git a/lib/spack/external/archspec/json/LICENSE-APACHE b/lib/spack/external/_vendoring/archspec/json/LICENSE-APACHE similarity index 100% rename from lib/spack/external/archspec/json/LICENSE-APACHE rename to lib/spack/external/_vendoring/archspec/json/LICENSE-APACHE diff --git a/lib/spack/external/archspec/json/LICENSE-MIT b/lib/spack/external/_vendoring/archspec/json/LICENSE-MIT similarity index 100% rename from lib/spack/external/archspec/json/LICENSE-MIT rename to lib/spack/external/_vendoring/archspec/json/LICENSE-MIT diff --git a/lib/spack/external/archspec/json/NOTICE b/lib/spack/external/_vendoring/archspec/json/NOTICE similarity index 100% rename from lib/spack/external/archspec/json/NOTICE rename to lib/spack/external/_vendoring/archspec/json/NOTICE diff --git a/lib/spack/external/archspec/json/README.md b/lib/spack/external/_vendoring/archspec/json/README.md similarity index 100% rename from lib/spack/external/archspec/json/README.md rename to lib/spack/external/_vendoring/archspec/json/README.md diff --git a/lib/spack/external/archspec/json/cpu/cpuid.json b/lib/spack/external/_vendoring/archspec/json/cpu/cpuid.json similarity index 100% rename from lib/spack/external/archspec/json/cpu/cpuid.json rename to lib/spack/external/_vendoring/archspec/json/cpu/cpuid.json diff --git a/lib/spack/external/archspec/json/cpu/cpuid_schema.json b/lib/spack/external/_vendoring/archspec/json/cpu/cpuid_schema.json similarity index 100% rename from lib/spack/external/archspec/json/cpu/cpuid_schema.json rename to lib/spack/external/_vendoring/archspec/json/cpu/cpuid_schema.json diff --git a/lib/spack/external/archspec/json/cpu/microarchitectures.json b/lib/spack/external/_vendoring/archspec/json/cpu/microarchitectures.json similarity index 100% rename from lib/spack/external/archspec/json/cpu/microarchitectures.json rename to lib/spack/external/_vendoring/archspec/json/cpu/microarchitectures.json diff --git a/lib/spack/external/archspec/json/cpu/microarchitectures_schema.json b/lib/spack/external/_vendoring/archspec/json/cpu/microarchitectures_schema.json similarity index 100% rename from lib/spack/external/archspec/json/cpu/microarchitectures_schema.json rename to lib/spack/external/_vendoring/archspec/json/cpu/microarchitectures_schema.json diff --git a/lib/spack/external/_vendoring/archspec/vendor/cpuid/LICENSE b/lib/spack/external/_vendoring/archspec/vendor/cpuid/LICENSE new file mode 100644 index 00000000000..af36480022f --- /dev/null +++ b/lib/spack/external/_vendoring/archspec/vendor/cpuid/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Anders Høst + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/spack/external/archspec/vendor/cpuid/README.md b/lib/spack/external/_vendoring/archspec/vendor/cpuid/README.md similarity index 100% rename from lib/spack/external/archspec/vendor/cpuid/README.md rename to lib/spack/external/_vendoring/archspec/vendor/cpuid/README.md diff --git a/lib/spack/external/archspec/vendor/cpuid/cpuid.py b/lib/spack/external/_vendoring/archspec/vendor/cpuid/cpuid.py similarity index 100% rename from lib/spack/external/archspec/vendor/cpuid/cpuid.py rename to lib/spack/external/_vendoring/archspec/vendor/cpuid/cpuid.py diff --git a/lib/spack/external/archspec/vendor/cpuid/example.py b/lib/spack/external/_vendoring/archspec/vendor/cpuid/example.py similarity index 100% rename from lib/spack/external/archspec/vendor/cpuid/example.py rename to lib/spack/external/_vendoring/archspec/vendor/cpuid/example.py diff --git a/lib/spack/external/_vendoring/jsonschema.pyi b/lib/spack/external/_vendoring/jsonschema.pyi deleted file mode 100644 index 85b509b63f3..00000000000 --- a/lib/spack/external/_vendoring/jsonschema.pyi +++ /dev/null @@ -1 +0,0 @@ -from jsonschema import * \ No newline at end of file diff --git a/lib/spack/external/_vendoring/macholib.pyi b/lib/spack/external/_vendoring/macholib.pyi deleted file mode 100644 index 62ac8a00a38..00000000000 --- a/lib/spack/external/_vendoring/macholib.pyi +++ /dev/null @@ -1 +0,0 @@ -from macholib import * \ No newline at end of file diff --git a/lib/spack/external/_vendoring/pyrsistent/__init__.pyi b/lib/spack/external/_vendoring/pyrsistent/__init__.pyi deleted file mode 100644 index 5909f7991a9..00000000000 --- a/lib/spack/external/_vendoring/pyrsistent/__init__.pyi +++ /dev/null @@ -1,213 +0,0 @@ -# flake8: noqa: E704 -# from https://gist.github.com/WuTheFWasThat/091a17d4b5cab597dfd5d4c2d96faf09 -# Stubs for pyrsistent (Python 3.6) - -from typing import Any -from typing import AnyStr -from typing import Callable -from typing import Iterable -from typing import Iterator -from typing import List -from typing import Optional -from typing import Mapping -from typing import MutableMapping -from typing import Sequence -from typing import Set -from typing import Union -from typing import Tuple -from typing import Type -from typing import TypeVar -from typing import overload - -# see commit 08519aa for explanation of the re-export -from pyrsistent.typing import CheckedKeyTypeError as CheckedKeyTypeError -from pyrsistent.typing import CheckedPMap as CheckedPMap -from pyrsistent.typing import CheckedPSet as CheckedPSet -from pyrsistent.typing import CheckedPVector as CheckedPVector -from pyrsistent.typing import CheckedType as CheckedType -from pyrsistent.typing import CheckedValueTypeError as CheckedValueTypeError -from pyrsistent.typing import InvariantException as InvariantException -from pyrsistent.typing import PClass as PClass -from pyrsistent.typing import PBag as PBag -from pyrsistent.typing import PDeque as PDeque -from pyrsistent.typing import PList as PList -from pyrsistent.typing import PMap as PMap -from pyrsistent.typing import PMapEvolver as PMapEvolver -from pyrsistent.typing import PSet as PSet -from pyrsistent.typing import PSetEvolver as PSetEvolver -from pyrsistent.typing import PTypeError as PTypeError -from pyrsistent.typing import PVector as PVector -from pyrsistent.typing import PVectorEvolver as PVectorEvolver - -T = TypeVar('T') -KT = TypeVar('KT') -VT = TypeVar('VT') - -def pmap(initial: Union[Mapping[KT, VT], Iterable[Tuple[KT, VT]]] = {}, pre_size: int = 0) -> PMap[KT, VT]: ... -def m(**kwargs: VT) -> PMap[str, VT]: ... - -def pvector(iterable: Iterable[T] = ...) -> PVector[T]: ... -def v(*iterable: T) -> PVector[T]: ... - -def pset(iterable: Iterable[T] = (), pre_size: int = 8) -> PSet[T]: ... -def s(*iterable: T) -> PSet[T]: ... - -# see class_test.py for use cases -Invariant = Tuple[bool, Optional[Union[str, Callable[[], str]]]] - -@overload -def field( - type: Union[Type[T], Sequence[Type[T]]] = ..., - invariant: Callable[[Any], Union[Invariant, Iterable[Invariant]]] = lambda _: (True, None), - initial: Any = object(), - mandatory: bool = False, - factory: Callable[[Any], T] = lambda x: x, - serializer: Callable[[Any, T], Any] = lambda _, value: value, -) -> T: ... -# The actual return value (_PField) is irrelevant after a PRecord has been instantiated, -# see https://github.com/tobgu/pyrsistent/blob/master/pyrsistent/_precord.py#L10 -@overload -def field( - type: Any = ..., - invariant: Callable[[Any], Union[Invariant, Iterable[Invariant]]] = lambda _: (True, None), - initial: Any = object(), - mandatory: bool = False, - factory: Callable[[Any], Any] = lambda x: x, - serializer: Callable[[Any, Any], Any] = lambda _, value: value, -) -> Any: ... - -# Use precise types for the simplest use cases, but fall back to Any for -# everything else. See record_test.py for the wide range of possible types for -# item_type -@overload -def pset_field( - item_type: Type[T], - optional: bool = False, - initial: Iterable[T] = ..., -) -> PSet[T]: ... -@overload -def pset_field( - item_type: Any, - optional: bool = False, - initial: Any = (), -) -> PSet[Any]: ... - -@overload -def pmap_field( - key_type: Type[KT], - value_type: Type[VT], - optional: bool = False, - invariant: Callable[[Any], Tuple[bool, Optional[str]]] = lambda _: (True, None), -) -> PMap[KT, VT]: ... -@overload -def pmap_field( - key_type: Any, - value_type: Any, - optional: bool = False, - invariant: Callable[[Any], Tuple[bool, Optional[str]]] = lambda _: (True, None), -) -> PMap[Any, Any]: ... - -@overload -def pvector_field( - item_type: Type[T], - optional: bool = False, - initial: Iterable[T] = ..., -) -> PVector[T]: ... -@overload -def pvector_field( - item_type: Any, - optional: bool = False, - initial: Any = (), -) -> PVector[Any]: ... - -def pbag(elements: Iterable[T]) -> PBag[T]: ... -def b(*elements: T) -> PBag[T]: ... - -def plist(iterable: Iterable[T] = (), reverse: bool = False) -> PList[T]: ... -def l(*elements: T) -> PList[T]: ... - -def pdeque(iterable: Optional[Iterable[T]] = None, maxlen: Optional[int] = None) -> PDeque[T]: ... -def dq(*iterable: T) -> PDeque[T]: ... - -@overload -def optional(type: T) -> Tuple[T, Type[None]]: ... -@overload -def optional(*typs: Any) -> Tuple[Any, ...]: ... - -T_PRecord = TypeVar('T_PRecord', bound='PRecord') -class PRecord(PMap[AnyStr, Any]): - _precord_fields: Mapping - _precord_initial_values: Mapping - - def __hash__(self) -> int: ... - def __init__(self, **kwargs: Any) -> None: ... - def __iter__(self) -> Iterator[Any]: ... - def __len__(self) -> int: ... - @classmethod - def create( - cls: Type[T_PRecord], - kwargs: Mapping, - _factory_fields: Optional[Iterable] = None, - ignore_extra: bool = False, - ) -> T_PRecord: ... - # This is OK because T_PRecord is a concrete type - def discard(self: T_PRecord, key: KT) -> T_PRecord: ... - def remove(self: T_PRecord, key: KT) -> T_PRecord: ... - - def serialize(self, format: Optional[Any] = ...) -> MutableMapping: ... - - # From pyrsistent documentation: - # This set function differs slightly from that in the PMap - # class. First of all it accepts key-value pairs. Second it accepts multiple key-value - # pairs to perform one, atomic, update of multiple fields. - @overload - def set(self, key: KT, val: VT) -> Any: ... - @overload - def set(self, **kwargs: VT) -> Any: ... - -def immutable( - members: Union[str, Iterable[str]] = '', - name: str = 'Immutable', - verbose: bool = False, -) -> Tuple: ... # actually a namedtuple - -# ignore mypy warning "Overloaded function signatures 1 and 5 overlap with -# incompatible return types" -@overload -def freeze(o: Mapping[KT, VT]) -> PMap[KT, VT]: ... # type: ignore -@overload -def freeze(o: List[T]) -> PVector[T]: ... # type: ignore -@overload -def freeze(o: Tuple[T, ...]) -> Tuple[T, ...]: ... -@overload -def freeze(o: Set[T]) -> PSet[T]: ... # type: ignore -@overload -def freeze(o: T) -> T: ... - - -@overload -def thaw(o: PMap[KT, VT]) -> MutableMapping[KT, VT]: ... # type: ignore -@overload -def thaw(o: PVector[T]) -> List[T]: ... # type: ignore -@overload -def thaw(o: Tuple[T, ...]) -> Tuple[T, ...]: ... -# collections.abc.MutableSet is kind of garbage: -# https://stackoverflow.com/questions/24977898/why-does-collections-mutableset-not-bestow-an-update-method -@overload -def thaw(o: PSet[T]) -> Set[T]: ... # type: ignore -@overload -def thaw(o: T) -> T: ... - -def mutant(fn: Callable) -> Callable: ... - -def inc(x: int) -> int: ... -@overload -def discard(evolver: PMapEvolver[KT, VT], key: KT) -> None: ... -@overload -def discard(evolver: PVectorEvolver[T], key: int) -> None: ... -@overload -def discard(evolver: PSetEvolver[T], key: T) -> None: ... -def rex(expr: str) -> Callable[[Any], bool]: ... -def ny(_: Any) -> bool: ... - -def get_in(keys: Iterable, coll: Mapping, default: Optional[Any] = None, no_default: bool = False) -> Any: ... diff --git a/lib/spack/external/_vendoring/ruamel.pyi b/lib/spack/external/_vendoring/ruamel.pyi deleted file mode 100644 index c77c78e8e3e..00000000000 --- a/lib/spack/external/_vendoring/ruamel.pyi +++ /dev/null @@ -1 +0,0 @@ -from ruamel import * \ No newline at end of file diff --git a/lib/spack/external/_vendoring/six/__init__.pyi b/lib/spack/external/_vendoring/six/__init__.pyi deleted file mode 100644 index e5c0e242278..00000000000 --- a/lib/spack/external/_vendoring/six/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -from six import * \ No newline at end of file diff --git a/lib/spack/external/_vendoring/six/moves/__init__.pyi b/lib/spack/external/_vendoring/six/moves/__init__.pyi deleted file mode 100644 index 7a82f79db68..00000000000 --- a/lib/spack/external/_vendoring/six/moves/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -from six.moves import * \ No newline at end of file diff --git a/lib/spack/external/_vendoring/six/moves/configparser.pyi b/lib/spack/external/_vendoring/six/moves/configparser.pyi deleted file mode 100644 index f77b3f41052..00000000000 --- a/lib/spack/external/_vendoring/six/moves/configparser.pyi +++ /dev/null @@ -1 +0,0 @@ -from six.moves.configparser import * \ No newline at end of file diff --git a/lib/spack/external/archspec/README.md b/lib/spack/external/archspec/README.md deleted file mode 100644 index fb1eaebda3b..00000000000 --- a/lib/spack/external/archspec/README.md +++ /dev/null @@ -1,81 +0,0 @@ -[![](https://github.com/archspec/archspec/workflows/Unit%20tests/badge.svg)](https://github.com/archspec/archspec/actions) -[![codecov](https://codecov.io/gh/archspec/archspec/branch/master/graph/badge.svg)](https://codecov.io/gh/archspec/archspec) -[![Documentation Status](https://readthedocs.org/projects/archspec/badge/?version=latest)](https://archspec.readthedocs.io/en/latest/?badge=latest) - - -# Archspec (Python bindings) - -Archspec aims at providing a standard set of human-understandable labels for -various aspects of a system architecture like CPU, network fabrics, etc. and -APIs to detect, query and compare them. - -This project grew out of [Spack](https://spack.io/) and is currently under -active development. At present it supports APIs to detect and model -compatibility relationships among different CPU microarchitectures. - -## Getting started with development - -The `archspec` Python package needs [poetry](https://python-poetry.org/) to -be installed from VCS sources. The preferred method to install it is via -its custom installer outside of any virtual environment: -```console -$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -``` -You can refer to [Poetry's documentation](https://python-poetry.org/docs/#installation) -for further details or for other methods to install this tool. You'll also need `tox` -to run unit test: -```console -$ pip install --user tox -``` -Finally you'll need to clone the repository: -```console -$ git clone --recursive https://github.com/archspec/archspec.git -``` - -### Running unit tests -Once you have your environment ready you can run `archspec` unit tests -using ``tox`` from the root of the repository: -```console -$ tox - [ ... ] - py27: commands succeeded - py35: commands succeeded - py36: commands succeeded - py37: commands succeeded - py38: commands succeeded - pylint: commands succeeded - flake8: commands succeeded - black: commands succeeded - congratulations :) -``` - -## Citing Archspec - -If you are referencing `archspec` in a publication, please cite the following -paper: - - * Massimiliano Culpo, Gregory Becker, Carlos Eduardo Arango Gutierrez, Kenneth - Hoste, and Todd Gamblin. - [**`archspec`: A library for detecting, labeling, and reasoning about - microarchitectures**](https://tgamblin.github.io/pubs/archspec-canopie-hpc-2020.pdf). - In *2nd International Workshop on Containers and New Orchestration Paradigms - for Isolated Environments in HPC (CANOPIE-HPC'20)*, Online Event, November - 12, 2020. - -## License - -Archspec is distributed under the terms of both the MIT license and the -Apache License (Version 2.0). Users may choose either license, at their -option. - -All new contributions must be made under both the MIT and Apache-2.0 -licenses. - -See [LICENSE-MIT](https://github.com/archspec/archspec/blob/master/LICENSE-MIT), -[LICENSE-APACHE](https://github.com/archspec/archspec/blob/master/LICENSE-APACHE), -[COPYRIGHT](https://github.com/archspec/archspec/blob/master/COPYRIGHT), and -[NOTICE](https://github.com/archspec/archspec/blob/master/NOTICE) for details. - -SPDX-License-Identifier: (Apache-2.0 OR MIT) - -LLNL-CODE-811653 diff --git a/lib/spack/external/archspec/json/COPYRIGHT b/lib/spack/external/archspec/json/COPYRIGHT deleted file mode 100644 index 4164e98de77..00000000000 --- a/lib/spack/external/archspec/json/COPYRIGHT +++ /dev/null @@ -1,22 +0,0 @@ -Intellectual Property Notice ------------------------------- - -Archspec is licensed under the Apache License, Version 2.0 (LICENSE-APACHE -or http://www.apache.org/licenses/LICENSE-2.0) or the MIT license, -(LICENSE-MIT or http://opensource.org/licenses/MIT), at your option. - -Copyrights and patents in the Archspec project are retained by contributors. -No copyright assignment is required to contribute to Archspec. - - -SPDX usage ------------- - -Individual files contain SPDX tags instead of the full license text. -This enables machine processing of license information based on the SPDX -License Identifiers that are available here: https://spdx.org/licenses/ - -Files that are dual-licensed as Apache-2.0 OR MIT contain the following -text in the license header: - - SPDX-License-Identifier: (Apache-2.0 OR MIT) diff --git a/lib/spack/external/vendor.txt b/lib/spack/external/vendor.txt index 3a169354fb3..319fa418032 100644 --- a/lib/spack/external/vendor.txt +++ b/lib/spack/external/vendor.txt @@ -9,3 +9,4 @@ macholib==1.16.2 altgraph==0.17.3 ruamel.yaml==0.17.21 typing_extensions==4.1.1 +archspec @ git+https://github.com/archspec/archspec.git@38ce485258ffc4fc6dd6688f8dc90cb269478c47 diff --git a/lib/spack/spack/bootstrap/_common.py b/lib/spack/spack/bootstrap/_common.py index ee79f988fa5..218cbc5a161 100644 --- a/lib/spack/spack/bootstrap/_common.py +++ b/lib/spack/spack/bootstrap/_common.py @@ -12,10 +12,9 @@ import warnings from typing import Optional, Sequence, Union +import _vendoring.archspec.cpu from _vendoring.typing_extensions import TypedDict -import archspec.cpu - import llnl.util.filesystem as fs from llnl.util import tty @@ -138,7 +137,7 @@ def _fix_ext_suffix(candidate_spec: "spack.spec.Spec"): } # If the current architecture is not problematic return - generic_target = archspec.cpu.host().family + generic_target = _vendoring.archspec.cpu.host().family if str(generic_target) not in _suffix_to_be_checked: return @@ -235,7 +234,7 @@ def _root_spec(spec_str: str) -> str: platform = str(spack.platforms.host()) spec_str += f" platform={platform}" - target = archspec.cpu.host().family + target = _vendoring.archspec.cpu.host().family spec_str += f" target={target}" tty.debug(f"[BOOTSTRAP ROOT SPEC] {spec_str}") diff --git a/lib/spack/spack/bootstrap/clingo.py b/lib/spack/spack/bootstrap/clingo.py index 0267ad2e2cf..874c941f80e 100644 --- a/lib/spack/spack/bootstrap/clingo.py +++ b/lib/spack/spack/bootstrap/clingo.py @@ -13,7 +13,7 @@ import sys from typing import Dict, Optional, Tuple -import archspec.cpu +import _vendoring.archspec.cpu import spack.compilers.config import spack.compilers.libraries @@ -30,7 +30,7 @@ class ClingoBootstrapConcretizer: def __init__(self, configuration): self.host_platform = spack.platforms.host() self.host_os = self.host_platform.default_operating_system() - self.host_target = archspec.cpu.host().family + self.host_target = _vendoring.archspec.cpu.host().family self.host_architecture = spack.spec.ArchSpec.default_arch() self.host_architecture.target = str(self.host_target) self.host_compiler = self._valid_compiler_or_raise() diff --git a/lib/spack/spack/bootstrap/environment.py b/lib/spack/spack/bootstrap/environment.py index f2240da8ea5..a27810f88a4 100644 --- a/lib/spack/spack/bootstrap/environment.py +++ b/lib/spack/spack/bootstrap/environment.py @@ -8,7 +8,7 @@ import sys from typing import Iterable, List -import archspec.cpu +import _vendoring.archspec.cpu from llnl.util import tty @@ -51,7 +51,7 @@ def environment_root(cls) -> pathlib.Path: """Environment root directory""" bootstrap_root_path = root_path() python_part = spec_for_current_python().replace("@", "") - arch_part = archspec.cpu.host().family + arch_part = _vendoring.archspec.cpu.host().family interpreter_part = hashlib.md5(sys.exec_prefix.encode()).hexdigest()[:5] environment_dir = f"{python_part}-{arch_part}-{interpreter_part}" return pathlib.Path( @@ -112,7 +112,7 @@ def _write_spack_yaml_file(self) -> None: context = { "python_spec": spec_for_current_python(), "python_prefix": sys.exec_prefix, - "architecture": archspec.cpu.host().family, + "architecture": _vendoring.archspec.cpu.host().family, "environment_path": self.environment_root(), "environment_specs": self.spack_dev_requirements(), "store_path": store_path(), diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index b4a9b911862..3a70601f5c5 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -59,7 +59,7 @@ overload, ) -import archspec.cpu +import _vendoring.archspec.cpu import llnl.util.tty as tty from llnl.string import plural @@ -440,10 +440,12 @@ def optimization_flags(compiler, target): # Try to check if the current compiler comes with a version number or # has an unexpected suffix. If so, treat it as a compiler with a # custom spec. - version_number, _ = archspec.cpu.version_components(compiler.version.dotted_numeric_string) + version_number, _ = _vendoring.archspec.cpu.version_components( + compiler.version.dotted_numeric_string + ) try: result = target.optimization_flags(compiler.name, version_number) - except (ValueError, archspec.cpu.UnsupportedMicroarchitecture): + except (ValueError, _vendoring.archspec.cpu.UnsupportedMicroarchitecture): result = "" return result diff --git a/lib/spack/spack/cmd/arch.py b/lib/spack/spack/cmd/arch.py index 8f810bc9840..e3d15d45b11 100644 --- a/lib/spack/spack/cmd/arch.py +++ b/lib/spack/spack/cmd/arch.py @@ -5,7 +5,7 @@ import collections import warnings -import archspec.cpu +import _vendoring.archspec.cpu import llnl.util.tty.colify as colify import llnl.util.tty.color as color @@ -92,11 +92,11 @@ def display_target_group(header, target_group): def arch(parser, args): if args.generic_target: # TODO: add deprecation warning in 0.24 - print(archspec.cpu.host().generic) + print(_vendoring.archspec.cpu.host().generic) return if args.known_targets: - display_targets(archspec.cpu.TARGETS) + display_targets(_vendoring.archspec.cpu.TARGETS) return if args.frontend: diff --git a/lib/spack/spack/compilers/config.py b/lib/spack/spack/compilers/config.py index 476bf193433..3198ffcc93d 100644 --- a/lib/spack/spack/compilers/config.py +++ b/lib/spack/spack/compilers/config.py @@ -10,7 +10,7 @@ import warnings from typing import Any, Dict, List, Optional, Tuple -import archspec.cpu +import _vendoring.archspec.cpu import llnl.util.filesystem as fs import llnl.util.lang @@ -316,7 +316,7 @@ def from_external_yaml(config: Dict[str, Any]) -> Optional[spack.spec.Spec]: @staticmethod def _finalize_external_concretization(abstract_spec): if CompilerFactory._GENERIC_TARGET is None: - CompilerFactory._GENERIC_TARGET = archspec.cpu.host().family + CompilerFactory._GENERIC_TARGET = _vendoring.archspec.cpu.host().family if abstract_spec.architecture: abstract_spec.architecture.complete_with_defaults() diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index d55f5ec9c4c..4a2755209cf 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -25,7 +25,7 @@ import warnings from typing import List, Tuple -import archspec.cpu +import _vendoring.archspec.cpu import llnl.util.lang import llnl.util.tty as tty @@ -734,7 +734,7 @@ def _compatible_sys_types(): """ host_platform = spack.platforms.host() host_os = str(host_platform.default_operating_system()) - host_target = archspec.cpu.host() + host_target = _vendoring.archspec.cpu.host() compatible_targets = [host_target] + host_target.ancestors compatible_archs = [ @@ -794,7 +794,7 @@ def shell_set(var, value): # print environment module system if available. This can be expensive # on clusters, so skip it if not needed. if "modules" in info: - generic_arch = archspec.cpu.host().family + generic_arch = _vendoring.archspec.cpu.host().family module_spec = "environment-modules target={0}".format(generic_arch) specs = spack.store.STORE.db.query(module_spec) if specs: diff --git a/lib/spack/spack/platforms/_platform.py b/lib/spack/spack/platforms/_platform.py index a219198c3fb..a24b7f08404 100644 --- a/lib/spack/spack/platforms/_platform.py +++ b/lib/spack/spack/platforms/_platform.py @@ -4,7 +4,7 @@ import warnings from typing import Optional -import archspec.cpu +import _vendoring.archspec.cpu import llnl.util.lang @@ -38,15 +38,15 @@ def __init__(self, name): self.name = name self._init_targets() - def add_target(self, name: str, target: archspec.cpu.Microarchitecture) -> None: + def add_target(self, name: str, target: _vendoring.archspec.cpu.Microarchitecture) -> None: if name in Platform.reserved_targets: msg = f"{name} is a spack reserved alias and cannot be the name of a target" raise ValueError(msg) self.targets[name] = target def _init_targets(self): - self.default = archspec.cpu.host().name - for name, microarchitecture in archspec.cpu.TARGETS.items(): + self.default = _vendoring.archspec.cpu.host().name + for name, microarchitecture in _vendoring.archspec.cpu.TARGETS.items(): self.add_target(name, microarchitecture) def target(self, name): diff --git a/lib/spack/spack/platforms/test.py b/lib/spack/spack/platforms/test.py index e4246bf4461..e5193eebc4f 100644 --- a/lib/spack/spack/platforms/test.py +++ b/lib/spack/spack/platforms/test.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import platform -import archspec.cpu +import _vendoring.archspec.cpu import spack.operating_systems @@ -28,7 +28,7 @@ def __init__(self, name=None): def _init_targets(self): targets = ("aarch64", "m1") if platform.machine() == "arm64" else ("x86_64", "core2") for t in targets: - self.add_target(t, archspec.cpu.TARGETS[t]) + self.add_target(t, _vendoring.archspec.cpu.TARGETS[t]) @classmethod def detect(cls): diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index a9ff0d8d3e5..77d48533956 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -34,7 +34,7 @@ Union, ) -import archspec.cpu +import _vendoring.archspec.cpu import llnl.util.lang import llnl.util.tty as tty @@ -1617,7 +1617,7 @@ def target_ranges(self, spec, single_target_fn): target = spec.architecture.target # Check if the target is a concrete target - if str(target) in archspec.cpu.TARGETS: + if str(target) in _vendoring.archspec.cpu.TARGETS: return [single_target_fn(spec.name, target)] self.target_constraints.add(target) @@ -2753,7 +2753,7 @@ def _supported_targets(self, compiler_name, compiler_version, targets): compiler_name, compiler_version.dotted_numeric_string ) supported.append(target) - except archspec.cpu.UnsupportedMicroarchitecture: + except _vendoring.archspec.cpu.UnsupportedMicroarchitecture: continue except ValueError: continue @@ -2818,7 +2818,7 @@ def target_defaults(self, specs): if not spec.architecture or not spec.architecture.target: continue - target = archspec.cpu.TARGETS.get(spec.target.name) + target = _vendoring.archspec.cpu.TARGETS.get(spec.target.name) if not target: self.target_ranges(spec, None) continue @@ -2830,7 +2830,7 @@ def target_defaults(self, specs): candidate_targets.append(ancestor) platform = spack.platforms.host() - uarch = archspec.cpu.TARGETS.get(platform.default) + uarch = _vendoring.archspec.cpu.TARGETS.get(platform.default) best_targets = {uarch.family.name} for compiler in self.possible_compilers: supported = self._supported_targets(compiler.name, compiler.version, candidate_targets) @@ -2938,7 +2938,7 @@ def _all_targets_satisfiying(single_constraint): return [single_constraint] t_min, _, t_max = single_constraint.partition(":") - for test_target in archspec.cpu.TARGETS.values(): + for test_target in _vendoring.archspec.cpu.TARGETS.values(): # Check lower bound if t_min and not t_min <= test_target: continue diff --git a/lib/spack/spack/solver/input_analysis.py b/lib/spack/spack/solver/input_analysis.py index 4c340ce39ad..ce32dbda065 100644 --- a/lib/spack/spack/solver/input_analysis.py +++ b/lib/spack/spack/solver/input_analysis.py @@ -5,7 +5,7 @@ import collections from typing import Dict, List, NamedTuple, Set, Tuple, Union -import archspec.cpu +import _vendoring.archspec.cpu from llnl.util import lang, tty @@ -34,7 +34,7 @@ def unreachable(self, *, pkg_name: str, when_spec: spack.spec.Spec) -> bool: """ raise NotImplementedError - def candidate_targets(self) -> List[archspec.cpu.Microarchitecture]: + def candidate_targets(self) -> List[_vendoring.archspec.cpu.Microarchitecture]: """Returns a list of targets that are candidate for concretization""" raise NotImplementedError @@ -70,7 +70,7 @@ def __init__(self, *, configuration: spack.config.Configuration, repo: spack.rep self.configuration = configuration self.repo = repo self._platform_condition = spack.spec.Spec( - f"platform={spack.platforms.host()} target={archspec.cpu.host().family}:" + f"platform={spack.platforms.host()} target={_vendoring.archspec.cpu.host().family}:" ) try: @@ -110,10 +110,10 @@ def unreachable(self, *, pkg_name: str, when_spec: spack.spec.Spec) -> bool: """ return False - def candidate_targets(self) -> List[archspec.cpu.Microarchitecture]: + def candidate_targets(self) -> List[_vendoring.archspec.cpu.Microarchitecture]: """Returns a list of targets that are candidate for concretization""" platform = spack.platforms.host() - default_target = archspec.cpu.TARGETS[platform.default] + default_target = _vendoring.archspec.cpu.TARGETS[platform.default] # Construct the list of targets which are compatible with the host candidate_targets = [default_target] + default_target.ancestors @@ -125,7 +125,7 @@ def candidate_targets(self) -> List[archspec.cpu.Microarchitecture]: additional_targets_in_family = sorted( [ t - for t in archspec.cpu.TARGETS.values() + for t in _vendoring.archspec.cpu.TARGETS.values() if (t.family.name == default_target.family.name and t not in candidate_targets) ], key=lambda x: len(x.ancestors), diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 01fb7f18d5d..217cdd86bdd 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -74,10 +74,9 @@ overload, ) +import _vendoring.archspec.cpu from _vendoring.typing_extensions import Literal -import archspec.cpu - import llnl.path import llnl.string import llnl.util.filesystem as fs @@ -217,10 +216,12 @@ def ensure_modern_format_string(fmt: str) -> None: ) -def _make_microarchitecture(name: str) -> archspec.cpu.Microarchitecture: - if isinstance(name, archspec.cpu.Microarchitecture): +def _make_microarchitecture(name: str) -> _vendoring.archspec.cpu.Microarchitecture: + if isinstance(name, _vendoring.archspec.cpu.Microarchitecture): return name - return archspec.cpu.TARGETS.get(name, archspec.cpu.generic_microarchitecture(name)) + return _vendoring.archspec.cpu.TARGETS.get( + name, _vendoring.archspec.cpu.generic_microarchitecture(name) + ) @lang.lazy_lexicographic_ordering @@ -364,7 +365,7 @@ def target(self, value): # will assumed to be the host machine's platform. def target_or_none(t): - if isinstance(t, archspec.cpu.Microarchitecture): + if isinstance(t, _vendoring.archspec.cpu.Microarchitecture): return t if t and t != "None": return _make_microarchitecture(t) diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py index 3afe6bf6630..56227c3043e 100644 --- a/lib/spack/spack/test/architecture.py +++ b/lib/spack/spack/test/architecture.py @@ -3,10 +3,9 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import platform +import _vendoring.archspec.cpu import pytest -import archspec.cpu - import spack.concretize import spack.operating_systems import spack.platforms @@ -125,7 +124,8 @@ def test_satisfy_strict_constraint_when_not_concrete(architecture_tuple, constra ) @pytest.mark.usefixtures("mock_packages", "config") @pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="tests are for x86_64 uarch ranges" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="tests are for x86_64 uarch ranges", ) def test_concretize_target_ranges(root_target_range, dep_target_range, result, monkeypatch): spec = spack.concretize.concretize_one( diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py index afc3efdc159..1fb72027b59 100644 --- a/lib/spack/spack/test/build_environment.py +++ b/lib/spack/spack/test/build_environment.py @@ -8,10 +8,9 @@ import sys from typing import Dict, Optional, Tuple +import _vendoring.archspec.cpu import pytest -import archspec.cpu - from llnl.path import Path, convert_to_platform_path from llnl.util.filesystem import HeaderList, LibraryList @@ -727,14 +726,15 @@ def test_rpath_with_duplicate_link_deps(): @pytest.mark.filterwarnings("ignore:microarchitecture specific") @pytest.mark.not_on_windows("Windows doesn't support the compiler wrapper") def test_optimization_flags(compiler_spec, target_name, expected_flags, compiler_factory): - target = archspec.cpu.TARGETS[target_name] + target = _vendoring.archspec.cpu.TARGETS[target_name] compiler = spack.spec.parse_with_version_concrete(compiler_spec) opt_flags = spack.build_environment.optimization_flags(compiler, target) assert opt_flags == expected_flags @pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="tests check specific x86_64 uarch flags" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="tests check specific x86_64 uarch flags", ) @pytest.mark.not_on_windows("Windows doesn't support the compiler wrapper") def test_optimization_flags_are_using_node_target(default_mock_concretization, monkeypatch): diff --git a/lib/spack/spack/test/build_systems.py b/lib/spack/spack/test/build_systems.py index 5625d614ea7..2de3740bad3 100644 --- a/lib/spack/spack/test/build_systems.py +++ b/lib/spack/spack/test/build_systems.py @@ -5,11 +5,10 @@ import glob import os +import _vendoring.archspec.cpu import py.path import pytest -import archspec.cpu - import llnl.util.filesystem as fs import spack @@ -217,7 +216,8 @@ def test_autotools_gnuconfig_replacement_disabled(self, mutable_database): @pytest.mark.disable_clean_stage_check @pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="test data is specific for x86_64" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="test data is specific for x86_64", ) def test_autotools_gnuconfig_replacement_no_gnuconfig(self, mutable_database, monkeypatch): """ diff --git a/lib/spack/spack/test/concretization/compiler_runtimes.py b/lib/spack/spack/test/concretization/compiler_runtimes.py index a1352948e14..4248fc09f49 100644 --- a/lib/spack/spack/test/concretization/compiler_runtimes.py +++ b/lib/spack/spack/test/concretization/compiler_runtimes.py @@ -4,10 +4,9 @@ import os +import _vendoring.archspec.cpu import pytest -import archspec.cpu - import spack.concretize import spack.config import spack.paths @@ -86,7 +85,8 @@ def test_external_nodes_do_not_have_runtimes(runtime_repo, mutable_config, tmp_p {"pkg-a": "gcc-runtime@9.4.0", "pkg-b": "gcc-runtime@9.4.0"}, 1, marks=pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="test data is x86_64 specific" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="test data is x86_64 specific", ), ), pytest.param( @@ -98,7 +98,8 @@ def test_external_nodes_do_not_have_runtimes(runtime_repo, mutable_config, tmp_p }, 2, marks=pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="test data is x86_64 specific" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="test data is x86_64 specific", ), ), ], diff --git a/lib/spack/spack/test/concretization/core.py b/lib/spack/spack/test/concretization/core.py index 8c7923eb3b4..3fa4f244a2b 100644 --- a/lib/spack/spack/test/concretization/core.py +++ b/lib/spack/spack/test/concretization/core.py @@ -6,11 +6,10 @@ import platform import sys +import _vendoring.archspec.cpu import _vendoring.jinja2 import pytest -import archspec.cpu - import llnl.util.lang import spack.binary_distribution @@ -146,12 +145,12 @@ def current_host(request, monkeypatch): monkeypatch.setattr(spack.platforms.Test, "default", cpu) if not is_preference: - target = archspec.cpu.TARGETS[cpu] - monkeypatch.setattr(archspec.cpu, "host", lambda: target) + target = _vendoring.archspec.cpu.TARGETS[cpu] + monkeypatch.setattr(_vendoring.archspec.cpu, "host", lambda: target) yield target else: - target = archspec.cpu.TARGETS["sapphirerapids"] - monkeypatch.setattr(archspec.cpu, "host", lambda: target) + target = _vendoring.archspec.cpu.TARGETS["sapphirerapids"] + monkeypatch.setattr(_vendoring.archspec.cpu, "host", lambda: target) with spack.config.override("packages:all", {"target": [cpu]}): yield target @@ -383,7 +382,7 @@ def test_different_compilers_get_different_flags( "gcc": {"externals": [gcc11_with_flags]}, }, ) - t = archspec.cpu.host().family + t = _vendoring.archspec.cpu.host().family client = spack.concretize.concretize_one( Spec( f"cmake-client platform=test os=redhat6 target={t} %gcc@11.1.0" @@ -976,7 +975,7 @@ def test_noversion_pkg(self, spec): def test_adjusting_default_target_based_on_compiler( self, spec, compiler_spec, best_achievable, current_host, compiler_factory, mutable_config ): - best_achievable = archspec.cpu.TARGETS[best_achievable] + best_achievable = _vendoring.archspec.cpu.TARGETS[best_achievable] expected = best_achievable if best_achievable < current_host else current_host mutable_config.set( "packages", {"gcc": {"externals": [compiler_factory(spec=f"{compiler_spec}")]}} @@ -1645,7 +1644,7 @@ def test_target_granularity(self): # The test architecture uses core2 as the default target. Check that when # we configure Spack for "generic" granularity we concretize for x86_64 default_target = spack.platforms.test.Test.default - generic_target = archspec.cpu.TARGETS[default_target].generic.name + generic_target = _vendoring.archspec.cpu.TARGETS[default_target].generic.name s = Spec("python") assert spack.concretize.concretize_one(s).satisfies("target=%s" % default_target) with spack.config.override("concretizer:targets", {"granularity": "generic"}): @@ -2011,7 +2010,7 @@ def test_installed_specs_disregard_conflicts(self, mutable_database, monkeypatch def test_require_targets_are_allowed(self, mutable_config, mutable_database): """Test that users can set target constraints under the require attribute.""" # Configuration to be added to packages.yaml - required_target = archspec.cpu.TARGETS[spack.platforms.test.Test.default].family + required_target = _vendoring.archspec.cpu.TARGETS[spack.platforms.test.Test.default].family external_conf = {"all": {"require": f"target={required_target}"}} mutable_config.set("packages", external_conf) diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 88b4b2b86cd..d5d1118c341 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -20,13 +20,12 @@ import tempfile import xml.etree.ElementTree +import _vendoring.archspec.cpu +import _vendoring.archspec.cpu.microarchitecture +import _vendoring.archspec.cpu.schema import py import pytest -import archspec.cpu -import archspec.cpu.microarchitecture -import archspec.cpu.schema - import llnl.util.lang import llnl.util.lock import llnl.util.tty as tty @@ -372,12 +371,12 @@ def clean_test_environment(): def _host(): """Mock archspec host so there is no inconsistency on the Windows platform This function cannot be local as it needs to be pickleable""" - return archspec.cpu.Microarchitecture("x86_64", [], "generic", [], {}, 0) + return _vendoring.archspec.cpu.Microarchitecture("x86_64", [], "generic", [], {}, 0) @pytest.fixture(scope="function") def archspec_host_is_spack_test_host(monkeypatch): - monkeypatch.setattr(archspec.cpu, "host", _host) + monkeypatch.setattr(_vendoring.archspec.cpu, "host", _host) # Hooks to add command line options or set other custom behaviors. @@ -728,14 +727,14 @@ def mock_uarch_json(tmpdir_factory): @pytest.fixture(scope="session") def mock_uarch_configuration(mock_uarch_json): - """Create mock dictionaries for the archspec.cpu.""" + """Create mock dictionaries for the _vendoring.archspec.cpu.""" def load_json(): with open(mock_uarch_json, encoding="utf-8") as f: return json.load(f) targets_json = load_json() - targets = archspec.cpu.microarchitecture._known_microarchitectures() + targets = _vendoring.archspec.cpu.microarchitecture._known_microarchitectures() yield targets_json, targets @@ -744,8 +743,8 @@ def load_json(): def mock_targets(mock_uarch_configuration, monkeypatch): """Use this fixture to enable mock uarch targets for testing.""" targets_json, targets = mock_uarch_configuration - monkeypatch.setattr(archspec.cpu.schema, "TARGETS_JSON", targets_json) - monkeypatch.setattr(archspec.cpu.microarchitecture, "TARGETS", targets) + monkeypatch.setattr(_vendoring.archspec.cpu.schema, "TARGETS_JSON", targets_json) + monkeypatch.setattr(_vendoring.archspec.cpu.microarchitecture, "TARGETS", targets) @pytest.fixture(scope="session") @@ -773,7 +772,7 @@ def configuration_dir(tmpdir_factory, linux_os): config_template = test_config / "config.yaml" config.write(config_template.read_text().format(install_tree_root, locks)) - target = str(archspec.cpu.host().family) + target = str(_vendoring.archspec.cpu.host().family) compilers = tmpdir.join("site", "packages.yaml") compilers_template = test_config / "packages.yaml" compilers.write(compilers_template.read_text().format(linux_os=linux_os, target=target)) @@ -2117,7 +2116,7 @@ def _factory(*, spec): @pytest.fixture() def host_architecture_str(): """Returns the broad architecture family (x86_64, aarch64, etc.)""" - return str(archspec.cpu.host().family) + return str(_vendoring.archspec.cpu.host().family) def _true(x): diff --git a/lib/spack/spack/test/cray_manifest.py b/lib/spack/spack/test/cray_manifest.py index c19858c7539..c37954784e4 100644 --- a/lib/spack/spack/test/cray_manifest.py +++ b/lib/spack/spack/test/cray_manifest.py @@ -11,10 +11,9 @@ import json import os +import _vendoring.archspec.cpu import pytest -import archspec.cpu - import spack import spack.cmd import spack.cmd.external @@ -104,7 +103,7 @@ def spec_json(self): @pytest.fixture def _common_arch(test_platform): - generic = archspec.cpu.TARGETS[test_platform.default].family + generic = _vendoring.archspec.cpu.TARGETS[test_platform.default].family return JsonArchEntry(platform=test_platform.name, os="redhat6", target=generic.name) diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py index f066a31f0a5..0c5fb175bd8 100644 --- a/lib/spack/spack/test/modules/lmod.py +++ b/lib/spack/spack/test/modules/lmod.py @@ -4,10 +4,9 @@ import os +import _vendoring.archspec.cpu import pytest -import archspec.cpu - import spack.concretize import spack.config import spack.environment as ev @@ -221,7 +220,8 @@ def test_setenv_raw_value(self, modulefile_content, module_configuration): assert len([x for x in content if 'setenv("FOO", "{{name}}, {name}, {{}}, {}")' in x]) == 1 @pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="test data is specific for x86_64" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="test data is specific for x86_64", ) def test_help_message(self, modulefile_content, module_configuration): """Tests the generation of module help message.""" diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index 61ef2dd641b..b532cb9f9a7 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -4,10 +4,9 @@ import os +import _vendoring.archspec.cpu import pytest -import archspec.cpu - import spack.concretize import spack.modules.common import spack.modules.tcl @@ -186,7 +185,8 @@ def test_setenv_raw_value(self, modulefile_content, module_configuration): assert len([x for x in content if "setenv FOO {{{name}}, {name}, {{}}, {}}" in x]) == 1 @pytest.mark.skipif( - str(archspec.cpu.host().family) != "x86_64", reason="test data is specific for x86_64" + str(_vendoring.archspec.cpu.host().family) != "x86_64", + reason="test data is specific for x86_64", ) def test_help_message(self, modulefile_content, module_configuration): """Tests the generation of module help message.""" diff --git a/pyproject.toml b/pyproject.toml index 321f4a02ddc..e73ae2cd207 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,6 @@ section-order = [ "future", "standard-library", "third-party", - "archspec", "llnl", "spack", "first-party", @@ -84,7 +83,6 @@ section-order = [ [tool.ruff.lint.isort.sections] spack = ["spack"] -archspec = ["archspec"] llnl = ["llnl"] [tool.ruff.lint.per-file-ignores] @@ -104,13 +102,11 @@ sections = [ "FUTURE", "STDLIB", "THIRDPARTY", - "ARCHSPEC", "LLNL", "FIRSTPARTY", "LOCALFOLDER", ] known_first_party = "spack" -known_archspec = "archspec" known_llnl = "llnl" known_third_party = ["ruamel", "six"] src_paths = "lib" @@ -264,6 +260,9 @@ substitute = [ { match = "from attr", replace = "from _vendoring.attr" }, { match = "import jsonschema", replace = "import _vendoring.jsonschema" }, { match = "from jsonschema", replace = "from _vendoring.jsonschema" }, + { match = "archspec.cpu", replace = "_vendoring.archspec.cpu" }, + { match = "archspec.__version__", replace = "_vendoring.archspec.__version__" }, + { match = "import archspec", replace = "import _vendoring.archspec" }, ] drop = [ # contains unnecessary scripts @@ -285,11 +284,21 @@ drop = [ "pvectorc.*.so", # Trim jsonschema tests "jsonschema/tests", + "archspec/json/tests", + "archspec/vendor/cpuid/.gitignore", + "pyrsistent/__init__.pyi", ] [tool.vendoring.typing-stubs] -six = ["six.__init__", "six.moves.__init__", "six.moves.configparser"] +_pyrsistent_version = [] +altgraph = [] +archspec = [] distro = [] +jsonschema = [] +macholib = [] +pyrsistent = [] +ruamel = [] +six = [] [tool.vendoring.license.directories] setuptools = "pkg_resources" diff --git a/var/spack/repos/spack_repo/builtin/build_systems/python.py b/var/spack/repos/spack_repo/builtin/build_systems/python.py index 79bfa6e59c9..8af036f7866 100644 --- a/var/spack/repos/spack_repo/builtin/build_systems/python.py +++ b/var/spack/repos/spack_repo/builtin/build_systems/python.py @@ -10,7 +10,7 @@ import stat from typing import Dict, Iterable, List, Mapping, Optional, Tuple -import archspec +import _vendoring.archspec.cpu import llnl.util.filesystem as fs from llnl.util.lang import ClassProperty, classproperty, match_predicate @@ -286,7 +286,7 @@ def _update_external_dependencies(self, extendee_spec: Optional[Spec] = None) -> if not python.architecture.os: python.architecture.os = platform.default_operating_system() if not python.architecture.target: - python.architecture.target = archspec.cpu.host().family.name + python.architecture.target = _vendoring.archspec.cpu.host().family.name python.external_path = self.spec.external_path python._mark_concrete() diff --git a/var/spack/repos/spack_repo/builtin/packages/compiler_wrapper/package.py b/var/spack/repos/spack_repo/builtin/packages/compiler_wrapper/package.py index edcb6a04d3e..56ab9671503 100644 --- a/var/spack/repos/spack_repo/builtin/packages/compiler_wrapper/package.py +++ b/var/spack/repos/spack_repo/builtin/packages/compiler_wrapper/package.py @@ -6,10 +6,9 @@ import sys from typing import List +import _vendoring.archspec.cpu from spack_repo.builtin.build_systems.generic import Package -import archspec.cpu - from llnl.util import lang import spack.compilers.libraries @@ -183,12 +182,12 @@ def setup_dependent_build_environment( env.set(f"SPACK_{wrapper_var_name}_RPATH_ARG", compiler_pkg.rpath_arg) uarch = dependent_spec.architecture.target - version_number, _ = archspec.cpu.version_components( + version_number, _ = _vendoring.archspec.cpu.version_components( compiler_pkg.spec.version.dotted_numeric_string ) try: isa_arg = uarch.optimization_flags(compiler_pkg.archspec_name(), version_number) - except (ValueError, archspec.cpu.UnsupportedMicroarchitecture): + except (ValueError, _vendoring.archspec.cpu.UnsupportedMicroarchitecture): isa_arg = "" if isa_arg: diff --git a/var/spack/test_repos/spack_repo/builtin_mock/build_systems/python.py b/var/spack/test_repos/spack_repo/builtin_mock/build_systems/python.py index a3bde3be19a..9095596b208 100644 --- a/var/spack/test_repos/spack_repo/builtin_mock/build_systems/python.py +++ b/var/spack/test_repos/spack_repo/builtin_mock/build_systems/python.py @@ -10,7 +10,7 @@ import stat from typing import Dict, Iterable, List, Mapping, Optional, Tuple -import archspec +import _vendoring.archspec import llnl.util.filesystem as fs import llnl.util.tty as tty @@ -276,7 +276,7 @@ def _update_external_dependencies(self, extendee_spec=None): if not python.architecture.os: python.architecture.os = platform.default_operating_system() if not python.architecture.target: - python.architecture.target = archspec.cpu.host().family.name + python.architecture.target = _vendoring.archspec.cpu.host().family.name python.external_path = self.spec.external_path python._mark_concrete() diff --git a/var/spack/test_repos/spack_repo/builtin_mock/packages/compiler_wrapper/package.py b/var/spack/test_repos/spack_repo/builtin_mock/packages/compiler_wrapper/package.py index 19b49f30c16..ed047da702b 100644 --- a/var/spack/test_repos/spack_repo/builtin_mock/packages/compiler_wrapper/package.py +++ b/var/spack/test_repos/spack_repo/builtin_mock/packages/compiler_wrapper/package.py @@ -6,10 +6,9 @@ import sys from typing import List +import _vendoring.archspec.cpu from spack_repo.builtin_mock.build_systems.generic import Package -import archspec.cpu - from llnl.util import lang import spack.compilers.libraries @@ -184,12 +183,12 @@ def setup_dependent_build_environment( env.set(f"SPACK_{wrapper_var_name}_RPATH_ARG", compiler_pkg.rpath_arg) uarch = dependent_spec.architecture.target - version_number, _ = archspec.cpu.version_components( + version_number, _ = _vendoring.archspec.cpu.version_components( compiler_pkg.spec.version.dotted_numeric_string ) try: isa_arg = uarch.optimization_flags(compiler_pkg.archspec_name(), version_number) - except (ValueError, archspec.cpu.UnsupportedMicroarchitecture): + except ValueError: isa_arg = "" if isa_arg: