Skip to content

Commit c10fc7d

Browse files
authored
Merge pull request #3078 from boegel/test_py38
take into account that platform.linux_distribution and platform.dist was removed in Python 3.8
2 parents 825e22f + 9a44bca commit c10fc7d

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

.github/workflows/unit_tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
runs-on: ubuntu-18.04
77
strategy:
88
matrix:
9-
python: [2.7, 3.5, 3.6, 3.7]
9+
python: [2.7, 3.5, 3.6, 3.7, 3.8]
1010
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]
1111
module_syntax: [Lua, Tcl]
1212
# exclude some configuration for non-Lmod modules tool:
1313
# - don't test with Lua module syntax (only supported in Lmod)
14-
# - don't test with Python 3.5 and 3.7 (only with 2.7 and 3.6), to limit test configurations
14+
# - exclude Python 3.x versions other than 3.6, to limit test configurations
1515
exclude:
1616
- modules_tool: modules-tcl-1.147
1717
module_syntax: Lua
@@ -23,14 +23,20 @@ jobs:
2323
python: 3.5
2424
- modules_tool: modules-tcl-1.147
2525
python: 3.7
26+
- modules_tool: modules-tcl-1.147
27+
python: 3.8
2628
- modules_tool: modules-3.2.10
2729
python: 3.5
2830
- modules_tool: modules-3.2.10
2931
python: 3.7
32+
- modules_tool: modules-3.2.10
33+
python: 3.8
3034
- modules_tool: modules-4.1.4
3135
python: 3.5
3236
- modules_tool: modules-4.1.4
3337
python: 3.7
38+
- modules_tool: modules-4.1.4
39+
python: 3.8
3440
fail-fast: false
3541
steps:
3642
- uses: actions/checkout@v1

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ matrix:
5858
- python: 3.7
5959
dist: xenial
6060
env: LMOD_VERSION=7.8.22
61+
- python: 3.8
62+
dist: xenial
63+
env: LMOD_VERSION=7.8.22
6164
addons:
6265
apt:
6366
packages:

easybuild/tools/systemtools.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949

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

52+
53+
try:
54+
import distro
55+
HAVE_DISTRO = True
56+
except ImportError as err:
57+
_log.debug("Failed to import 'distro' Python module: %s", err)
58+
HAVE_DISTRO = False
59+
60+
5261
# Architecture constants
5362
AARCH32 = 'AArch32'
5463
AARCH64 = 'AArch64'
@@ -531,9 +540,21 @@ def get_os_name():
531540
Determine system name, e.g., 'redhat' (generic), 'centos', 'debian', 'fedora', 'suse', 'ubuntu',
532541
'red hat enterprise linux server', 'SL' (Scientific Linux), 'opensuse', ...
533542
"""
534-
# platform.linux_distribution is more useful, but only available since Python 2.6
535-
# this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS)
536-
os_name = platform.linux_distribution()[0].strip().lower()
543+
os_name = None
544+
545+
# platform.linux_distribution was removed in Python 3.8,
546+
# see https://docs.python.org/2/library/platform.html#platform.linux_distribution
547+
if hasattr(platform, 'linux_distribution'):
548+
# platform.linux_distribution is more useful, but only available since Python 2.6
549+
# this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS)
550+
os_name = platform.linux_distribution()[0].strip().lower()
551+
elif HAVE_DISTRO:
552+
# distro package is the recommended alternative to platform.linux_distribution,
553+
# see https://pypi.org/project/distro
554+
os_name = distro.name()
555+
else:
556+
# no easy way to determine name of Linux distribution
557+
os_name = None
537558

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

551572
def get_os_version():
552573
"""Determine system version."""
553-
os_version = platform.dist()[1]
574+
575+
# platform.dist was removed in Python 3.8
576+
if hasattr(platform, 'dist'):
577+
os_version = platform.dist()[1]
578+
elif HAVE_DISTRO:
579+
os_version = distro.version()
580+
else:
581+
os_version = None
582+
554583
if os_version:
555584
if get_os_name() in ["suse", "SLES"]:
556585

0 commit comments

Comments
 (0)