diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-09-26 13:10:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-09-26 14:40:15 +0200 |
commit | d5ec09b3ccc00bb6e1d0999a4c6d076343d91549 (patch) | |
tree | f4fd9c17989425d6c54e590900dd7b82107dd8cc /sources | |
parent | 569f2a19dd32f6fcab9910cdf38b956e7ca2f39e (diff) |
pyside6-project: Recognize .pyw files as Python
The suffix .pyw is used for Windows GUI applications.
Pick-to: 6.6 6.5
Fixes: PYSIDE-2471
Change-Id: Ib067e075ea5b76c36a69da0881e224bdf416c45e
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside-tools/project.py | 9 | ||||
-rw-r--r-- | sources/pyside-tools/project/__init__.py | 3 | ||||
-rw-r--r-- | sources/pyside-tools/project/project_data.py | 8 |
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: |