@@ -11,7 +11,6 @@ Instead, use one of the tools listed
1111[ here] ( https://docs.python.org/3/using/android.html ) , which will provide a much
1212easier experience.
1313
14-
1514## Prerequisites
1615
1716If you already have an Android SDK installed, export the ` ANDROID_HOME `
2524 ` android-sdk/cmdline-tools/latest ` .
2625* ` export ANDROID_HOME=/path/to/android-sdk `
2726
28- The ` android.py ` script will automatically use the SDK's ` sdkmanager ` to install
27+ The ` Platforms/Android ` script will automatically use the SDK's ` sdkmanager ` to install
2928any packages it needs.
3029
3130The script also requires the following commands to be on the ` PATH ` :
3231
3332* ` curl `
3433* ` java ` (or set the ` JAVA_HOME ` environment variable)
3534
36-
3735## Building
3836
3937Python can be built for Android on any POSIX platform supported by the Android
@@ -43,29 +41,28 @@ First we'll make a "build" Python (for your development machine), then use it to
4341help produce a "host" Python for Android. So make sure you have all the usual
4442tools and libraries needed to build Python for your development machine.
4543
46- The easiest way to do a build is to use the ` android.py ` script. You can either
44+ The easiest way to do a build is to use the ` Platforms/Android ` script. You can either
4745have it perform the entire build process from start to finish in one step, or
4846you can do it in discrete steps that mirror running ` configure ` and ` make ` for
4947each of the two builds of Python you end up producing.
5048
51- The discrete steps for building via ` android.py ` are:
49+ The discrete steps for building via ` Platforms/Android ` are:
5250
5351``` sh
54- ./android.py configure-build
55- ./android.py make-build
56- ./android.py configure-host HOST
57- ./android.py make-host HOST
52+ python3 Platforms/Android configure-build
53+ python3 Platforms/Android make-build
54+ python3 Platforms/Android configure-host HOST
55+ python3 Platforms/Android make-host HOST
5856```
5957
6058` HOST ` identifies which architecture to build. To see the possible values, run
61- ` ./android.py configure-host --help` .
59+ ` python3 Platforms/Android configure-host --help` .
6260
6361To do all steps in a single command, run:
6462
6563``` sh
66- ./android.py build HOST
64+ python3 Platforms/Android build HOST
6765```
68-
6966In the end you should have a build Python in ` cross-build/build ` , and a host
7067Python in ` cross-build/HOST ` .
7168
@@ -75,25 +72,23 @@ call. For example, if you want a pydebug build that also caches the results from
7572` configure ` , you can do:
7673
7774``` sh
78- ./android.py build HOST -- -C --with-pydebug
75+ python3 Platforms/Android build HOST -- -C --with-pydebug
7976```
8077
81-
8278## Packaging
8379
8480After building an architecture as described in the section above, you can
8581package it for release with this command:
8682
8783``` sh
88- ./android.py package HOST
84+ python3 Platforms/Android package HOST
8985```
9086
9187` HOST ` is defined in the section above.
9288
9389This will generate a tarball in ` cross-build/HOST/dist ` , whose structure is
9490similar to the ` Android ` directory of the CPython source tree.
9591
96-
9792## Testing
9893
9994The Python test suite can be run on Linux, macOS, or Windows.
@@ -103,14 +98,10 @@ require adding your user to a group, or changing your udev rules. On GitHub
10398Actions, the test script will do this automatically using the commands shown
10499[ here] ( https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/ ) .
105100
106- You can run the test suite either:
107-
108- * Within the CPython repository, after doing a build as described above. On
109- Windows, you won't be able to do the build on the same machine, so you'll have
110- to copy the ` cross-build/HOST/prefix ` directory from somewhere else.
111-
112- * Or by taking a release package built using the ` package ` command, extracting
113- it wherever you want, and using its own copy of ` android.py ` .
101+ You can run the test suite by doing a build as described above, and then running
102+ ` python3 Platforms/Android test ` . On Windows, you won't be able to do the build
103+ on the same machine, so you'll have to copy the ` cross-build/HOST/prefix ` directory
104+ from somewhere else.
114105
115106The test script supports the following modes:
116107
@@ -120,7 +111,7 @@ The test script supports the following modes:
120111 script like this:
121112
122113 ``` sh
123- ./android.py test --connected emulator-5554
114+ python3 Platforms/Android test --connected emulator-5554
124115 ```
125116
126117* In ` --managed ` mode, it uses a temporary headless emulator defined in the
@@ -131,29 +122,47 @@ The test script supports the following modes:
131122 to our minimum and maximum supported Android versions. For example:
132123
133124 ``` sh
134- ./android.py test --managed maxVersion
125+ python3 Platforms/Android test --managed maxVersion
135126 ```
136127
137128By default, the only messages the script will show are Python's own stdout and
138129stderr. Add the ` -v ` option to also show Gradle output, and non-Python logcat
139130messages.
140131
141- Any other arguments on the ` android.py test` command line will be passed through
142- to ` python -m test ` – use ` -- ` to separate them from android.py 's own options.
132+ Any other arguments on the ` Platforms/Android test` command line will be passed through
133+ to ` python -m test ` – use ` -- ` to separate them from ` Platforms/Android ` 's own options.
143134See the [ Python Developer's
144135Guide] ( https://devguide.python.org/testing/run-write-tests/ ) for common options
145136– most of them will work on Android, except for those that involve subprocesses,
146137such as ` -j ` .
147138
148- Every time you run ` android.py test` , changes in pure-Python files in the
139+ Every time you run ` python3 Platforms/Android test` , changes in pure-Python files in the
149140repository's ` Lib ` directory will be picked up immediately. Changes in C files,
150141and architecture-specific files such as sysconfigdata, will not take effect
151- until you re-run ` android.py make-host ` or ` build ` .
142+ until you re-run ` python3 Platforms/Android make-host ` or ` build ` .
143+
144+ ### Testing a third-party package
145+
146+ The ` Platforms/Android ` script is also included as ` android.py ` in the root of a
147+ release package (i.e., the one built using ` Platforms/Android package ` ).
148+
149+ You can use this script to test third-party packages by taking a release
150+ package, extracting it wherever you want, and using the ` android.py ` script to
151+ run the test suite for your third-party package.
152+
153+ Any argument that can be passed to ` python3 Platforms/Android test ` can also be
154+ passed to ` android.py ` . The following options will be of particular use when
155+ configuring the execution of a third-party test suite:
156+
157+ * ` --cwd ` : the directory of content to copy into the testbed app as the working
158+ directory.
159+ * ` --site-packages ` : the directory to copy into the testbed app to use as site
160+ packages.
152161
153- The testbed app can also be used to test third-party packages. For more details,
154- run ` android.py test --help ` , paying attention to the options ` --site-packages ` ,
155- ` --cwd ` , ` -c ` and ` -m ` .
162+ The arguments passed after ` -- ` should also include either a ` -c ` or ` -m `
163+ argument to specify how the test suite should be started.
156164
165+ For more details, run ` android.py test --help ` .
157166
158167## Using in your own app
159168
0 commit comments