@@ -4,44 +4,74 @@ pyside6-project
4
4
===============
5
5
6
6
`pyside6-project ` is a command line tool for creating, building and deploying
7
- |project | applications. It operates on a project file which is also used by
8
- `Qt Creator `_.
7
+ |project | applications. It operates on project files which are also supported
8
+ by `Qt Creator `_.
9
9
10
- Project file format
11
- -------------------
10
+ A project file contains a list of the source files used in the project. Typically they are
11
+ ``.py ``, ``.qml ``, ``.qrc ``, ``.ts ``, or ``.ui `` files. It can also include other subproject files.
12
+ Generated files such as compiled resources or compiled translations should not be included in the
13
+ project file.
12
14
13
- The project file format is a simple `JSON `_-based format with the suffix
14
- ``.pyproject `` listing all files of the project excluding generated files
15
- (typically ``.py ``, ``.qml ``, ``.qrc ``, ``.ts ``, or ``.ui `` files):
15
+ Currently, two project file formats are supported. Since PySide6 version 6.9.0, the ``*.pyproject ``
16
+ file format is deprecated in favor of the new ``pyproject.toml `` file format. The ``*.pyproject ``
17
+ file format is still supported for backward compatibility, but it is recommended to migrate to the
18
+ new ``pyproject.toml `` file format. See
19
+ :ref: `Migrating from *.pyproject to pyproject.toml<migrating_from_pyproject_to_pyproject_toml> `
20
+ for more information.
21
+
22
+ ``pyproject.toml ``
23
+ ------------------
24
+
25
+ PySide6 version 6.9.0 added support for the new Python standard ``pyproject.toml `` project file
26
+ format. It is intended to replace the deprecated ``*.pyproject `` file format. The project source
27
+ files are listed in the ``tool.pyside6-project `` table. For example:
28
+
29
+ .. code-block :: toml
30
+
31
+ [project]
32
+ name = "myproject"
33
+
34
+ [tool.pyside6-project]
35
+ files = ["main.py", "main_window.py"]
36
+
37
+ More information about the ``pyproject.toml `` file format can be found in
38
+ `Python Packaging User Guide specification: "Writing your pyproject.toml" `_.
39
+
40
+ ``*.pyproject ``
41
+ ---------------
42
+
43
+ The deprecated ``*.pyproject `` project file uses a simple `JSON `_-based format. The source files
44
+ are listed in the ``files `` array of the JSON root object. For example:
16
45
17
46
.. code-block :: json
18
47
19
48
{
20
- "files" : [" main.py" ]
49
+ "files" : [" main.py" , " main_window.py " ]
21
50
}
22
51
23
-
24
52
Usage
25
53
-----
26
54
27
55
The tool has several subcommands. New projects can be created using
28
56
the below commands, passing the project name (directory):
29
57
30
58
*new-ui *
31
- Creates a new QtWidgets project with a *Qt Widgets Designer *-based main
32
- window.
59
+ Creates a new QtWidgets project with a *Qt Widgets Designer *-based main window.
33
60
34
61
*new-widget *
35
62
Creates a new QtWidgets project with a main window.
36
63
37
64
*new-quick *
38
65
Creates a new QtQuick project.
39
66
40
- The other commands take the project file as an argument.
67
+ Using the optional ``--legacy-pyproject `` flag, the tool will create a legacy ``.pyproject `` file
68
+ instead of a ``pyproject.toml `` file.
69
+
70
+ The following commands can receive a project file as an optional argument.
41
71
It is also possible to specify a directory containing the project file.
42
72
43
73
*build *
44
- Builds the project, generating the required build artifacts
74
+ Builds the project. Compiles resources, UI files, and QML files if existing and necessary.
45
75
(see :ref: `tutorial_uifiles `, :ref: `tutorial_qrcfiles `).
46
76
47
77
*run *
@@ -54,11 +84,65 @@ It is also possible to specify a directory containing the project file.
54
84
Updates translation (.ts) files (see :ref: `tutorial_translations `).
55
85
56
86
*clean *
57
- Cleans the build artifacts.
87
+ Cleans the build artifacts. For example, compiled resources.
58
88
59
89
*qmllint *
60
90
Runs the ``qmllint `` tool, checking the QML files.
61
91
92
+ *migrate-pyproject *
93
+ Migrates the content of one or more ``*.pyproject `` files to a ``pyproject.toml `` file.
94
+ See :ref: `Migrating from *.pyproject to pyproject.toml <migrating_from_pyproject_to_pyproject_toml >`.
95
+
96
+ Considerations
97
+ --------------
98
+
99
+ For each file entry in the project files, ``pyside6-project `` does the following:
100
+
101
+ * ``<other project file> ``: Recursively handle subproject
102
+ * ``<name>.qrc ``: Runs the resource compiler to create a file rc_<name>.py
103
+ * ``<name>.ui ``: Runs the user interface compiler to create a file ui_<name>.py
104
+
105
+ For a Python file declaring a QML module, a directory matching the URI is
106
+ created and populated with .qmltypes and qmldir files for use by code analysis
107
+ tools. Currently, only one QML module consisting of several classes can be
108
+ handled per project file.
109
+
110
+ .. _migrating_from_pyproject_to_pyproject_toml :
111
+
112
+ Migrating from ``*.pyproject `` to ``pyproject.toml ``
113
+ ----------------------------------------------------
114
+
115
+ Since PySide6 6.9.0, ``pyside6-project `` tool can create a new ``pyproject.toml `` file or update an
116
+ existing one with the existing ``*.pyproject `` file content. To migrate an existing project, run
117
+ ``pyside6-project `` command with the ``migrate-pyproject `` argument. For example:
118
+
119
+ .. code-block :: bash
120
+
121
+ pyside6-project migrate-pyproject
122
+
123
+ If no file is specified, the tool will read the ``*.pyproject `` files in the current working
124
+ directory. In the case of having multiple ``*.pyproject `` files in the same directory, its contents
125
+ will be merged. A new ``pyproject.toml `` file will be created if not existing. If the file already
126
+ exists, a confirmation message is displayed to the user asking for confirmation before
127
+ updating the file with the new content. For example:
128
+
129
+ .. code-block :: bash
130
+
131
+ mkdir myproject
132
+ cd myproject
133
+ echo {" files" : [" main.py" , " my_widget.py" ]} > myproject.pyproject
134
+ pyside6-project migrate-pyproject
135
+
136
+ Generated pyproject.toml file:
137
+
138
+ .. code-block :: toml
139
+
140
+ [project]
141
+ name = "myproject"
142
+
143
+ [tool.pyside6-project]
144
+ files = ["main.py", "my_widget.py"]
62
145
63
146
.. _`Qt Creator` : https://www.qt.io/product/development-tools
147
+ .. _`Python Packaging User Guide specification: "Writing your pyproject.toml"` : https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
64
148
.. _`JSON` : https://www.json.org/
0 commit comments