diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index a58f0e8102..90668cc4df 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -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 @@ -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 diff --git a/.travis.yml b/.travis.yml index e780254118..c7d8a76d50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/easybuild/tools/systemtools.py b/easybuild/tools/systemtools.py index ee6b0bceaf..c0242c8b71 100644 --- a/easybuild/tools/systemtools.py +++ b/easybuild/tools/systemtools.py @@ -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' @@ -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', @@ -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"]: