mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-09-02 02:03:54 +00:00
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/gstreamer/-/merge_requests/1358>
This commit is contained in:
parent
f95f63c5af
commit
bdc4d9c395
1 changed files with 12 additions and 3 deletions
15
gst-env.py
15
gst-env.py
|
@ -18,8 +18,7 @@ import signal
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import PurePath, Path
|
from pathlib import PurePath, Path
|
||||||
|
|
||||||
from distutils.sysconfig import get_python_lib
|
from typing import Any
|
||||||
from distutils.util import strtobool
|
|
||||||
|
|
||||||
from scripts.common import get_meson
|
from scripts.common import get_meson
|
||||||
from scripts.common import git
|
from scripts.common import git
|
||||||
|
@ -55,6 +54,16 @@ done
|
||||||
BASH_COMPLETION_PATHS = [SCRIPTDIR + '/subprojects/gstreamer/data/bash-completion/completions']
|
BASH_COMPLETION_PATHS = [SCRIPTDIR + '/subprojects/gstreamer/data/bash-completion/completions']
|
||||||
BASH_COMPLETION_PATHS += [SCRIPTDIR + '/subprojects/gst-devtools/validate/data/bash-completion/completions']
|
BASH_COMPLETION_PATHS += [SCRIPTDIR + '/subprojects/gst-devtools/validate/data/bash-completion/completions']
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
def listify(o):
|
||||||
if isinstance(o, str):
|
if isinstance(o, str):
|
||||||
return [o]
|
return [o]
|
||||||
|
@ -545,7 +554,7 @@ if __name__ == "__main__":
|
||||||
args += ['/k', 'prompt [gst-{}] $P$G'.format(gst_version)]
|
args += ['/k', 'prompt [gst-{}] $P$G'.format(gst_version)]
|
||||||
else:
|
else:
|
||||||
args = [os.environ.get("SHELL", os.path.realpath("/bin/sh"))]
|
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
|
# Let the GC remove the tmp file
|
||||||
tmprc = tempfile.NamedTemporaryFile(mode='w')
|
tmprc = tempfile.NamedTemporaryFile(mode='w')
|
||||||
bashrc = os.path.expanduser('~/.bashrc')
|
bashrc = os.path.expanduser('~/.bashrc')
|
||||||
|
|
Loading…
Reference in a new issue