Skip to content

Commit 35118f4

Browse files
committed
Add Qt boostrap to docs
- update the docs to include sections depicting the Qt boostrap.
1 parent 4f746d1 commit 35118f4

File tree

3 files changed

+59
-16
lines changed

3 files changed

+59
-16
lines changed

doc/source/buildoptions.rst

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ options (this list may not be exhaustive):
6464
for the SDL bootstrap. If multiple orientations are given,
6565
``android:screenOrientation`` will be set to ``unspecified``.
6666
- ``--manifest-orientation``: The orientation that will be set for the ``android:screenOrientation``
67-
attribute of the activity in the ``AndroidManifest.xml`` file. If not set, the value
67+
attribute of the activity in the ``AndroidManifest.xml`` file. If not set, the value
6868
will be synthesized from the ``--orientation`` option.
6969
The full list of valid options is given under ``android:screenOrientation``
7070
in the `Android documentation <https://developer.android.com/guide/topics/manifest/activity-element.html>`__.
@@ -74,11 +74,11 @@ options (this list may not be exhaustive):
7474
``--home-app`` Gives you the option to set your application as a home app (launcher) on your Android device.
7575

7676
.. Note ::
77-
``--permission`` accepts the following syntaxes:
77+
``--permission`` accepts the following syntaxes:
7878
``--permission (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)``
7979
or ``--permission android.permission.WRITE_EXTERNAL_STORAGE``.
8080
81-
The first syntax is used to set additional properties to the permission
81+
The first syntax is used to set additional properties to the permission
8282
(``android:maxSdkVersion`` and ``android:usesPermissionFlags`` are the only ones supported for now).
8383
8484
The second one can be used when there's no need to add any additional properties.
@@ -148,7 +148,7 @@ ready.
148148
(Which is the default on Android 12+), this setting is not guaranteed to work, and
149149
you should consider to implement a custom orientation change handler in your app.
150150
- ``--manifest-orientation``: The orientation that will be set in the ``android:screenOrientation``
151-
attribute of the activity in the ``AndroidManifest.xml`` file. If not set, the value
151+
attribute of the activity in the ``AndroidManifest.xml`` file. If not set, the value
152152
will be synthesized from the ``--orientation`` option.
153153
The full list of valid options is given under ``android:screenOrientation``
154154
in the `Android documentation <https://developer.android.com/guide/topics/manifest/activity-element.html>`__.
@@ -187,7 +187,7 @@ You can use this with ``--bootstrap=service_library`` option.
187187

188188

189189
This bootstrap can be used together with ``aar`` output target to generate
190-
a library, containing Python services that can be used with other build
190+
a library, containing Python services that can be used with other build
191191
systems and frameworks.
192192

193193
- ``--private``: The directory containing your project files.
@@ -204,6 +204,49 @@ systems and frameworks.
204204
include multiple jar files, pass this argument multiple times.
205205
- ``add-source``: Add a source directory to the app's Java code.
206206

207+
Qt
208+
~~
209+
210+
This bootstrap can be used with ``--bootstrap=qt`` or by including the ``PySide6`` or
211+
``shiboken6`` recipe, e.g. ``--requirements=PySide6,shiboken6``. Currently, the only way
212+
to use this bootstrap is through `pyside6-android-deploy <https://www.qt.io/blog/taking-qt-for-python-to-android>`__
213+
tool shipped with ``PySide6``, as the recipes for ``PySide6`` and ``shiboken6`` are created
214+
dynamically. The tool builds ``PySide6`` and ``shiboken6`` wheels for a specific Android platform
215+
and the recipes simply unpack the built wheels. You can see the recipes `here <https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside-tools/deploy_lib/android/recipes>`__.
216+
217+
.. note::
218+
The ``pyside6-android-deploy`` tool and hence the Qt bootstrap does not support multi-architecture
219+
builds currently.
220+
221+
What are Qt and PySide?
222+
%%%%%%%%%%%%%%%%%%%%%%%%
223+
224+
`Qt <https://www.qt.io/>`__ is a popularly used cross-platform C++ framewrok for developing
225+
GUI applications. `PySide6 <https://doc.qt.io/qtforpython-6/quickstart.html>`__ refers to the
226+
Python bindings for Qt6, and enables the Python developers access to the Qt6 API.
227+
`Shiboken6 <https://doc.qt.io/qtforpython-6/shiboken6/index.html>`__ is the binding generator
228+
tool used for generating the Python bindings from C++ code.
229+
230+
.. note:: The `shiboken6` recipe is for the `Shiboken Python module <https://doc.qt.io/qtforpython-6/shiboken6/shibokenmodule.html>`__
231+
which includes a couple of utility functions for inspecting and debugging PySide6 code.
232+
233+
Build Options
234+
%%%%%%%%%%%%%
235+
236+
``pyside6-android-deploy`` works by generating a ``buildozer.spec`` file and thereby using
237+
`buildozer <https://buildozer.readthedocs.io/en/latest/>`__ to control the build options used by
238+
``python-for-android`` with the Qt bootstrap. Apart from the general build options that works
239+
across all the other bootstraps, the Qt bootstrap introduces the following 3 new build options.
240+
241+
- ``--qt-libs``: list of Qt libraries(modules) to be loaded.
242+
- ``--load-local-libs``: list of Qt plugin libraries to be loaded.
243+
- ``--init-classes``: list of Java class names to the loaded from the Qt jar files supplied through
244+
the ``--add-jar`` option.
245+
246+
These build options are automatically populated by the ``pyside6-android-deploy`` tool, but can be
247+
modified by updating the ``buildozer.spec`` file. Apart from the above 3 build options, the tool
248+
also automatically identifies the values to be fed into the cli options ``--permission``, ``--add-jar``
249+
depending on the PySide6 modules used by the applicaiton.
207250

208251
Requirements blacklist (APK size optimization)
209252
----------------------------------------------

doc/source/commands.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ behaviour, though not all commands make use of them.
2626

2727
``--debug``
2828
Print extra debug information about the build, including all compilation output.
29-
29+
3030
``--sdk_dir``
3131
The filepath where the Android SDK is installed. This can
3232
alternatively be set in several other ways.
3333

3434
``--android_api``
3535
The Android API level to target; python-for-android will check if
3636
the platform tools for this level are installed.
37-
37+
3838
``--ndk_dir``
3939
The filepath where the Android NDK is installed. This can
4040
alternatively be set in several other ways.
@@ -62,7 +62,7 @@ supply those that you need.
6262
``--name NAME``
6363
The name of the distribution. Only one distribution with a given name can be created.
6464

65-
``--requirements LIST,OF,REQUIREMENTS``
65+
``--requirements LIST,OF,REQUIREMENTS``
6666
The recipes that your
6767
distribution must contain, as a comma separated list. These must be
6868
names of recipes or the pypi names of Python modules.
@@ -74,12 +74,12 @@ supply those that you need.
7474
The architecture to build for. You can specify multiple architectures to build for
7575
at the same time. As an example ``p4a ... --arch arm64-v8a --arch armeabi-v7a ...``
7676
will build a distribution for both ``arm64-v8a`` and ``armeabi-v7a``.
77-
77+
7878
``--bootstrap BOOTSTRAP``
7979
The Java bootstrap to use for your application. You mostly don't
8080
need to worry about this or set it manually, as an appropriate
8181
bootstrap will be chosen from your ``--requirements``. Current
82-
choices are ``sdl2`` (used with Kivy and most other apps) or ``webview``.
82+
choices are ``sdl2`` (used with Kivy and most other apps), ``webview`` or ``qt``.
8383

8484

8585
.. note:: These options are preliminary. Others will include toggles

doc/source/quickstart.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Concepts
2626

2727
- **bootstrap:** A bootstrap is the app backend that will start your
2828
application. The default for graphical applications is SDL2.
29-
You can also use e.g. the webview for web apps, or service_only/service_library for
30-
background services. Different bootstraps have different additional
29+
You can also use e.g. the webview for web apps, or service_only/service_library for
30+
background services, or qt for PySide6 apps. Different bootstraps have different additional
3131
build options.
3232

3333
*Advanced:*
@@ -114,7 +114,7 @@ You need to download and unpack the Android SDK and NDK to a directory (let's sa
114114
For the Android SDK, you can download 'just the command line
115115
tools'. When you have extracted these you'll see only a directory
116116
named ``tools``, and you will need to run extra commands to install
117-
the SDK packages needed.
117+
the SDK packages needed.
118118

119119
For Android NDK, note that modern releases will only work on a 64-bit
120120
operating system. **The minimal, and recommended, NDK version to use is r25b:**
@@ -214,7 +214,7 @@ website. The default for Flask is 5000.
214214
Build a Service library archive
215215
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216216

217-
To build an android archive (.aar), containing an android service , you need a name, version, package identifier, explicitly use the
217+
To build an android archive (.aar), containing an android service , you need a name, version, package identifier, explicitly use the
218218
service_library bootstrap, and declare service entry point (See :ref:`services <arbitrary_scripts_services>` for more options), as well as the requirements and arch(s)::
219219

220220
p4a aar --private $HOME/code/myapp --package=org.example.myapp --name "My library" --version 0.1 --bootstrap=service_library --requirements=python3 --release --service=myservice:service.py --arch=arm64-v8a --arch=armeabi-v7a
@@ -281,7 +281,7 @@ Recipe management
281281
You can see the list of the available recipes with::
282282

283283
p4a recipes
284-
284+
285285
If you are contributing to p4a and want to test a recipes again,
286286
you need to clean the build and rebuild your distribution::
287287

@@ -295,7 +295,7 @@ it (edit the ``__init__.py``)::
295295

296296
mkdir -p p4a-recipes/myrecipe
297297
touch p4a-recipes/myrecipe/__init__.py
298-
298+
299299

300300
Distribution management
301301
~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)