aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/deploy_lib/commands.py
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2024-08-27 11:27:45 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-09-05 09:34:52 +0200
commit2232118e90d5d8851dd10550a43c1dec718af2e8 (patch)
tree28d378849550da386824870510641b56ad8aec72 /sources/pyside-tools/deploy_lib/commands.py
parentea40e353bcbe985a5255c7955ee80a537906b76f (diff)
Deployment: Exclude directories from qmlimportscanner check
- ac55d94395849a5a4af2883d2dab82982252c92d helps to fix a TODO where we can exclude directories from the qmlimportscanner check directly without moving all the QML files into a temporary directory - Amend b32183d2cd5fbbd1ac6a53827edf5d40428855ff Task-number: PYSIDE-1612 Task-number: PYSIDE-2803 Change-Id: I2524af7154b32730d2d823fda6973b9a2c8a76a3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy_lib/commands.py')
-rw-r--r--sources/pyside-tools/deploy_lib/commands.py33
1 files changed, 12 insertions, 21 deletions
diff --git a/sources/pyside-tools/deploy_lib/commands.py b/sources/pyside-tools/deploy_lib/commands.py
index 8c017051d..03f8c20f8 100644
--- a/sources/pyside-tools/deploy_lib/commands.py
+++ b/sources/pyside-tools/deploy_lib/commands.py
@@ -5,10 +5,9 @@ from __future__ import annotations
import json
import subprocess
import sys
-import shutil
-import tempfile
from pathlib import Path
from functools import lru_cache
+from . import DEFAULT_IGNORE_DIRS
"""
@@ -42,31 +41,23 @@ def run_command(command, dry_run: bool, fetch_output: bool = False):
@lru_cache
-def run_qmlimportscanner(qml_files: tuple[Path], dry_run: bool):
+def run_qmlimportscanner(project_dir: Path, dry_run: bool):
"""
Runs pyside6-qmlimportscanner to find all the imported qml modules in project_dir
"""
qml_modules = []
- # Create a temporary directory to copy all the .qml_files
- # TODO: Modify qmlimportscanner code in qtdeclarative to include a flag to ignore directories
- # Then, this copy into a temporary directory can be avoided
- # See 36b425ea8bf36d47694ea69fa7d129b6d5a2ca2d in gerrit
- with tempfile.TemporaryDirectory() as temp_dir:
- temp_path = Path(temp_dir)
- # Copy only files with .qml suffix
- for qml_file in qml_files:
- if qml_file.suffix == ".qml":
- shutil.copy2(qml_file.resolve(), temp_path / qml_file.name)
+ cmd = ["pyside6-qmlimportscanner", "-rootPath", str(project_dir)]
- cmd = ["pyside6-qmlimportscanner", "-rootPath", str(temp_path)]
+ for ignore_dir in DEFAULT_IGNORE_DIRS:
+ cmd.extend(["-exclude", ignore_dir])
- if dry_run:
- run_command(command=cmd, dry_run=True)
+ if dry_run:
+ run_command(command=cmd, dry_run=True)
- # Run qmlimportscanner during dry_run as well to complete the command being run by nuitka
- _, json_string = run_command(command=cmd, dry_run=False, fetch_output=True)
- json_string = json_string.decode("utf-8")
- json_array = json.loads(json_string)
- qml_modules = [item['name'] for item in json_array if item['type'] == "module"]
+ # Run qmlimportscanner during dry_run as well to complete the command being run by nuitka
+ _, json_string = run_command(command=cmd, dry_run=False, fetch_output=True)
+ json_string = json_string.decode("utf-8")
+ json_array = json.loads(json_string)
+ qml_modules = [item['name'] for item in json_array if item['type'] == "module"]
return qml_modules