diff --git a/lib/spack/spack/bootstrap/clingo.py b/lib/spack/spack/bootstrap/clingo.py index c55addf12f2..17a86baf39d 100644 --- a/lib/spack/spack/bootstrap/clingo.py +++ b/lib/spack/spack/bootstrap/clingo.py @@ -27,9 +27,9 @@ class ClingoBootstrapConcretizer: def __init__(self, configuration): self.host_platform = spack.platforms.host() - self.host_os = self.host_platform.operating_system("frontend") + self.host_os = self.host_platform.default_operating_system() self.host_target = archspec.cpu.host().family - self.host_architecture = spack.spec.ArchSpec.frontend_arch() + self.host_architecture = spack.spec.ArchSpec.default_arch() self.host_architecture.target = str(self.host_target) self.host_compiler = self._valid_compiler_or_raise() self.host_python = self.python_external_spec() diff --git a/lib/spack/spack/bootstrap/config.py b/lib/spack/spack/bootstrap/config.py index a81be057563..4c0ff117664 100644 --- a/lib/spack/spack/bootstrap/config.py +++ b/lib/spack/spack/bootstrap/config.py @@ -141,7 +141,7 @@ def _bootstrap_config_scopes() -> Sequence["spack.config.ConfigScope"]: def _add_compilers_if_missing() -> None: - arch = spack.spec.ArchSpec.frontend_arch() + arch = spack.spec.ArchSpec.default_arch() if not spack.compilers.compilers_for_arch(arch): spack.compilers.find_compilers() diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py index e09408fcd7f..557fca15d4b 100644 --- a/lib/spack/spack/build_systems/python.py +++ b/lib/spack/spack/build_systems/python.py @@ -264,16 +264,17 @@ def update_external_dependencies(self, extendee_spec=None): # Ensure architecture information is present if not python.architecture: host_platform = spack.platforms.host() - host_os = host_platform.operating_system("default_os") - host_target = host_platform.target("default_target") + host_os = host_platform.default_operating_system() + host_target = host_platform.default_target() python.architecture = spack.spec.ArchSpec( (str(host_platform), str(host_os), str(host_target)) ) else: if not python.architecture.platform: python.architecture.platform = spack.platforms.host() + platform = spack.platforms.by_name(python.architecture.platform) if not python.architecture.os: - python.architecture.os = "default_os" + python.architecture.os = platform.default_operating_system() if not python.architecture.target: python.architecture.target = archspec.cpu.host().family.name diff --git a/lib/spack/spack/cmd/arch.py b/lib/spack/spack/cmd/arch.py index 683fd01450d..8f810bc9840 100644 --- a/lib/spack/spack/cmd/arch.py +++ b/lib/spack/spack/cmd/arch.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import collections +import warnings import archspec.cpu @@ -51,10 +52,10 @@ def setup_parser(subparser): "-t", "--target", action="store_true", default=False, help="print only the target" ) parts2.add_argument( - "-f", "--frontend", action="store_true", default=False, help="print frontend" + "-f", "--frontend", action="store_true", default=False, help="print frontend (DEPRECATED)" ) parts2.add_argument( - "-b", "--backend", action="store_true", default=False, help="print backend" + "-b", "--backend", action="store_true", default=False, help="print backend (DEPRECATED)" ) @@ -98,15 +99,14 @@ def arch(parser, args): display_targets(archspec.cpu.TARGETS) return - os_args, target_args = "default_os", "default_target" if args.frontend: - os_args, target_args = "frontend", "frontend" + warnings.warn("the argument --frontend is deprecated, and will be removed in Spack v1.0") elif args.backend: - os_args, target_args = "backend", "backend" + warnings.warn("the argument --backend is deprecated, and will be removed in Spack v1.0") host_platform = spack.platforms.host() - host_os = host_platform.operating_system(os_args) - host_target = host_platform.target(target_args) + host_os = host_platform.default_operating_system() + host_target = host_platform.default_target() if args.family: host_target = host_target.family elif args.generic: diff --git a/lib/spack/spack/cmd/debug.py b/lib/spack/spack/cmd/debug.py index e03479955a4..f9ef00a1a7f 100644 --- a/lib/spack/spack/cmd/debug.py +++ b/lib/spack/spack/cmd/debug.py @@ -86,8 +86,8 @@ def create_db_tarball(args): def report(args): host_platform = spack.platforms.host() - host_os = host_platform.operating_system("frontend") - host_target = host_platform.target("frontend") + host_os = host_platform.default_operating_system() + host_target = host_platform.default_target() architecture = spack.spec.ArchSpec((str(host_platform), str(host_os), str(host_target))) print("* **Spack:**", spack.get_version()) print("* **Python:**", platform.python_version()) diff --git a/lib/spack/spack/cmd/help.py b/lib/spack/spack/cmd/help.py index 3b754cd6ef2..ace7ef224d0 100644 --- a/lib/spack/spack/cmd/help.py +++ b/lib/spack/spack/cmd/help.py @@ -54,10 +54,6 @@ @m{target=target} specific processor @m{arch=platform-os-target} shortcut for all three above - cross-compiling: - @m{os=backend} or @m{os=be} build for compute node (backend) - @m{os=frontend} or @m{os=fe} build for login node (frontend) - dependencies: ^dependency [constraints] specify constraints on dependencies ^@K{/hash} build with a specific installed diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index af40945c373..4ca2aa3bb08 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -801,17 +801,17 @@ def _extract_compiler_paths(spec: "spack.spec.Spec") -> Optional[Dict[str, str]] def _extract_os_and_target(spec: "spack.spec.Spec"): if not spec.architecture: host_platform = spack.platforms.host() - operating_system = host_platform.operating_system("default_os") - target = host_platform.target("default_target") + operating_system = host_platform.default_operating_system() + target = host_platform.default_target() else: target = spec.architecture.target if not target: - target = spack.platforms.host().target("default_target") + target = spack.platforms.host().default_target() operating_system = spec.os if not operating_system: host_platform = spack.platforms.host() - operating_system = host_platform.operating_system("default_os") + operating_system = host_platform.default_operating_system() return operating_system, target diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index 33fb308adb4..2c353a3e59c 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -728,7 +728,7 @@ def _compatible_sys_types(): with the current host. """ host_platform = spack.platforms.host() - host_os = str(host_platform.operating_system("default_os")) + host_os = str(host_platform.default_operating_system()) host_target = archspec.cpu.host() compatible_targets = [host_target] + host_target.ancestors diff --git a/lib/spack/spack/platforms/__init__.py b/lib/spack/spack/platforms/__init__.py index 04a44db5163..f38fa604971 100644 --- a/lib/spack/spack/platforms/__init__.py +++ b/lib/spack/spack/platforms/__init__.py @@ -52,8 +52,7 @@ def use_platform(new_platform): import spack.config - msg = '"{0}" must be an instance of Platform' - assert isinstance(new_platform, Platform), msg.format(new_platform) + assert isinstance(new_platform, Platform), f'"{new_platform}" must be an instance of Platform' original_host_fn = host diff --git a/lib/spack/spack/platforms/_platform.py b/lib/spack/spack/platforms/_platform.py index fd91bac91d2..a219198c3fb 100644 --- a/lib/spack/spack/platforms/_platform.py +++ b/lib/spack/spack/platforms/_platform.py @@ -1,42 +1,22 @@ # Copyright Spack Project Developers. See COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import warnings from typing import Optional import archspec.cpu import llnl.util.lang -import spack.error - - -class NoPlatformError(spack.error.SpackError): - def __init__(self): - msg = "Could not determine a platform for this machine" - super().__init__(msg) - @llnl.util.lang.lazy_lexicographic_ordering class Platform: """Platform is an abstract class extended by subclasses. - To add a new type of platform (such as cray_xe), create a subclass and set all the - class attributes such as priority, front_target, back_target, front_os, back_os. - Platform also contain a priority class attribute. A lower number signifies higher priority. These numbers are arbitrarily set and can be changed though often there isn't much need unless a new platform is added and the user wants that to be detected first. - - Targets are created inside the platform subclasses. Most architecture (like linux, - and darwin) will have only one target family (x86_64) but in the case of Cray - machines, there is both a frontend and backend processor. The user can specify - which targets are present on front-end and back-end architecture. - - Depending on the platform, operating systems are either autodetected or are - set. The user can set the frontend and backend operating setting by the class - attributes front_os and back_os. The operating system will be responsible for - compiler detection. """ # Subclass sets number. Controls detection order @@ -45,82 +25,72 @@ class attributes such as priority, front_target, back_target, front_os, back_os. #: binary formats used on this platform; used by relocation logic binary_formats = ["elf"] - front_end: Optional[str] = None - back_end: Optional[str] = None - default: Optional[str] = None # The default back end target. - - front_os: Optional[str] = None - back_os: Optional[str] = None - default_os: Optional[str] = None + default: str + default_os: str reserved_targets = ["default_target", "frontend", "fe", "backend", "be"] reserved_oss = ["default_os", "frontend", "fe", "backend", "be"] + deprecated_names = ["frontend", "fe", "backend", "be"] def __init__(self, name): self.targets = {} self.operating_sys = {} self.name = name + self._init_targets() def add_target(self, name: str, target: archspec.cpu.Microarchitecture) -> None: - """Used by the platform specific subclass to list available targets. - Raises an error if the platform specifies a name - that is reserved by spack as an alias. - """ if name in Platform.reserved_targets: - msg = "{0} is a spack reserved alias and cannot be the name of a target" - raise ValueError(msg.format(name)) + msg = f"{name} is a spack reserved alias and cannot be the name of a target" + raise ValueError(msg) self.targets[name] = target - def _add_archspec_targets(self): + def _init_targets(self): + self.default = archspec.cpu.host().name for name, microarchitecture in archspec.cpu.TARGETS.items(): self.add_target(name, microarchitecture) def target(self, name): - """This is a getter method for the target dictionary - that handles defaulting based on the values provided by default, - front-end, and back-end. This can be overwritten - by a subclass for which we want to provide further aliasing options. - """ - # TODO: Check if we can avoid using strings here name = str(name) - if name == "default_target": + if name in Platform.deprecated_names: + warnings.warn(f"target={name} is deprecated, use target={self.default} instead") + + if name in Platform.reserved_targets: name = self.default - elif name == "frontend" or name == "fe": - name = self.front_end - elif name == "backend" or name == "be": - name = self.back_end return self.targets.get(name, None) def add_operating_system(self, name, os_class): - """Add the operating_system class object into the - platform.operating_sys dictionary. - """ - if name in Platform.reserved_oss: - msg = "{0} is a spack reserved alias and cannot be the name of an OS" - raise ValueError(msg.format(name)) + if name in Platform.reserved_oss + Platform.deprecated_names: + msg = f"{name} is a spack reserved alias and cannot be the name of an OS" + raise ValueError(msg) self.operating_sys[name] = os_class + def default_target(self): + return self.target(self.default) + + def default_operating_system(self): + return self.operating_system(self.default_os) + def operating_system(self, name): - if name == "default_os": + if name in Platform.deprecated_names: + warnings.warn(f"os={name} is deprecated, use os={self.default_os} instead") + + if name in Platform.reserved_oss: name = self.default_os - if name == "frontend" or name == "fe": - name = self.front_os - if name == "backend" or name == "be": - name = self.back_os return self.operating_sys.get(name, None) def setup_platform_environment(self, pkg, env): - """Subclass can override this method if it requires any - platform-specific build environment modifications. + """Platform-specific build environment modifications. + + This method is meant toi be overridden by subclasses, when needed. """ pass @classmethod def detect(cls): - """Return True if the the host platform is detected to be the current - Platform class, False otherwise. + """Returns True if the host platform is detected to be the current Platform class, + False otherwise. Derived classes are responsible for implementing this method. """ @@ -135,11 +105,7 @@ def __str__(self): def _cmp_iter(self): yield self.name yield self.default - yield self.front_end - yield self.back_end yield self.default_os - yield self.front_os - yield self.back_os def targets(): for t in sorted(self.targets.values()): diff --git a/lib/spack/spack/platforms/darwin.py b/lib/spack/spack/platforms/darwin.py index a1259445562..f6264e291a9 100644 --- a/lib/spack/spack/platforms/darwin.py +++ b/lib/spack/spack/platforms/darwin.py @@ -4,8 +4,6 @@ import platform as py_platform -import archspec.cpu - from spack.operating_systems.mac_os import MacOs from spack.version import Version @@ -19,18 +17,8 @@ class Darwin(Platform): def __init__(self): super().__init__("darwin") - self._add_archspec_targets() - - self.default = archspec.cpu.host().name - self.front_end = self.default - self.back_end = self.default - mac_os = MacOs() - self.default_os = str(mac_os) - self.front_os = str(mac_os) - self.back_os = str(mac_os) - self.add_operating_system(str(mac_os), mac_os) @classmethod diff --git a/lib/spack/spack/platforms/freebsd.py b/lib/spack/spack/platforms/freebsd.py index 8ef84e8a12e..c2b2d0d96cd 100644 --- a/lib/spack/spack/platforms/freebsd.py +++ b/lib/spack/spack/platforms/freebsd.py @@ -3,8 +3,6 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import platform -import archspec.cpu - from spack.operating_systems.freebsd import FreeBSDOs from ._platform import Platform @@ -15,18 +13,8 @@ class FreeBSD(Platform): def __init__(self): super().__init__("freebsd") - - self._add_archspec_targets() - - # Get specific default - self.default = archspec.cpu.host().name - self.front_end = self.default - self.back_end = self.default - os = FreeBSDOs() self.default_os = str(os) - self.front_os = self.default_os - self.back_os = self.default_os self.add_operating_system(str(os), os) @classmethod diff --git a/lib/spack/spack/platforms/linux.py b/lib/spack/spack/platforms/linux.py index dda925d0933..8a30d5e21a7 100644 --- a/lib/spack/spack/platforms/linux.py +++ b/lib/spack/spack/platforms/linux.py @@ -3,8 +3,6 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import platform -import archspec.cpu - from spack.operating_systems.linux_distro import LinuxDistro from ._platform import Platform @@ -15,18 +13,8 @@ class Linux(Platform): def __init__(self): super().__init__("linux") - - self._add_archspec_targets() - - # Get specific default - self.default = archspec.cpu.host().name - self.front_end = self.default - self.back_end = self.default - linux_dist = LinuxDistro() self.default_os = str(linux_dist) - self.front_os = self.default_os - self.back_os = self.default_os self.add_operating_system(str(linux_dist), linux_dist) @classmethod diff --git a/lib/spack/spack/platforms/test.py b/lib/spack/spack/platforms/test.py index e6aa8508958..e4246bf4461 100644 --- a/lib/spack/spack/platforms/test.py +++ b/lib/spack/spack/platforms/test.py @@ -16,31 +16,19 @@ class Test(Platform): if platform.system().lower() == "darwin": binary_formats = ["macho"] - if platform.machine() == "arm64": - front_end = "aarch64" - back_end = "m1" - default = "m1" - else: - front_end = "x86_64" - back_end = "core2" - default = "core2" - - front_os = "redhat6" - back_os = "debian6" default_os = "debian6" + default = "m1" if platform.machine() == "arm64" else "core2" def __init__(self, name=None): name = name or "test" super().__init__(name) - self.add_target(self.default, archspec.cpu.TARGETS[self.default]) - self.add_target(self.front_end, archspec.cpu.TARGETS[self.front_end]) + self.add_operating_system("debian6", spack.operating_systems.OperatingSystem("debian", 6)) + self.add_operating_system("redhat6", spack.operating_systems.OperatingSystem("redhat", 6)) - self.add_operating_system( - self.default_os, spack.operating_systems.OperatingSystem("debian", 6) - ) - self.add_operating_system( - self.front_os, spack.operating_systems.OperatingSystem("redhat", 6) - ) + 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]) @classmethod def detect(cls): diff --git a/lib/spack/spack/platforms/windows.py b/lib/spack/spack/platforms/windows.py index edfb68b074b..f50d3fe4dd0 100755 --- a/lib/spack/spack/platforms/windows.py +++ b/lib/spack/spack/platforms/windows.py @@ -4,8 +4,6 @@ import platform -import archspec.cpu - from spack.operating_systems.windows_os import WindowsOs from ._platform import Platform @@ -16,18 +14,8 @@ class Windows(Platform): def __init__(self): super().__init__("windows") - self._add_archspec_targets() - - self.default = archspec.cpu.host().name - self.front_end = self.default - self.back_end = self.default - windows_os = WindowsOs() - self.default_os = str(windows_os) - self.front_os = str(windows_os) - self.back_os = str(windows_os) - self.add_operating_system(str(windows_os), windows_os) @classmethod diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index edc2696ec50..4368aa5dd09 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -106,7 +106,7 @@ def __init__(self, configuration: CDashConfiguration): self.site = configuration.site or socket.gethostname() self.osname = platform.system() self.osrelease = platform.release() - self.target = spack.platforms.host().target("default_target") + self.target = spack.platforms.host().default_target() self.starttime = int(time.time()) self.endtime = self.starttime self.buildstamp = ( diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 293c9691067..78202b65e98 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -237,23 +237,14 @@ def _make_microarchitecture(name: str) -> archspec.cpu.Microarchitecture: class ArchSpec: """Aggregate the target platform, the operating system and the target microarchitecture.""" - @staticmethod - def _return_arch(os_tag, target_tag): - platform = spack.platforms.host() - default_os = platform.operating_system(os_tag) - default_target = platform.target(target_tag) - arch_tuple = str(platform), str(default_os), str(default_target) - return ArchSpec(arch_tuple) - @staticmethod def default_arch(): """Return the default architecture""" - return ArchSpec._return_arch("default_os", "default_target") - - @staticmethod - def frontend_arch(): - """Return the frontend architecture""" - return ArchSpec._return_arch("frontend", "frontend") + platform = spack.platforms.host() + default_os = platform.default_operating_system() + default_target = platform.default_target() + arch_tuple = str(platform), str(default_os), str(default_target) + return ArchSpec(arch_tuple) __slots__ = "_platform", "_os", "_target" @@ -5191,12 +5182,10 @@ def get_host_environment_metadata() -> Dict[str, str]: def get_host_environment() -> Dict[str, Any]: - """Return a dictionary (lookup) with host information (not including the - os.environ). - """ + """Returns a dictionary with host information (not including the os.environ).""" host_platform = spack.platforms.host() - host_target = host_platform.target("default_target") - host_os = host_platform.operating_system("default_os") + host_target = host_platform.default_target() + host_os = host_platform.default_operating_system() arch_fmt = "platform={0} os={1} target={2}" arch_spec = Spec(arch_fmt.format(host_platform, host_os, host_target)) return { diff --git a/lib/spack/spack/test/architecture.py b/lib/spack/spack/test/architecture.py index 04e89fc80b5..8562be992f1 100644 --- a/lib/spack/spack/test/architecture.py +++ b/lib/spack/spack/test/architecture.py @@ -60,8 +60,7 @@ def test_user_input_combination(config, target_str, os_str): """Test for all the valid user input combinations that both the target and the operating system match. """ - spec_str = "libelf os={} target={}".format(os_str, target_str) - spec = Spec(spec_str) + spec = Spec(f"libelf os={os_str} target={target_str}") assert spec.architecture.os == str(TEST_PLATFORM.operating_system(os_str)) assert spec.architecture.target == TEST_PLATFORM.target(target_str) @@ -71,8 +70,8 @@ def test_default_os_and_target(default_mock_concretization): after concretization. """ spec = default_mock_concretization("libelf") - assert spec.architecture.os == str(TEST_PLATFORM.operating_system("default_os")) - assert spec.architecture.target == TEST_PLATFORM.target("default_target") + assert spec.architecture.os == str(TEST_PLATFORM.default_operating_system()) + assert spec.architecture.target == TEST_PLATFORM.default_target() def test_operating_system_conversion_to_dict(): diff --git a/lib/spack/spack/test/cmd/debug.py b/lib/spack/spack/test/cmd/debug.py index 33944fbc6f8..e8e87746dc9 100644 --- a/lib/spack/spack/test/cmd/debug.py +++ b/lib/spack/spack/test/cmd/debug.py @@ -51,8 +51,8 @@ def test_create_db_tarball(tmpdir, database): def test_report(): out = debug("report") host_platform = spack.platforms.host() - host_os = host_platform.operating_system("frontend") - host_target = host_platform.target("frontend") + host_os = host_platform.default_operating_system() + host_target = host_platform.default_target() architecture = spack.spec.ArchSpec((str(host_platform), str(host_os), str(host_target))) assert spack.get_version() in out diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index f8408b736cb..661ba7a1995 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -2614,7 +2614,7 @@ def test_stack_yaml_remove_from_matrix_no_effect(tmpdir): - packages: - matrix: - [mpileaks, callpath] - - [target=be] + - [target=default_target] specs: - $packages """ @@ -2639,7 +2639,7 @@ def test_stack_yaml_force_remove_from_matrix(tmpdir): - packages: - matrix: - [mpileaks, callpath] - - [target=be] + - [target=default_target] specs: - $packages """ @@ -2659,7 +2659,7 @@ def test_stack_yaml_force_remove_from_matrix(tmpdir): assert before_user == after_user - mpileaks_spec = Spec("mpileaks target=be") + mpileaks_spec = Spec("mpileaks target=default_target") assert mpileaks_spec in before_conc assert mpileaks_spec not in after_conc diff --git a/lib/spack/spack/test/concretization/core.py b/lib/spack/spack/test/concretization/core.py index d0521b4369c..0950e227ea9 100644 --- a/lib/spack/spack/test/concretization/core.py +++ b/lib/spack/spack/test/concretization/core.py @@ -148,7 +148,6 @@ def current_host(request, monkeypatch): cpu, _, is_preference = request.param.partition("-") monkeypatch.setattr(spack.platforms.Test, "default", cpu) - monkeypatch.setattr(spack.platforms.Test, "front_end", cpu) if not is_preference: target = archspec.cpu.TARGETS[cpu] monkeypatch.setattr(archspec.cpu, "host", lambda: target) @@ -385,10 +384,11 @@ def test_different_compilers_get_different_flags( ): """Tests that nodes get the flags of the associated compiler.""" mutable_config.set("compilers", [clang12_with_flags, gcc11_with_flags]) + t = archspec.cpu.host().family client = spack.concretize.concretize_one( Spec( - "cmake-client %gcc@11.1.0 platform=test os=fe target=fe" - " ^cmake %clang@12.2.0 platform=test os=fe target=fe" + f"cmake-client %gcc@11.1.0 platform=test os=redhat6 target={t}" + f" ^cmake %clang@12.2.0 platform=test os=redhat6 target={t}" ) ) cmake = client["cmake"] @@ -413,7 +413,8 @@ def test_spec_flags_maintain_order(self, mutable_config, gcc11_with_flags): def test_compiler_flags_differ_identical_compilers(self, mutable_config, clang12_with_flags): mutable_config.set("compilers", [clang12_with_flags]) # Correct arch to use test compiler that has flags - spec = Spec("pkg-a %clang@12.2.0 platform=test os=fe target=fe") + t = archspec.cpu.host().family + spec = Spec(f"pkg-a %clang@12.2.0 platform=test os=redhat6 target={t}") # Get the compiler that matches the spec ( compiler = spack.compilers.compiler_for_spec("clang@=12.2.0", spec.architecture) @@ -2111,14 +2112,15 @@ def test_installed_specs_disregard_conflicts(self, mutable_database, monkeypatch def test_require_targets_are_allowed(self, mutable_database): """Test that users can set target constraints under the require attribute.""" # Configuration to be added to packages.yaml - external_conf = {"all": {"require": "target=%s" % spack.platforms.test.Test.front_end}} + required_target = archspec.cpu.TARGETS[spack.platforms.test.Test.default].family + external_conf = {"all": {"require": f"target={required_target}"}} spack.config.set("packages", external_conf) with spack.config.override("concretizer:reuse", False): spec = spack.concretize.concretize_one("mpich") for s in spec.traverse(): - assert s.satisfies("target=%s" % spack.platforms.test.Test.front_end) + assert s.satisfies(f"target={required_target}") def test_external_python_extensions_have_dependency(self): """Test that python extensions have access to a python dependency diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py index 11829ed92bc..5682135ee26 100644 --- a/lib/spack/spack/test/config.py +++ b/lib/spack/spack/test/config.py @@ -408,7 +408,7 @@ def test_substitute_config_variables(mock_low_high_config, monkeypatch): os.path.join("foo", "$platform", "bar") ) == os.path.abspath(os.path.join("foo", "test", "bar")) - host_target = spack.platforms.host().target("default_target") + host_target = spack.platforms.host().default_target() host_target_family = str(host_target.family) assert spack_path.canonicalize_path( os.path.join("foo", "$target_family", "bar") diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index f907c6c54ff..ceabdc53a13 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -621,7 +621,7 @@ def linux_os(): platform = spack.platforms.host() name, version = "debian", "6" if platform.name == "linux": - current_os = platform.operating_system("default_os") + current_os = platform.default_operating_system() name, version = current_os.name, current_os.version LinuxOS = collections.namedtuple("LinuxOS", ["name", "version"]) return LinuxOS(name=name, version=version) @@ -680,7 +680,6 @@ 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) diff --git a/lib/spack/spack/test/cray_manifest.py b/lib/spack/spack/test/cray_manifest.py index 42585f55fa7..f04a51c0b0d 100644 --- a/lib/spack/spack/test/cray_manifest.py +++ b/lib/spack/spack/test/cray_manifest.py @@ -13,6 +13,8 @@ import pytest +import archspec.cpu + import spack import spack.cmd import spack.cmd.external @@ -98,11 +100,8 @@ def spec_json(self): @pytest.fixture def _common_arch(test_platform): - return JsonArchEntry( - platform=test_platform.name, - os=test_platform.front_os, - target=test_platform.target("fe").name, - ) + generic = archspec.cpu.TARGETS[test_platform.default].family + return JsonArchEntry(platform=test_platform.name, os="redhat6", target=generic.name) @pytest.fixture diff --git a/lib/spack/spack/test/spec_dag.py b/lib/spack/spack/test/spec_dag.py index 5f366b44f61..8a39f07dbdd 100644 --- a/lib/spack/spack/test/spec_dag.py +++ b/lib/spack/spack/test/spec_dag.py @@ -319,7 +319,6 @@ def test_dependents_and_dependencies_are_correct(self): ("mpich@1.0", "mpileaks ^mpich@2.0"), ("mpich%gcc", "mpileaks ^mpich%intel"), ("mpich%gcc@4.6", "mpileaks ^mpich%gcc@4.5"), - ("mpich platform=test target=be", "mpileaks ^mpich platform=test target=fe"), ], ) def test_unsatisfiable_cases(self, set_dependency, constraint_str, spec_str): diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index 8cac90a46cf..668677c44d9 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -460,7 +460,6 @@ def test_concrete_specs_which_satisfies_abstract(self, lhs, rhs, default_mock_co ("foo platform=linux", "platform=test os=redhat6 target=x86"), ("foo os=redhat6", "platform=test os=debian6 target=x86_64"), ("foo target=x86_64", "platform=test os=redhat6 target=x86"), - ("foo arch=test-frontend-frontend", "platform=test os=frontend target=backend"), ("foo%intel", "%gcc"), ("foo%intel", "%gcc"), ("foo%gcc@4.3", "%gcc@4.4:4.6"), @@ -487,7 +486,6 @@ def test_concrete_specs_which_satisfies_abstract(self, lhs, rhs, default_mock_co ("libelf+debug", "libelf~debug"), ("libelf+debug~foo", "libelf+debug+foo"), ("libelf debug=True", "libelf debug=False"), - ("libelf platform=test target=be os=be", "libelf target=fe os=fe"), ("namespace=builtin.mock", "namespace=builtin"), ], ) diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py index e00fb3a7eee..4f58be0b2c3 100644 --- a/lib/spack/spack/test/spec_syntax.py +++ b/lib/spack/spack/test/spec_syntax.py @@ -306,7 +306,7 @@ def _specfile_for(spec_str, filename): ( r"os=fe", # Various translations associated with the architecture [Token(SpecTokens.KEY_VALUE_PAIR, value="os=fe")], - "arch=test-redhat6-None", + "arch=test-debian6-None", ), ( r"os=default_os", @@ -999,14 +999,14 @@ def test_disambiguate_hash_by_spec(spec1, spec2, constraint, mock_packages, monk ("x arch=linux-rhel7-ppc64le arch=linux-rhel7-x86_64", "two architectures"), ("y ^x arch=linux-rhel7-x86_64 arch=linux-rhel7-x86_64", "two architectures"), ("y ^x arch=linux-rhel7-x86_64 arch=linux-rhel7-ppc64le", "two architectures"), - ("x os=fe os=fe", "'os'"), - ("x os=fe os=be", "'os'"), - ("x target=fe target=fe", "'target'"), - ("x target=fe target=be", "'target'"), + ("x os=redhat6 os=debian6", "'os'"), + ("x os=debian6 os=redhat6", "'os'"), + ("x target=core2 target=x86_64", "'target'"), + ("x target=x86_64 target=core2", "'target'"), ("x platform=test platform=test", "'platform'"), # TODO: these two seem wrong: need to change how arch is initialized (should fail on os) - ("x os=fe platform=test target=fe os=fe", "'platform'"), - ("x target=be platform=test os=be os=fe", "'platform'"), + ("x os=debian6 platform=test target=default_target os=redhat6", "two architectures"), + ("x target=default_target platform=test os=redhat6 os=debian6", "'platform'"), # Dependencies ("^[@foo] zlib", "edge attributes"), ("x ^[deptypes=link]foo ^[deptypes=run]foo", "conflicting dependency types"), diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py index 49a0b5e240b..87542415fd0 100644 --- a/lib/spack/spack/util/path.py +++ b/lib/spack/spack/util/path.py @@ -29,8 +29,8 @@ def architecture(): import spack.spec host_platform = spack.platforms.host() - host_os = host_platform.operating_system("default_os") - host_target = host_platform.target("default_target") + host_os = host_platform.default_operating_system() + host_target = host_platform.default_target() return spack.spec.ArchSpec((str(host_platform), str(host_os), str(host_target))) diff --git a/share/spack/spack-completion.fish b/share/spack/spack-completion.fish index 41ae4c91c3d..a920426f8f7 100644 --- a/share/spack/spack-completion.fish +++ b/share/spack/spack-completion.fish @@ -506,9 +506,9 @@ complete -c spack -n '__fish_spack_using_command arch' -s o -l operating-system complete -c spack -n '__fish_spack_using_command arch' -s t -l target -f -a target complete -c spack -n '__fish_spack_using_command arch' -s t -l target -d 'print only the target' complete -c spack -n '__fish_spack_using_command arch' -s f -l frontend -f -a frontend -complete -c spack -n '__fish_spack_using_command arch' -s f -l frontend -d 'print frontend' +complete -c spack -n '__fish_spack_using_command arch' -s f -l frontend -d 'print frontend (DEPRECATED)' complete -c spack -n '__fish_spack_using_command arch' -s b -l backend -f -a backend -complete -c spack -n '__fish_spack_using_command arch' -s b -l backend -d 'print backend' +complete -c spack -n '__fish_spack_using_command arch' -s b -l backend -d 'print backend (DEPRECATED)' # spack audit set -g __fish_spack_optspecs_spack_audit h/help diff --git a/var/spack/repos/builtin/packages/quantum-espresso/package.py b/var/spack/repos/builtin/packages/quantum-espresso/package.py index 490a114577a..cc180d0356c 100644 --- a/var/spack/repos/builtin/packages/quantum-espresso/package.py +++ b/var/spack/repos/builtin/packages/quantum-espresso/package.py @@ -500,18 +500,6 @@ def install(self, pkg, spec, prefix): prefix_path = prefix.bin if "@:5.4.0" in spec else prefix options = ["-prefix={0}".format(prefix_path)] - # This additional flag is needed anytime the target architecture - # does not match the host architecture, which results in a binary that - # configure cannot execute on the login node. This is how we detect - # cross compilation: If the platform is NOT either Linux or Darwin - # and the target=backend, that we are in the cross-compile scenario - # scenario. This should cover Cray, BG/Q, and other custom platforms. - # The other option is to list out all the platform where you would be - # cross compiling explicitly. - if not (spec.satisfies("platform=linux") or spec.satisfies("platform=darwin")): - if spec.satisfies("target=backend"): - options.append("--host") - # QE autoconf compiler variables has some limitations: # 1. There is no explicit MPICC variable so we must re-purpose # CC for the case of MPI.