aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts/qfp_tool.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-07-23 14:47:29 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-07-24 14:06:43 +0200
commit09b39866b34cc2e4e849a451f9a76daeb14bc046 (patch)
tree011376515c4db1b6fe60b72fa4726d0d482a060b /build_scripts/qfp_tool.py
parent03e16a56062f42b32efdba583950dab8a57522c6 (diff)
qfp_tool: Add an option to uninstall the PySide packages
Pick-to: 6.9 Change-Id: Idb9354fa8e443fc0ea4aea72851163b9908a5e3f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'build_scripts/qfp_tool.py')
-rw-r--r--build_scripts/qfp_tool.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/build_scripts/qfp_tool.py b/build_scripts/qfp_tool.py
index a15796f33..b1af14a4d 100644
--- a/build_scripts/qfp_tool.py
+++ b/build_scripts/qfp_tool.py
@@ -284,6 +284,32 @@ def get_config_file(base_name) -> Path:
return config_file
+def pip_list():
+ """List installed packages from the output lines of pip (shiboken6 6.9.0a1)."""
+ result = []
+ pattern = re.compile(r"^([^\s]+)\s+\d.*$")
+ for line in run_process_output(["pip", "list"]):
+ match = pattern.search(line)
+ if match:
+ result.append(match.group(1))
+ return result
+
+
+def uninstall_pyside():
+ """Uninstall all PySide related packages."""
+ packages = []
+ for p in pip_list():
+ if "shiboken" in p or "PySide" in p:
+ packages.append(p)
+ if not packages or opt_dry_run:
+ return
+ yes = "Y\n" * len(packages)
+ cmd = ["pip", "uninstall"] + packages
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
+ stderr=subprocess.PIPE, text=True) as process:
+ print(process.communicate(input=yes)[0])
+
+
def run_build(target: str):
"""Run configure and build steps"""
arguments = []
@@ -398,6 +424,8 @@ def create_argument_parser(desc):
help='Run tests')
parser.add_argument('--Documentation', '-D', action='store_true',
help='Run build_base_docs')
+ parser.add_argument('--uninstall', '-U', action='store_true',
+ help='Uninstall packages')
parser.add_argument('--version', '-v', action='version', version='%(prog)s 1.0')
parser.add_argument('--verbose', '-V', action='store_true',
help='Turn off --quiet specified in build arguments')
@@ -436,7 +464,8 @@ if __name__ == '__main__':
build_mode = BuildMode.RECONFIGURE
if build_mode == BuildMode.NONE and not (options.clean or options.reset or options.pull
- or options.Documentation or options.test):
+ or options.uninstall or options.Documentation
+ or options.test):
argument_parser.print_help()
sys.exit(0)
@@ -460,6 +489,9 @@ if __name__ == '__main__':
base_dir = Path.cwd().name
+ if options.uninstall:
+ uninstall_pyside()
+
if options.clean:
run_git(['clean', '-dxf'])