Skip to content

Commit

Permalink
Make pkgtest app default to the newest Chaquopy version on Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Sep 4, 2023
1 parent e09bbe6 commit b9c908d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
23 changes: 10 additions & 13 deletions server/pypi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 14 additions & 2 deletions server/pypi/pkgtest/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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, [])
Expand Down
12 changes: 9 additions & 3 deletions server/pypi/pkgtest/build.gradle
Original file line number Diff line number Diff line change
@@ -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 ?: "+")
}
}

Expand Down

0 comments on commit b9c908d

Please sign in to comment.