diff options
| -rw-r--r-- | sources/pyside-tools/project.py | 10 | ||||
| -rw-r--r-- | sources/pyside-tools/project_lib/project_data.py | 13 | ||||
| -rw-r--r-- | sources/pyside-tools/project_lib/pyproject_parse_result.py | 2 | ||||
| -rw-r--r-- | sources/pyside-tools/project_lib/pyproject_toml.py | 9 | ||||
| -rw-r--r-- | sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 2 | ||||
| -rw-r--r-- | sources/pyside6/doc/tools/pyside-project.rst | 11 | ||||
| -rw-r--r-- | sources/pyside6/tests/QtCore/qobject_property_test.py | 13 |
7 files changed, 49 insertions, 11 deletions
diff --git a/sources/pyside-tools/project.py b/sources/pyside-tools/project.py index 762e76f31..fbb740c32 100644 --- a/sources/pyside-tools/project.py +++ b/sources/pyside-tools/project.py @@ -104,13 +104,19 @@ class Project: """Return path and command for a file's artifact""" if file.suffix == ".ui": # Qt form files py_file = f"{file.parent}/ui_{file.stem}.py" - return [Path(py_file)], [UIC_CMD, os.fspath(file), "--rc-prefix", "-o", py_file] + cmd = [UIC_CMD] + cmd.extend(self.project.uic_options) + cmd.extend([os.fspath(file), "--rc-prefix", "-o", py_file]) + return [Path(py_file)], cmd if file.suffix == ".qrc": # Qt resources if not output_path: py_file = f"{file.parent}/rc_{file.stem}.py" else: py_file = str(output_path.resolve()) - return [Path(py_file)], [RCC_CMD, os.fspath(file), "-o", py_file] + cmd = [RCC_CMD] + cmd.extend(self.project.rcc_options) + cmd.extend([os.fspath(file), "-o", py_file]) + return [Path(py_file)], cmd # generate .qmltypes from sources with Qml decorators if file.suffix == ".py" and file in self._qml_module_sources: assert self._qml_module_dir diff --git a/sources/pyside-tools/project_lib/project_data.py b/sources/pyside-tools/project_lib/project_data.py index 9a219c957..928e79c7b 100644 --- a/sources/pyside-tools/project_lib/project_data.py +++ b/sources/pyside-tools/project_lib/project_data.py @@ -34,8 +34,10 @@ class ProjectData: self._python_files: list[Path] = [] # ui files self._ui_files: list[Path] = [] + self._uic_options: list[str] = [] # qrc files self._qrc_files: list[Path] = [] + self._rcc_options: list[str] = [] # ts files self._ts_files: list[Path] = [] @@ -53,6 +55,9 @@ class ProjectData: print(f"{error}", file=sys.stderr) sys.exit(1) + self._rcc_options = project_file_data.rcc_options + self._uic_options = project_file_data.uic_options + for f in project_file_data.files: file = Path(project_file.parent / f) if any(file.match(pattern) for pattern in PYPROJECT_FILE_PATTERNS): @@ -101,10 +106,18 @@ class ProjectData: return self._ui_files @property + def uic_options(self): + return self._uic_options + + @property def qrc_files(self): return self._qrc_files @property + def rcc_options(self): + return self._rcc_options + + @property def qml_files(self): return self._qml_files diff --git a/sources/pyside-tools/project_lib/pyproject_parse_result.py b/sources/pyside-tools/project_lib/pyproject_parse_result.py index 6a04bf5ce..4c3264b52 100644 --- a/sources/pyside-tools/project_lib/pyproject_parse_result.py +++ b/sources/pyside-tools/project_lib/pyproject_parse_result.py @@ -8,3 +8,5 @@ from pathlib import Path class PyProjectParseResult: errors: list[str] = field(default_factory=list) files: list[Path] = field(default_factory=list) + rcc_options: list[str] = field(default_factory=list) + uic_options: list[str] = field(default_factory=list) diff --git a/sources/pyside-tools/project_lib/pyproject_toml.py b/sources/pyside-tools/project_lib/pyproject_toml.py index 6da7b455e..bc5a0f69d 100644 --- a/sources/pyside-tools/project_lib/pyproject_toml.py +++ b/sources/pyside-tools/project_lib/pyproject_toml.py @@ -91,11 +91,18 @@ def parse_pyproject_toml(pyproject_toml_file: Path) -> PyProjectParseResult: result.errors.append(str(e)) return result - pyside_table = root_table.get("tool", {}).get("pyside6-project", {}) + tool_entry = root_table.get("tool", {}) + pyside_table = tool_entry.get("pyside6-project", {}) if not pyside_table: result.errors.append("Missing [tool.pyside6-project] table") return result + if rcc_table := tool_entry.get("pyside6-rcc", {}): + result.rcc_options = rcc_table.get("options", []) + + if uic_table := tool_entry.get("pyside6-uic", {}): + result.uic_options = uic_table.get("options", []) + files = pyside_table.get("files", []) if not isinstance(files, list): result.errors.append("Missing or invalid files list") diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index f001178cc..bf04e04ed 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -336,8 +336,6 @@ <add-conversion type="SbkObject" file="../glue/qtcore.cpp" snippet="conversion-sbkobject"/> <add-conversion type="PyDict" check="PyDict_CheckExact(%in)" file="../glue/qtcore.cpp" snippet="conversion-pydict"/> <add-conversion type="PyList" check="PyList_Check(%in)" file="../glue/qtcore.cpp" snippet="conversion-pylist"/> - <add-conversion type="PyTuple" check="PyTuple_CheckExact(%in)" - file="../glue/qtcore.cpp" snippet="conversion-pylist"/> <add-conversion type="PyObject" file="../glue/qtcore.cpp" snippet="conversion-pyobject"/> </target-to-native> </conversion-rule> diff --git a/sources/pyside6/doc/tools/pyside-project.rst b/sources/pyside6/doc/tools/pyside-project.rst index c6913f363..41b5bc9af 100644 --- a/sources/pyside6/doc/tools/pyside-project.rst +++ b/sources/pyside6/doc/tools/pyside-project.rst @@ -34,6 +34,17 @@ files are listed in the ``tool.pyside6-project`` table. For example: [tool.pyside6-project] files = ["main.py", "main_window.py"] +It is also possible to specify options for the :ref:`pyside6-rcc` and +:ref:`pyside6-uic` tools: + +.. code-block:: toml + + [tool.pyside6-rcc] + options = ["--compress-algo", "zlib"] + + [tool.pyside6-uic] + options = [" --star-imports"] + More information about the ``pyproject.toml`` file format can be found in `Python Packaging User Guide specification: "Writing your pyproject.toml"`_. diff --git a/sources/pyside6/tests/QtCore/qobject_property_test.py b/sources/pyside6/tests/QtCore/qobject_property_test.py index 9d2bd2c56..e0a8044fe 100644 --- a/sources/pyside6/tests/QtCore/qobject_property_test.py +++ b/sources/pyside6/tests/QtCore/qobject_property_test.py @@ -106,9 +106,10 @@ class QObjectWithOtherClassPropertyTest(unittest.TestCase): class VariantPropertyTest(unittest.TestCase): - """Test QVariant conversion in properties and signals (PYSIDE-3206, PYSIDE-3244). - It uses a property of list type that is passed a QVariantList - with various element types when using QObject.setProperty().""" + """Test QVariant conversion in properties and signals (PYSIDE-3256, + PYSIDE-3244, PYSIDE-3206 [open]). It uses a property of list type + that is passed a QVariantList with various element types when + using QObject.setProperty().""" def testIt(self): to = TestVariantPropertyObject() @@ -123,11 +124,11 @@ class VariantPropertyTest(unittest.TestCase): to.setProperty("testProperty", [{"key": 42}]) self.assertEqual(type(to.get_property()[0]), dict) - # PYSIDE-3206 (DBus): Convert a tuple to a list + # Tuple (PYSIDE-3256) to.setProperty("testProperty", [(1, 2)]) - self.assertEqual(type(to.get_property()[0]), list) + self.assertEqual(type(to.get_property()[0]), tuple) - # PYSIDE-324: The tuple conversion must not occur for named tuples + # Named Tuple (PYSIDE-3244) to.setProperty("testProperty", [Point(1, 2)]) self.assertEqual(type(to.get_property()[0]), Point) |
