aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-26 13:10:03 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-09-26 23:16:34 +0000
commitf13af24b1a03719c71c4378687514c2ec8a72021 (patch)
treed599b27ddb8486806abd0df4832a0129bec352bf
parent2823763072ce3a2da0210dbc014c6ad3195fbeff (diff)
pyside6-project: Recognize .pyw files as Python
The suffix .pyw is used for Windows GUI applications. Fixes: PYSIDE-2471 Change-Id: Ib067e075ea5b76c36a69da0881e224bdf416c45e Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit d5ec09b3ccc00bb6e1d0999a4c6d076343d91549) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 50d971046c5638d6258eb09f7f5ef1100cbef43b)
-rw-r--r--sources/pyside-tools/project.py9
-rw-r--r--sources/pyside-tools/project/__init__.py3
-rw-r--r--sources/pyside-tools/project/project_data.py8
3 files changed, 13 insertions, 7 deletions
diff --git a/sources/pyside-tools/project.py b/sources/pyside-tools/project.py
index 003bde319..3dbe42547 100644
--- a/sources/pyside-tools/project.py
+++ b/sources/pyside-tools/project.py
@@ -25,9 +25,10 @@ from typing import List, Tuple, Optional
from pathlib import Path
from argparse import ArgumentParser, RawTextHelpFormatter
-from project import (QmlProjectData, check_qml_decorators, QMLDIR_FILE,
- MOD_CMD, METATYPES_JSON_SUFFIX, requires_rebuild, run_command,
- remove_path, ProjectData, resolve_project_file, new_project,
+from project import (QmlProjectData, check_qml_decorators, is_python_file,
+ QMLDIR_FILE, MOD_CMD, METATYPES_JSON_SUFFIX,
+ requires_rebuild, run_command, remove_path,
+ ProjectData, resolve_project_file, new_project,
ProjectType)
MODE_HELP = """build Builds the project
@@ -71,7 +72,7 @@ class Project:
if not opt_qml_module and not self.project.qml_files:
return
for file in self.project.files:
- if file.suffix == ".py":
+ if is_python_file(file):
has_class, data = check_qml_decorators(file)
if has_class:
self._qml_module_sources.append(file)
diff --git a/sources/pyside-tools/project/__init__.py b/sources/pyside-tools/project/__init__.py
index 39dcef345..be99555b1 100644
--- a/sources/pyside-tools/project/__init__.py
+++ b/sources/pyside-tools/project/__init__.py
@@ -21,5 +21,6 @@ METATYPES_JSON_SUFFIX = "metatypes.json"
from .utils import (run_command, requires_rebuild, remove_path, package_dir, qtpaths,
qt_metatype_json_dir, resolve_project_file)
-from .project_data import ProjectData, QmlProjectData, check_qml_decorators
+from .project_data import (is_python_file, ProjectData, QmlProjectData,
+ check_qml_decorators)
from .newproject import new_project, ProjectType
diff --git a/sources/pyside-tools/project/project_data.py b/sources/pyside-tools/project/project_data.py
index 05235fefc..4cd30c42b 100644
--- a/sources/pyside-tools/project/project_data.py
+++ b/sources/pyside-tools/project/project_data.py
@@ -11,6 +11,10 @@ from . import (METATYPES_JSON_SUFFIX, PROJECT_FILE_SUFFIX, qt_metatype_json_dir,
MOD_CMD, QML_IMPORT_MAJOR_VERSION, QML_IMPORT_MINOR_VERSION, QML_IMPORT_NAME,
QT_MODULES)
+def is_python_file(file: Path) -> bool:
+ return (file.suffix == ".py"
+ or sys.platform == "win32" and file.suffix == ".pyw")
+
class ProjectData:
def __init__(self, project_file: Path) -> None:
@@ -36,8 +40,8 @@ class ProjectData:
self._files.append(file)
if file.suffix == ".qml":
self._qml_files.append(file)
- elif file.suffix == ".py":
- if file.name == "main.py":
+ elif is_python_file(file):
+ if file.stem == "main":
self.main_file = file
self._python_files.append(file)
if not self.main_file: