summaryrefslogtreecommitdiff
path: root/lib/spack/spack/platforms/linux.py
blob: 60624a800935e9f8eda5b494eb566d9d91a2adbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import platform

import archspec.cpu

import spack.target
from spack.operating_systems.linux_distro import LinuxDistro

from ._platform import Platform


class Linux(Platform):
    priority = 90

    def __init__(self):
        super().__init__("linux")

        for name in archspec.cpu.TARGETS:
            self.add_target(name, spack.target.Target(name))

        # 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
    def detect(cls):
        return "linux" in platform.system().lower()