Add function to determine Linux kernel version (#27855)
This reports the kernel version (vs. the distro version) on Linux and returns a valid Version (stripping characters like '+' which may be present for custom-built kernels).
This commit is contained in:
parent
52cfd17917
commit
a4f0fbafbb
@ -2,11 +2,31 @@
|
|||||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
import platform as py_platform
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from spack.version import Version
|
||||||
|
|
||||||
from ._operating_system import OperatingSystem
|
from ._operating_system import OperatingSystem
|
||||||
|
|
||||||
|
|
||||||
|
def kernel_version():
|
||||||
|
"""Return the kernel version as a Version object.
|
||||||
|
Note that the kernel version is distinct from OS and/or
|
||||||
|
distribution versions. For instance:
|
||||||
|
>>> external.distro.id()
|
||||||
|
'centos'
|
||||||
|
>>> external.distro.version()
|
||||||
|
'7'
|
||||||
|
>>> platform.release()
|
||||||
|
'5.10.84+'
|
||||||
|
"""
|
||||||
|
# Strip '+' characters just in case we're running a
|
||||||
|
# version built from git/etc
|
||||||
|
clean_version = re.sub(r'\+', r'', py_platform.release())
|
||||||
|
return Version(clean_version)
|
||||||
|
|
||||||
|
|
||||||
class LinuxDistro(OperatingSystem):
|
class LinuxDistro(OperatingSystem):
|
||||||
""" This class will represent the autodetected operating system
|
""" This class will represent the autodetected operating system
|
||||||
for a Linux System. Since there are many different flavors of
|
for a Linux System. Since there are many different flavors of
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
|
|
||||||
from spack import *
|
from spack import *
|
||||||
|
from spack.operating_systems.linux_distro import kernel_version
|
||||||
from spack.operating_systems.mac_os import macos_version
|
from spack.operating_systems.mac_os import macos_version
|
||||||
|
|
||||||
MACOS_VERSION = macos_version() if sys.platform == 'darwin' else None
|
MACOS_VERSION = macos_version() if sys.platform == 'darwin' else None
|
||||||
LINUX_VERSION = Version(platform.release()) if platform.system() == 'Linux' else None
|
LINUX_VERSION = kernel_version() if platform.system() == 'Linux' else None
|
||||||
|
|
||||||
|
|
||||||
class Qt(Package):
|
class Qt(Package):
|
||||||
|
Loading…
Reference in New Issue
Block a user