gst-env: Improve coding style and cleanup
* Remove unused variables * Remove unused imports * Apply pycodestyle style suggestions - Missing newlines - spaces before brackets - Wrong indentations Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1743>
This commit is contained in:
parent
c769a089ea
commit
cfea428081
16
gst-env.py
16
gst-env.py
@ -1,17 +1,14 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import contextlib
|
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import site
|
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import pathlib
|
import pathlib
|
||||||
import signal
|
import signal
|
||||||
@ -71,6 +68,7 @@ def listify(o):
|
|||||||
return o
|
return o
|
||||||
raise AssertionError('Object {!r} must be a string or a list'.format(o))
|
raise AssertionError('Object {!r} must be a string or a list'.format(o))
|
||||||
|
|
||||||
|
|
||||||
def stringify(o):
|
def stringify(o):
|
||||||
if isinstance(o, str):
|
if isinstance(o, str):
|
||||||
return o
|
return o
|
||||||
@ -80,6 +78,7 @@ def stringify(o):
|
|||||||
raise AssertionError('Did not expect object {!r} to have more than one element'.format(o))
|
raise AssertionError('Did not expect object {!r} to have more than one element'.format(o))
|
||||||
raise AssertionError('Object {!r} must be a string or a list'.format(o))
|
raise AssertionError('Object {!r} must be a string or a list'.format(o))
|
||||||
|
|
||||||
|
|
||||||
def prepend_env_var(env, var, value, sysroot):
|
def prepend_env_var(env, var, value, sysroot):
|
||||||
if var is None:
|
if var is None:
|
||||||
return
|
return
|
||||||
@ -96,6 +95,7 @@ def prepend_env_var(env, var, value, sysroot):
|
|||||||
env[var] = val + env_val
|
env[var] = val + env_val
|
||||||
env[var] = env[var].replace(os.pathsep + os.pathsep, os.pathsep).strip(os.pathsep)
|
env[var] = env[var].replace(os.pathsep + os.pathsep, os.pathsep).strip(os.pathsep)
|
||||||
|
|
||||||
|
|
||||||
def get_target_install_filename(target, filename):
|
def get_target_install_filename(target, filename):
|
||||||
'''
|
'''
|
||||||
Checks whether this file is one of the files installed by the target
|
Checks whether this file is one of the files installed by the target
|
||||||
@ -106,6 +106,7 @@ def get_target_install_filename(target, filename):
|
|||||||
return install_filename
|
return install_filename
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_pkgconfig_variable_from_pcfile(pcfile, varname):
|
def get_pkgconfig_variable_from_pcfile(pcfile, varname):
|
||||||
variables = {}
|
variables = {}
|
||||||
substre = re.compile('\$\{[^${}]+\}')
|
substre = re.compile('\$\{[^${}]+\}')
|
||||||
@ -123,6 +124,7 @@ def get_pkgconfig_variable_from_pcfile(pcfile, varname):
|
|||||||
variables[key] = value
|
variables[key] = value
|
||||||
return variables.get(varname, '')
|
return variables.get(varname, '')
|
||||||
|
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def get_pkgconfig_variable(builddir, pcname, varname):
|
def get_pkgconfig_variable(builddir, pcname, varname):
|
||||||
'''
|
'''
|
||||||
@ -147,6 +149,7 @@ def is_gio_module(target, filename, builddir):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def is_library_target_and_not_plugin(target, filename):
|
def is_library_target_and_not_plugin(target, filename):
|
||||||
'''
|
'''
|
||||||
Don't add plugins to PATH/LD_LIBRARY_PATH because:
|
Don't add plugins to PATH/LD_LIBRARY_PATH because:
|
||||||
@ -169,6 +172,7 @@ def is_library_target_and_not_plugin(target, filename):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def is_binary_target_and_in_path(target, filename, bindir):
|
def is_binary_target_and_in_path(target, filename, bindir):
|
||||||
if target['type'] != 'executable':
|
if target['type'] != 'executable':
|
||||||
return False
|
return False
|
||||||
@ -200,6 +204,7 @@ def get_wine_subprocess_env(options, env):
|
|||||||
|
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def setup_gdb(options):
|
def setup_gdb(options):
|
||||||
python_paths = set()
|
python_paths = set()
|
||||||
|
|
||||||
@ -242,9 +247,11 @@ def setup_gdb(options):
|
|||||||
|
|
||||||
return python_paths
|
return python_paths
|
||||||
|
|
||||||
|
|
||||||
def is_bash_completion_available(options):
|
def is_bash_completion_available(options):
|
||||||
return os.path.exists(os.path.join(options.builddir, 'subprojects/gstreamer/data/bash-completion/helpers/gst'))
|
return os.path.exists(os.path.join(options.builddir, 'subprojects/gstreamer/data/bash-completion/helpers/gst'))
|
||||||
|
|
||||||
|
|
||||||
def get_subprocess_env(options, gst_version):
|
def get_subprocess_env(options, gst_version):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
|
||||||
@ -404,7 +411,6 @@ def get_subprocess_env(options, gst_version):
|
|||||||
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
|
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
|
||||||
for path, installpath in json.loads(installed_s.decode()).items():
|
for path, installpath in json.loads(installed_s.decode()).items():
|
||||||
installpath_parts = pathlib.Path(installpath).parts
|
installpath_parts = pathlib.Path(installpath).parts
|
||||||
path_parts = pathlib.Path(path).parts
|
|
||||||
|
|
||||||
# We want to add all python modules to the PYTHONPATH
|
# We want to add all python modules to the PYTHONPATH
|
||||||
# in a manner consistent with the way they would be imported:
|
# in a manner consistent with the way they would be imported:
|
||||||
@ -481,12 +487,14 @@ def get_subprocess_env(options, gst_version):
|
|||||||
|
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def get_windows_shell():
|
def get_windows_shell():
|
||||||
command = ['powershell.exe', '-noprofile', '-executionpolicy', 'bypass', '-file',
|
command = ['powershell.exe', '-noprofile', '-executionpolicy', 'bypass', '-file',
|
||||||
os.path.join(SCRIPTDIR, 'data', 'misc', 'cmd_or_ps.ps1')]
|
os.path.join(SCRIPTDIR, 'data', 'misc', 'cmd_or_ps.ps1')]
|
||||||
result = subprocess.check_output(command)
|
result = subprocess.check_output(command)
|
||||||
return result.decode().strip()
|
return result.decode().strip()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(prog="gst-env")
|
parser = argparse.ArgumentParser(prog="gst-env")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user