-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for PySide6 and Qt bootstrap (#2918)
* Initial support for PySide6 - Add a new bootstrap for Qt - This bootstrap will be used by `pyside6-android-deploy` tool shipped with PySide6, which interally calls pythonforandroid using buildozer. - The Qt bootstrap depends on recipes PySide6 and shiboken6 among other mandatory recipes. The recipes for PySide6 and shiboken6 resides in the PySide repository - https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside-tools/deploy_lib/android/recipes - The PythonActivity entrypoint class is derived from QtActivity class which is the main acitivty class when a Qt C++ application is packaged for Android. The jar containing QtActivity class is supplied through buildozer `android.add_jars` option. - The C wrapper binary to the application main.py is named as `main_{abi_name}` instead of just `main` for other bootstraps. - Multi architecture deployment is not supported at the moment. - Adapt tests based on the new Qt bootstrap * Add Qt boostrap to docs - update the docs to include sections depicting the Qt boostrap. * Tweak gradle build properties for Qt bootstrap - Sometimes a flaky Java heap out of memory error is throw. By, tweaking the memory setting we can get rid of that error. * Fix bug - check for main.py - Qt boostrap removed from comparison in the changed line because its expects a value is args.launcher, which is not applicable for Qt boostrap. Hence, it exits with an value not found exception. - Removing Qt boostrap from the comparison leads to checking for main.py or --private, which is to be done for the Qt boostrap. * Make --init-classes truly optional - check if empty, otherwise store empty string * Add a non-gui test app build to CI that uses Qt bootstrap - for the purpose of testing, the pyside6 and shiboken6 wheels, the extra .jar files needed and the recipes for pyside6 and shiboken6 are manually added into testapps/on_device_unit_tests/test_qt. These files are normally generated by the `pyside6-android-deploy` tool that is shipped with PySide. Generating the wheels and the .jar files belongs to the scope of PySide and not python-for-android. Hence, they are not done here. This also reduces the load on the CI which will otherwise have to cross-compile CPython and PySide. - The Android aarch64 wheels for testing are downloaded from Qt servers. These wheels are for testing purposes only and the download link will be updated when official PySide6 Android wheels are generated. - Tests were added in test_requirements.py so that when running the apk the current date and time are printed on the terminal. The tests also checks shiboken6 and PySide6 module imports. * Remove superfluous whitespace removal - This was introduced by a VSCode setting and is unrealated to this patch. Although this might be good, this has to be introduced through a different patch. - pyside6 recipe typo adapted in buildoptions.rst * Add aab generation to test app with Qt bootstrap * Fix typo in doc/source/buildoptions.rst Co-authored-by: Mirko Galimberti <me@mirkogalimberti.com> --------- Co-authored-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Co-authored-by: Mirko Galimberti <me@mirkogalimberti.com>
- Loading branch information
1 parent
66ba3e5
commit 75be018
Showing
34 changed files
with
819 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
pythonforandroid/bootstraps/common/build/templates/gradle.tmpl.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import sh | ||
from os.path import join | ||
from pythonforandroid.toolchain import ( | ||
Bootstrap, current_directory, info, info_main, shprint) | ||
from pythonforandroid.util import ensure_dir, rmdir | ||
|
||
|
||
class QtBootstrap(Bootstrap): | ||
name = 'qt' | ||
recipe_depends = ['python3', 'genericndkbuild', 'PySide6', 'shiboken6'] | ||
# this is needed because the recipes PySide6 and shiboken6 resides in the PySide Qt repository | ||
# - https://code.qt.io/cgit/pyside/pyside-setup.git/ | ||
# Without this some tests will error because it cannot find the recipes within pythonforandroid | ||
# repository | ||
can_be_chosen_automatically = False | ||
|
||
def assemble_distribution(self): | ||
info_main("# Creating Android project using Qt bootstrap") | ||
|
||
rmdir(self.dist_dir) | ||
info("Copying gradle build") | ||
shprint(sh.cp, '-r', self.build_dir, self.dist_dir) | ||
|
||
with current_directory(self.dist_dir): | ||
with open('local.properties', 'w') as fileh: | ||
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) | ||
|
||
arch = self.ctx.archs[0] | ||
if len(self.ctx.archs) > 1: | ||
raise ValueError("Trying to build for more than one arch. Qt bootstrap cannot handle that yet") | ||
|
||
info(f"Bootstrap running with arch {arch}") | ||
|
||
with current_directory(self.dist_dir): | ||
info("Copying Python distribution") | ||
|
||
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) | ||
self.distribute_aars(arch) | ||
self.distribute_javaclasses(self.ctx.javaclass_dir, | ||
dest_dir=join("src", "main", "java")) | ||
|
||
python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle') | ||
ensure_dir(python_bundle_dir) | ||
site_packages_dir = self.ctx.python_recipe.create_python_bundle( | ||
join(self.dist_dir, python_bundle_dir), arch) | ||
|
||
if not self.ctx.with_debug_symbols: | ||
self.strip_libraries(arch) | ||
self.fry_eggs(site_packages_dir) | ||
super().assemble_distribution() | ||
|
||
|
||
bootstrap = QtBootstrap() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.gradle | ||
/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 | ||
# gradle/wrapper/gradle-wrapper.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# prevent user to include invalid extensions | ||
*.apk | ||
*.aab | ||
*.apks | ||
*.pxd | ||
|
||
# eggs | ||
*.egg-info | ||
|
||
# unit test | ||
unittest/* | ||
|
||
# python config | ||
config/makesetup | ||
|
||
# unused encodings | ||
lib-dynload/*codec* | ||
encodings/cp*.pyo | ||
encodings/tis* | ||
encodings/shift* | ||
encodings/bz2* | ||
encodings/iso* | ||
encodings/undefined* | ||
encodings/johab* | ||
encodings/p* | ||
encodings/m* | ||
encodings/euc* | ||
encodings/k* | ||
encodings/unicode_internal* | ||
encodings/quo* | ||
encodings/gb* | ||
encodings/big5* | ||
encodings/hp* | ||
encodings/hz* | ||
|
||
# unused python modules | ||
bsddb/* | ||
wsgiref/* | ||
hotshot/* | ||
pydoc_data/* | ||
tty.pyo | ||
anydbm.pyo | ||
nturl2path.pyo | ||
LICENCE.txt | ||
macurl2path.pyo | ||
dummy_threading.pyo | ||
audiodev.pyo | ||
antigravity.pyo | ||
dumbdbm.pyo | ||
sndhdr.pyo | ||
__phello__.foo.pyo | ||
sunaudio.pyo | ||
os2emxpath.pyo | ||
multiprocessing/dummy* | ||
|
||
# unused binaries python modules | ||
lib-dynload/termios.so | ||
lib-dynload/_lsprof.so | ||
lib-dynload/*audioop.so | ||
lib-dynload/_hotshot.so | ||
lib-dynload/_heapq.so | ||
lib-dynload/_json.so | ||
lib-dynload/grp.so | ||
lib-dynload/resource.so | ||
lib-dynload/pyexpat.so | ||
lib-dynload/_ctypes_test.so | ||
lib-dynload/_testcapi.so | ||
|
||
# odd files | ||
plat-linux3/regen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# Uncomment this if you're using STL in your project | ||
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information | ||
# APP_STL := stlport_static | ||
|
||
# APP_ABI := armeabi armeabi-v7a x86 | ||
APP_ABI := $(ARCH) | ||
APP_PLATFORM := $(NDK_API) |
18 changes: 18 additions & 0 deletions
18
pythonforandroid/bootstraps/qt/build/jni/application/src/Android.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
|
||
LOCAL_MODULE := main_$(PREFERRED_ABI) | ||
|
||
# Add your application source files here... | ||
LOCAL_SRC_FILES := start.c | ||
|
||
LOCAL_CFLAGS += -I$(PYTHON_INCLUDE_ROOT) $(EXTRA_CFLAGS) | ||
|
||
LOCAL_SHARED_LIBRARIES := python_shared | ||
|
||
LOCAL_LDLIBS := -llog $(EXTRA_LDLIBS) | ||
|
||
LOCAL_LDFLAGS += -L$(PYTHON_LINK_ROOT) $(APPLICATION_ADDITIONAL_LDFLAGS) | ||
|
||
include $(BUILD_SHARED_LIBRARY) |
Oops, something went wrong.