diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-09-08 11:50:21 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-09-08 21:39:02 +0200 |
commit | 9bca4e6c1d2a1a374dee704c33e1b8f6ab337f61 (patch) | |
tree | a590b37f31e36bfa6518b96a56082b82c306b2a2 /sources/pyside-tools | |
parent | bd579d1c74e965ee74e455fa23cec8174d946e11 (diff) |
Android Deployment: auto download the required Android NDK and SDK
- Enable automatic download of Android NDK and SDK for creating
Android PySide6 and shiboken6 wheels. Earlier, the user was
required to manually download it and supply as a command line
argument.
- They are downloaded into the HOME directory of the user into the
folder .pyside6_android_deploy. This is also similar to buildozer
which downloads them into .buildozer.
- The downloaded NDK is set to r25c, same as buildozer. The latest
Android SDK packages are downloaded.
- For the deployment tool, incase the NDK and SDK path are not
provided either through the command line or through the configuration
.spec file, the it will look for the NDK and SDK inside
.pyside6_android_deploy, before falling back to the default Android
NDK and SDK that buildozer supplies. buildozer will download them.
- As a addition, a small code rearranging is also done, along with
changing the deprecated subprocess.call() to subprocess.run().
Task-number: PYSIDE-1612
Change-Id: Ie8d51f8c7634b5b320b1dce2d4164985cbfbaaca
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools')
-rw-r--r-- | sources/pyside-tools/android_deploy.py | 5 | ||||
-rw-r--r-- | sources/pyside-tools/deploy_lib/config.py | 24 |
2 files changed, 24 insertions, 5 deletions
diff --git a/sources/pyside-tools/android_deploy.py b/sources/pyside-tools/android_deploy.py index f10834c12..fbc613069 100644 --- a/sources/pyside-tools/android_deploy.py +++ b/sources/pyside-tools/android_deploy.py @@ -237,14 +237,13 @@ if __name__ == "__main__": help=f"Path to shiboken{MAJOR_VERSION} Android Wheel", required=not config_option_exists()) - #TODO: --ndk-path and --sdk-path will be removed when automatic download of sdk and ndk is added parser.add_argument("--ndk-path", type=lambda p: Path(p).resolve(), help=("Path to Android Ndk. If omitted, the default from buildozer is used") - , required=True) + ) parser.add_argument("--sdk-path", type=lambda p: Path(p).resolve(), help=("Path to Android Sdk. If omitted, the default from buildozer is used") - , required=True) + ) parser.add_argument("--extra-ignore-dirs", type=str, help=HELP_EXTRA_IGNORE_DIRS) diff --git a/sources/pyside-tools/deploy_lib/config.py b/sources/pyside-tools/deploy_lib/config.py index af019a093..8af341bad 100644 --- a/sources/pyside-tools/deploy_lib/config.py +++ b/sources/pyside-tools/deploy_lib/config.py @@ -12,6 +12,9 @@ from .commands import run_qmlimportscanner # Some QML plugins like QtCore are excluded from this list as they don't contribute much to # executable size. Excluding them saves the extra processing of checking for them in files EXCLUDED_QML_PLUGINS = {"QtQuick", "QtQuick3D", "QtCharts", "QtWebEngine", "QtTest", "QtSensors"} +# TODO: Move this to android module. Fix circular import. +ANDROID_NDK_VERSION = "25c" +ANDROID_DEPLOY_CACHE = Path.home() / ".pyside6_android_deploy" class BaseConfig: @@ -128,13 +131,30 @@ class Config(BaseConfig): self.ndk_path = android_data.ndk_path else: ndk_path_temp = self.get_value("buildozer", "ndk_path") - self.ndk_path = Path(ndk_path_temp) if ndk_path_temp else None + if ndk_path_temp: + self.ndk_path = Path(ndk_path_temp) + else: + self.ndk_path = (ANDROID_DEPLOY_CACHE / "android-ndk" + / f"android-ndk-r{ANDROID_NDK_VERSION}") + if not self.ndk_path.exists(): + logging.info("[DEPLOY] Use default NDK from buildoer") + + if self.ndk_path: + print(f"Using Android NDK: {str(self.ndk_path)}") if android_data.sdk_path: self.sdk_path = android_data.sdk_path else: sdk_path_temp = self.get_value("buildozer", "sdk_path") - self.sdk_path = Path(sdk_path_temp) if sdk_path_temp else None + if sdk_path_temp: + self.sdk_path = Path(sdk_path_temp) + else: + self.sdk_path = ANDROID_DEPLOY_CACHE / "android-sdk" + if not self.sdk_path.exists(): + logging.info("[DEPLOY] Use default SDK from buildozer") + + if self.sdk_path: + print(f"Using Android SDK: {str(self.sdk_path)}") recipe_dir_temp = self.get_value("buildozer", "recipe_dir") self.recipe_dir = Path(recipe_dir_temp) if recipe_dir_temp else None |