diff options
author | marmeladema <xademax@gmail.com> | 2019-10-20 19:50:44 +0100 |
---|---|---|
committer | marmeladema <xademax@gmail.com> | 2019-10-20 23:56:46 +0100 |
commit | 4d6f28df3563878188406c375650620378200715 (patch) | |
tree | 31077f9c52d78369011d27f82b3c818eea638d41 /python | |
parent | 0aa6314ee29fcacc44e7f4401733857b3264d3be (diff) | |
download | servo-4d6f28df3563878188406c375650620378200715.tar.gz servo-4d6f28df3563878188406c375650620378200715.zip |
Use linux_distribution() from distro package instead of builtin platform module
platform.linux_distribution() is deprecated since Python 3.5 and
will be removed with Python 3.8.
Diffstat (limited to 'python')
-rw-r--r-- | python/requirements.txt | 1 | ||||
-rw-r--r-- | python/servo/bootstrap.py | 33 | ||||
-rw-r--r-- | python/servo/command_base.py | 8 |
3 files changed, 25 insertions, 17 deletions
diff --git a/python/requirements.txt b/python/requirements.txt index 45eedfaf586..e0e4bb40cc0 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -2,6 +2,7 @@ # since `--system-site-packages` is enabled blessings == 1.6 +distro == 1.4 mach == 0.6.0 mozdebug == 0.1 mozinfo == 0.8 diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py index e3ccff6f953..b854b8844f1 100644 --- a/python/servo/bootstrap.py +++ b/python/servo/bootstrap.py @@ -8,9 +8,10 @@ from distutils.spawn import find_executable from distutils.version import LooseVersion import json import os -import platform +import distro import shutil import subprocess +import six import six.moves.urllib as urllib from subprocess import PIPE from zipfile import BadZipfile @@ -342,9 +343,11 @@ LINUX_SPECIFIC_BOOTSTRAPPERS = { def get_linux_distribution(): - distro, version, _ = platform.linux_distribution() + distrib, version, _ = distro.linux_distribution() + distrib = six.ensure_str(distrib) + version = six.ensure_str(version) - if distro == 'LinuxMint': + if distrib == 'LinuxMint': if '.' in version: major, _ = version.split('.', 1) else: @@ -357,10 +360,10 @@ def get_linux_distribution(): elif major == '17': base_version = '14.04' else: - raise Exception('unsupported version of %s: %s' % (distro, version)) + raise Exception('unsupported version of %s: %s' % (distrib, version)) - distro, version = 'Ubuntu', base_version - elif distro.lower() == 'elementary': + distrib, version = 'Ubuntu', base_version + elif distrib.lower() == 'elementary': if version == '5.0': base_version = '18.04' elif version[0:3] == '0.4': @@ -372,21 +375,21 @@ def get_linux_distribution(): elif version == '0.1': base_version = '10.10' else: - raise Exception('unsupported version of %s: %s' % (distro, version)) - distro, version = 'Ubuntu', base_version - elif distro.lower() == 'ubuntu': + raise Exception('unsupported version of %s: %s' % (distrib, version)) + distrib, version = 'Ubuntu', base_version + elif distrib.lower() == 'ubuntu': if version > '19.04': - raise Exception('unsupported version of %s: %s' % (distro, version)) + raise Exception('unsupported version of %s: %s' % (distrib, version)) # Fixme: we should allow checked/supported versions only - elif distro.lower() not in [ + elif distrib.lower() not in [ 'centos', 'centos linux', 'debian', 'fedora', ]: - raise Exception('mach bootstrap does not support %s, please file a bug' % distro) + raise Exception('mach bootstrap does not support %s, please file a bug' % distrib) - return distro, version + return distrib, version def bootstrap(context, force=False, specific=None): @@ -396,9 +399,9 @@ def bootstrap(context, force=False, specific=None): if "windows-msvc" in host_triple(): bootstrapper = windows_msvc elif "linux-gnu" in host_triple(): - distro, version = get_linux_distribution() + distrib, version = get_linux_distribution() - context.distro = distro + context.distro = distrib context.distro_version = version bootstrapper = LINUX_SPECIFIC_BOOTSTRAPPERS.get(specific, linux) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index d7b9b26dee9..51fa4bc4b5a 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -18,10 +18,12 @@ import locale import os from os import path import platform +import distro import re import contextlib import subprocess from subprocess import PIPE +import six import sys import tarfile import zipfile @@ -679,8 +681,10 @@ install them, let us know by filing a bug!") append_to_path_env(path.join(libpath, "pkgconfig"), env, "PKG_CONFIG_PATH") if sys.platform == "linux2": - distro, version, _ = platform.linux_distribution() - if distro == "Ubuntu" and (version == "16.04" or version == "14.04"): + distrib, version, _ = distro.linux_distribution() + distrib = six.ensure_str(distrib) + version = six.ensure_str(version) + if distrib == "Ubuntu" and (version == "16.04" or version == "14.04"): env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true" if extra_path: |