summaryrefslogtreecommitdiffstats
path: root/Android/README.md
diff options
context:
space:
mode:
authorMalcolm Smith <smith@chaquo.com>2024-03-21 23:52:29 (GMT)
committerGitHub <noreply@github.com>2024-03-21 23:52:29 (GMT)
commit3ec57307e70ee6f42410e844d3399bbd598917ba (patch)
tree6a8a4241ab77eb831818110235cd67d6f1263bf1 /Android/README.md
parent50f9b0b1e0fb181875751cef951351ed007b6397 (diff)
downloadcpython-3ec57307e70ee6f42410e844d3399bbd598917ba.zip
cpython-3ec57307e70ee6f42410e844d3399bbd598917ba.tar.gz
cpython-3ec57307e70ee6f42410e844d3399bbd598917ba.tar.bz2
gh-71052: Add Android build script and instructions (#116426)
Diffstat (limited to 'Android/README.md')
-rw-r--r--Android/README.md64
1 files changed, 64 insertions, 0 deletions
diff --git a/Android/README.md b/Android/README.md
new file mode 100644
index 0000000..5ed186e
--- /dev/null
+++ b/Android/README.md
@@ -0,0 +1,64 @@
+# Python for Android
+
+These instructions are only needed if you're planning to compile Python for
+Android yourself. Most users should *not* need to do this. If you're looking to
+use Python on Android, one of the following tools will provide a much more
+approachable user experience:
+
+* [Briefcase](https://briefcase.readthedocs.io), from the BeeWare project
+* [Buildozer](https://buildozer.readthedocs.io), from the Kivy project
+* [Chaquopy](https://chaquo.com/chaquopy/)
+
+
+## Prerequisites
+
+Export the `ANDROID_HOME` environment variable to point at your Android SDK. If
+you don't already have the SDK, here's how to install it:
+
+* Download the "Command line tools" from <https://developer.android.com/studio>.
+* Create a directory `android-sdk/cmdline-tools`, and unzip the command line
+ tools package into it.
+* Rename `android-sdk/cmdline-tools/cmdline-tools` to
+ `android-sdk/cmdline-tools/latest`.
+* `export ANDROID_HOME=/path/to/android-sdk`
+
+
+## Building
+
+Building for Android requires doing a cross-build where you have a "build"
+Python to help produce an Android build of CPython. This procedure has been
+tested on Linux and macOS.
+
+The easiest way to do a build is to use the `android.py` script. You can either
+have it perform the entire build process from start to finish in one step, or
+you can do it in discrete steps that mirror running `configure` and `make` for
+each of the two builds of Python you end up producing.
+
+The discrete steps for building via `android.py` are:
+
+```sh
+./android.py configure-build
+./android.py make-build
+./android.py configure-host HOST
+./android.py make-host HOST
+```
+
+To see the possible values of HOST, run `./android.py configure-host --help`.
+
+Or to do it all in a single command, run:
+
+```sh
+./android.py build HOST
+```
+
+In the end you should have a build Python in `cross-build/build`, and an Android
+build in `cross-build/HOST`.
+
+You can use `--` as a separator for any of the `configure`-related commands –
+including `build` itself – to pass arguments to the underlying `configure`
+call. For example, if you want a pydebug build that also caches the results from
+`configure`, you can do:
+
+```sh
+./android.py build HOST -- -C --with-pydebug
+```