mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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.
This commit is contained in:
parent
0aa6314ee2
commit
4d6f28df35
3 changed files with 25 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue