spack.platforms package

class spack.platforms.Cray[source]

Bases: Platform

classmethod craype_type_and_version()[source]
classmethod detect()[source]

Detect whether this system requires CrayPE module support.

Systems with newer CrayPE (21.10 for EX systems, future work for CS and XC systems) have compilers and MPI wrappers that can be used directly by path. These systems are considered linux platforms.

For systems running an older CrayPE, we detect the Cray platform based on the availability through module of the Cray programming environment. If this environment is available, we can use it to find compilers, target modules, etc. If the Cray programming environment is not available via modules, then we will treat it as a standard linux system, as the Cray compiler wrappers and other components of the Cray programming environment are irrelevant without module support.

priority: int | None = 10
setup_platform_environment(pkg, env)[source]

Change the linker to default dynamic to be more similar to linux/standard linker behavior

class spack.platforms.Darwin[source]

Bases: Platform

binary_formats = ['macho']

binary formats used on this platform; used by relocation logic

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 89
setup_platform_environment(pkg, env)[source]

Specify deployment target based on target OS version.

The MACOSX_DEPLOYMENT_TARGET environment variable provides a default -mmacosx-version-min argument for GCC and Clang compilers, as well as the default value of CMAKE_OSX_DEPLOYMENT_TARGET for CMake-based build systems. The default value for the deployment target is usually the major version (11, 10.16, …) for CMake and Clang, but some versions of GCC specify a minor component as well (11.3), leading to numerous link warnings about inconsistent or incompatible target versions. Setting the environment variable ensures consistent versions for an install toolchain target, even when the host macOS version changes.

TODO: it may be necessary to add SYSTEM_VERSION_COMPAT for older versions of the macosx developer tools; see https://github.com/spack/spack/pull/26290 for discussion.

class spack.platforms.FreeBSD[source]

Bases: Platform

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 102
class spack.platforms.Linux[source]

Bases: Platform

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 90
class spack.platforms.Platform(name)[source]

Bases: object

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.

add_operating_system(name, os_class)[source]

Add the operating_system class object into the platform.operating_sys dictionary.

add_target(name, target)[source]

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.

back_end: str | None = None
back_os: str | None = None
binary_formats = ['elf']

binary formats used on this platform; used by relocation logic

default: str | None = None
default_os: str | None = None
classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

front_end: str | None = None
front_os: str | None = None
operating_system(name)[source]
priority: int | None = None
reserved_oss = ['default_os', 'frontend', 'fe', 'backend', 'be']
reserved_targets = ['default_target', 'frontend', 'fe', 'backend', 'be']
setup_platform_environment(pkg, env)[source]

Subclass can override this method if it requires any platform-specific build environment modifications.

target(name)[source]

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.

class spack.platforms.Test(name=None)[source]

Bases: Platform

back_end: str | None = 'core2'
back_os: str | None = 'debian6'
default: str | None = 'core2'
default_os: str | None = 'debian6'
classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

front_end: str | None = 'x86_64'
front_os: str | None = 'redhat6'
priority: int | None = 1000000
class spack.platforms.Windows[source]

Bases: Platform

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 101
spack.platforms.by_name(name)[source]

Return a platform object that corresponds to the given name or None if there is no match.

Parameters:

name (str) – name of the platform

spack.platforms.host()

The current platform used by Spack. May be swapped by the use_platform context manager.

spack.platforms.prevent_cray_detection()[source]

Context manager that prevents the detection of the Cray platform

spack.platforms.reset()[source]

The result of the host search is memoized. In case it needs to be recomputed we must clear the cache, which is what this function does.

Submodules

spack.platforms.cray module

class spack.platforms.cray.Cray[source]

Bases: Platform

classmethod craype_type_and_version()[source]
classmethod detect()[source]

Detect whether this system requires CrayPE module support.

Systems with newer CrayPE (21.10 for EX systems, future work for CS and XC systems) have compilers and MPI wrappers that can be used directly by path. These systems are considered linux platforms.

For systems running an older CrayPE, we detect the Cray platform based on the availability through module of the Cray programming environment. If this environment is available, we can use it to find compilers, target modules, etc. If the Cray programming environment is not available via modules, then we will treat it as a standard linux system, as the Cray compiler wrappers and other components of the Cray programming environment are irrelevant without module support.

priority: int | None = 10
setup_platform_environment(pkg, env)[source]

Change the linker to default dynamic to be more similar to linux/standard linker behavior

spack.platforms.cray.slingshot_network()[source]

spack.platforms.darwin module

class spack.platforms.darwin.Darwin[source]

Bases: Platform

binary_formats = ['macho']

binary formats used on this platform; used by relocation logic

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 89
setup_platform_environment(pkg, env)[source]

Specify deployment target based on target OS version.

The MACOSX_DEPLOYMENT_TARGET environment variable provides a default -mmacosx-version-min argument for GCC and Clang compilers, as well as the default value of CMAKE_OSX_DEPLOYMENT_TARGET for CMake-based build systems. The default value for the deployment target is usually the major version (11, 10.16, …) for CMake and Clang, but some versions of GCC specify a minor component as well (11.3), leading to numerous link warnings about inconsistent or incompatible target versions. Setting the environment variable ensures consistent versions for an install toolchain target, even when the host macOS version changes.

TODO: it may be necessary to add SYSTEM_VERSION_COMPAT for older versions of the macosx developer tools; see https://github.com/spack/spack/pull/26290 for discussion.

spack.platforms.freebsd module

class spack.platforms.freebsd.FreeBSD[source]

Bases: Platform

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 102

spack.platforms.linux module

class spack.platforms.linux.Linux[source]

Bases: Platform

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 90

spack.platforms.test module

class spack.platforms.test.Test(name=None)[source]

Bases: Platform

back_end: str | None = 'core2'
back_os: str | None = 'debian6'
default: str | None = 'core2'
default_os: str | None = 'debian6'
classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

front_end: str | None = 'x86_64'
front_os: str | None = 'redhat6'
priority: int | None = 1000000

spack.platforms.windows module

class spack.platforms.windows.Windows[source]

Bases: Platform

classmethod detect()[source]

Return True if the the host platform is detected to be the current Platform class, False otherwise.

Derived classes are responsible for implementing this method.

priority: int | None = 101