Skip to content

Commit

Permalink
Merge pull request #3078 from boegel/test_py38
Browse files Browse the repository at this point in the history
take into account that platform.linux_distribution and platform.dist was removed in Python 3.8
  • Loading branch information
akesandgren authored Nov 12, 2019
2 parents 825e22f + 9a44bca commit c10fc7d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
python: [2.7, 3.5, 3.6, 3.7]
python: [2.7, 3.5, 3.6, 3.7, 3.8]
modules_tool: [Lmod-6.6.3, Lmod-7.8.22, Lmod-8.1.14, modules-tcl-1.147, modules-3.2.10, modules-4.1.4]
module_syntax: [Lua, Tcl]
# exclude some configuration for non-Lmod modules tool:
# - don't test with Lua module syntax (only supported in Lmod)
# - don't test with Python 3.5 and 3.7 (only with 2.7 and 3.6), to limit test configurations
# - exclude Python 3.x versions other than 3.6, to limit test configurations
exclude:
- modules_tool: modules-tcl-1.147
module_syntax: Lua
Expand All @@ -23,14 +23,20 @@ jobs:
python: 3.5
- modules_tool: modules-tcl-1.147
python: 3.7
- modules_tool: modules-tcl-1.147
python: 3.8
- modules_tool: modules-3.2.10
python: 3.5
- modules_tool: modules-3.2.10
python: 3.7
- modules_tool: modules-3.2.10
python: 3.8
- modules_tool: modules-4.1.4
python: 3.5
- modules_tool: modules-4.1.4
python: 3.7
- modules_tool: modules-4.1.4
python: 3.8
fail-fast: false
steps:
- uses: actions/checkout@v1
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ matrix:
- python: 3.7
dist: xenial
env: LMOD_VERSION=7.8.22
- python: 3.8
dist: xenial
env: LMOD_VERSION=7.8.22
addons:
apt:
packages:
Expand Down
37 changes: 33 additions & 4 deletions easybuild/tools/systemtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@

_log = fancylogger.getLogger('systemtools', fname=False)


try:
import distro
HAVE_DISTRO = True
except ImportError as err:
_log.debug("Failed to import 'distro' Python module: %s", err)
HAVE_DISTRO = False


# Architecture constants
AARCH32 = 'AArch32'
AARCH64 = 'AArch64'
Expand Down Expand Up @@ -531,9 +540,21 @@ def get_os_name():
Determine system name, e.g., 'redhat' (generic), 'centos', 'debian', 'fedora', 'suse', 'ubuntu',
'red hat enterprise linux server', 'SL' (Scientific Linux), 'opensuse', ...
"""
# platform.linux_distribution is more useful, but only available since Python 2.6
# this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS)
os_name = platform.linux_distribution()[0].strip().lower()
os_name = None

# platform.linux_distribution was removed in Python 3.8,
# see https://docs.python.org/2/library/platform.html#platform.linux_distribution
if hasattr(platform, 'linux_distribution'):
# platform.linux_distribution is more useful, but only available since Python 2.6
# this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS)
os_name = platform.linux_distribution()[0].strip().lower()
elif HAVE_DISTRO:
# distro package is the recommended alternative to platform.linux_distribution,
# see https://pypi.org/project/distro
os_name = distro.name()
else:
# no easy way to determine name of Linux distribution
os_name = None

os_name_map = {
'red hat enterprise linux server': 'RHEL',
Expand All @@ -550,7 +571,15 @@ def get_os_name():

def get_os_version():
"""Determine system version."""
os_version = platform.dist()[1]

# platform.dist was removed in Python 3.8
if hasattr(platform, 'dist'):
os_version = platform.dist()[1]
elif HAVE_DISTRO:
os_version = distro.version()
else:
os_version = None

if os_version:
if get_os_name() in ["suse", "SLES"]:

Expand Down

0 comments on commit c10fc7d

Please sign in to comment.