diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2021-11-16 23:39:43 -0300 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-11-20 20:38:21 +0000 |
commit | 5b691455ae6804bd4e35f57d0f7de3c0606d736e (patch) | |
tree | 8e16167dce64f2e6040f91c914d5d60b861c2c4f | |
parent | 1ef766f29e3ef84053b324e13128c3790384eb0d (diff) |
env: Fix deprecations from python 3.10
distutils is now deprecated and strtobool is simple enough for us to just
vendor.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/268>
-rwxr-xr-x | gst-env.py | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -18,8 +18,7 @@ import signal from functools import lru_cache from pathlib import PurePath, Path -from distutils.sysconfig import get_python_lib -from distutils.util import strtobool +from typing import Any from scripts.common import get_meson from scripts.common import git @@ -43,6 +42,14 @@ SHAREDLIB_REG = re.compile(r'\.so|\.dylib|\.dll') GSTPLUGIN_FILEPATH_REG_TEMPLATE = r'.*/{libdir}/gstreamer-1.0/[^/]+$' GSTPLUGIN_FILEPATH_REG = None +def str_to_bool(value: Any) -> bool: + """Return whether the provided string (or any value really) represents true. Otherwise false. + Just like plugin server stringToBoolean. + """ + if not value: + return False + return str(value).lower() in ("y", "yes", "t", "true", "on", "1") + def listify(o): if isinstance(o, str): return [o] @@ -507,7 +514,7 @@ if __name__ == "__main__": args += ['/k', 'prompt [gst-{}] $P$G'.format(gst_version)] else: args = [os.environ.get("SHELL", os.path.realpath("/bin/sh"))] - if args[0].endswith('bash') and not strtobool(os.environ.get("GST_BUILD_DISABLE_PS1_OVERRIDE", r"FALSE")): + if args[0].endswith('bash') and not str_to_bool(os.environ.get("GST_BUILD_DISABLE_PS1_OVERRIDE", r"FALSE")): # Let the GC remove the tmp file tmprc = tempfile.NamedTemporaryFile(mode='w') bashrc = os.path.expanduser('~/.bashrc') |