From b9c908d9aa86b9415d7c93b2955572fae76c3db0 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Mon, 4 Sep 2023 10:08:57 +0100 Subject: [PATCH] Make pkgtest app default to the newest Chaquopy version on Maven Central --- server/pypi/README.md | 23 ++++++++++------------- server/pypi/pkgtest/app/build.gradle | 16 ++++++++++++++-- server/pypi/pkgtest/build.gradle | 12 +++++++++--- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/server/pypi/README.md b/server/pypi/README.md index 9f6908c3c3..5dd0e19e9d 100644 --- a/server/pypi/README.md +++ b/server/pypi/README.md @@ -139,18 +139,15 @@ how to use it. First, create a `test.py` file in the recipe directory, or a `test` subdirectory with an `__init__.py` if you need to include additional files. This should contain a `TestCase` -class which imports the package and does some basic checks. See the existing recipes for -examples. - -Open the pkgtest app in Android Studio, and temporarily edit it as follows: - -* In `build.gradle`: - * Use the current stable Chaquopy version, unless the package depends on changes in the - development version. -* In `app/build.gradle`: - * List the package in the `addPackages` line. - * Change the Python `version` setting if necessary. - * Set the `--extra-index-url` as described above. - * Set `abiFilters` to the ABIs you've built .whl files for. +class which does some basic checks on the package. See the existing recipes for +examples: usually we base them on the package's own tutorial. + +Open the pkgtest app in Android Studio, and temporarily edit `app/build.gradle` as +follows: + +* Add the package to the `addPackages` line, e.g. `addPackages(delegate, ["package-name"])`. +* Set `python { version }` to the Python version you want to test. +* Set the `--extra-index-url` as described above. +* Set `abiFilters` to the ABIs you want to test. Then run the app. diff --git a/server/pypi/pkgtest/app/build.gradle b/server/pypi/pkgtest/app/build.gradle index 308a7b9994..b50c38b064 100644 --- a/server/pypi/pkgtest/app/build.gradle +++ b/server/pypi/pkgtest/app/build.gradle @@ -60,8 +60,20 @@ android { minSdk = 21 targetSdk = 33 - versionName rootProject.version - def verParsed = rootProject.version.split(/\./).collect { Integer.parseInt(it) } + String pluginVersion = null + for (art in rootProject.buildscript.configurations.getByName("classpath") + .resolvedConfiguration.resolvedArtifacts) { + def dep = art.moduleVersion.id + if (dep.group == "com.chaquo.python" && dep.name == "gradle") { + pluginVersion = dep.version + } + } + if (pluginVersion == null) { + throw new GradleException("Couldn't find Chaquopy plugin") + } + + versionName pluginVersion + def verParsed = versionName.split(/\./).collect { Integer.parseInt(it) } versionCode ((verParsed[0] * 1000000) + (verParsed[1] * 1000) + (verParsed[2] * 10)) addPackages(delegate, []) diff --git a/server/pypi/pkgtest/build.gradle b/server/pypi/pkgtest/build.gradle index 5f86b4513b..d7d5f3a824 100644 --- a/server/pypi/pkgtest/build.gradle +++ b/server/pypi/pkgtest/build.gradle @@ -1,16 +1,22 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - version = file("../../../VERSION.txt").text.trim() + // If null, the newest version on Maven Central will be used. + String chaquopyVersion = null + + // Uncomment to use the local development version. + // chaquopyVersion = file("../../../VERSION.txt").text.trim() repositories { - maven { url "../../../maven" } + if (chaquopyVersion != null) { + maven { url "../../../maven" } + } google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.1.1' - classpath "com.chaquo.python:gradle:$version" + classpath "com.chaquo.python:gradle:" + (chaquopyVersion ?: "+") } }