Skip to content

Commit e80dd30

Browse files
mhsmithfreakboy3742Yhg1sAA-Turner
authored
pythongh-116622: Complete Android documentation (python#124259)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com> Co-authored-by: T. Wouters <thomas@python.org> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 27a62e7 commit e80dd30

22 files changed

+205
-111
lines changed

Android/README.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# Python for Android
22

33
These instructions are only needed if you're planning to compile Python for
4-
Android yourself. Most users should *not* need to do this. If you're looking to
5-
use Python on Android, one of the following tools will provide a much more
6-
approachable user experience:
7-
8-
* [Briefcase](https://briefcase.readthedocs.io), from the BeeWare project
9-
* [Buildozer](https://buildozer.readthedocs.io), from the Kivy project
10-
* [Chaquopy](https://chaquo.com/chaquopy/)
4+
Android yourself. Most users should *not* need to do this. Instead, use one of
5+
the tools listed in `Doc/using/android.rst`, which will provide a much easier
6+
experience.
117

128

139
## Prerequisites
@@ -89,10 +85,10 @@ The test suite can be run on Linux, macOS, or Windows:
8985
The test suite can usually be run on a device with 2 GB of RAM, but this is
9086
borderline, so you may need to increase it to 4 GB. As of Android
9187
Studio Koala, 2 GB is the default for all emulators, although the user interface
92-
may indicate otherwise. The effective setting is `hw.ramSize` in
93-
~/.android/avd/*.avd/hardware-qemu.ini, whereas Android Studio displays the
94-
value from config.ini. Changing the value in Android Studio will update both of
95-
these files.
88+
may indicate otherwise. Locate the emulator's directory under `~/.android/avd`,
89+
and find `hw.ramSize` in both config.ini and hardware-qemu.ini. Either set these
90+
manually to the same value, or use the Android Studio Device Manager, which will
91+
update both files.
9692

9793
Before running the test suite, follow the instructions in the previous section
9894
to build the architecture you want to test. Then run the test script in one of
@@ -133,3 +129,8 @@ Every time you run `android.py test`, changes in pure-Python files in the
133129
repository's `Lib` directory will be picked up immediately. Changes in C files,
134130
and architecture-specific files such as sysconfigdata, will not take effect
135131
until you re-run `android.py make-host` or `build`.
132+
133+
134+
## Using in your own app
135+
136+
See `Doc/using/android.rst`.

Doc/includes/wasm-ios-notavail.rst

-8
This file was deleted.

Doc/includes/wasm-mobile-notavail.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. include for modules that don't work on WASM or mobile platforms
2+
3+
.. availability:: not Android, not iOS, not WASI.
4+
5+
This module is not supported on :ref:`mobile platforms <mobile-availability>`
6+
or :ref:`WebAssembly platforms <wasm-availability>`.

Doc/library/curses.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ for Windows, DOS, and possibly other systems as well. This extension module is
2121
designed to match the API of ncurses, an open-source curses library hosted on
2222
Linux and the BSD variants of Unix.
2323

24-
.. include:: ../includes/wasm-ios-notavail.rst
24+
.. include:: ../includes/wasm-mobile-notavail.rst
2525

2626
.. note::
2727

Doc/library/dbm.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There
1919
is a `third party interface <https://www.jcea.es/programacion/pybsddb.htm>`_ to
2020
the Oracle Berkeley DB.
2121

22-
.. include:: ../includes/wasm-ios-notavail.rst
23-
2422
.. exception:: error
2523

2624
A tuple containing the exceptions that can be raised by each of the supported
@@ -164,6 +162,8 @@ SQLite backend for the :mod:`dbm` module.
164162
The files created by :mod:`dbm.sqlite3` can thus be opened by :mod:`sqlite3`,
165163
or any other SQLite browser, including the SQLite CLI.
166164

165+
.. include:: ../includes/wasm-notavail.rst
166+
167167
.. function:: open(filename, /, flag="r", mode=0o666)
168168

169169
Open an SQLite database.
@@ -207,6 +207,8 @@ functionality like crash tolerance.
207207
The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are incompatible
208208
and can not be used interchangeably.
209209

210+
.. include:: ../includes/wasm-mobile-notavail.rst
211+
210212
.. exception:: error
211213

212214
Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:`KeyError` is
@@ -326,6 +328,8 @@ This module can be used with the "classic" NDBM interface or the
326328
when storing values larger than this limit. Reading such corrupted files can
327329
result in a hard crash (segmentation fault).
328330

331+
.. include:: ../includes/wasm-mobile-notavail.rst
332+
329333
.. exception:: error
330334

331335
Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised

Doc/library/ensurepip.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ when creating a virtual environment) or after explicitly uninstalling
3838
:pep:`453`: Explicit bootstrapping of pip in Python installations
3939
The original rationale and specification for this module.
4040

41-
.. include:: ../includes/wasm-ios-notavail.rst
41+
.. include:: ../includes/wasm-mobile-notavail.rst
4242

4343
Command line interface
4444
----------------------

Doc/library/grp.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
This module provides access to the Unix group database. It is available on all
1111
Unix versions.
1212

13-
.. availability:: Unix, not WASI, not iOS.
13+
.. availability:: Unix, not WASI, not Android, not iOS.
1414

1515
Group database entries are reported as a tuple-like object, whose attributes
1616
correspond to the members of the ``group`` structure (Attribute field below, see

Doc/library/intro.rst

+46-32
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Notes on availability
5858
operating system.
5959

6060
* If not separately noted, all functions that claim "Availability: Unix" are
61-
supported on macOS and iOS, both of which build on a Unix core.
61+
supported on macOS, iOS and Android, all of which build on a Unix core.
6262

6363
* If an availability note contains both a minimum Kernel version and a minimum
6464
libc version, then both conditions must hold. For example a feature with note
@@ -120,43 +120,57 @@ DOM APIs as well as limited networking capabilities with JavaScript's
120120
.. _Pyodide: https://pyodide.org/
121121
.. _PyScript: https://pyscript.net/
122122

123+
.. _mobile-availability:
123124
.. _iOS-availability:
124125

125-
iOS
126-
---
126+
Mobile platforms
127+
----------------
127128

128-
iOS is, in most respects, a POSIX operating system. File I/O, socket handling,
129+
Android and iOS are, in most respects, POSIX operating systems. File I/O, socket handling,
129130
and threading all behave as they would on any POSIX operating system. However,
130-
there are several major differences between iOS and other POSIX systems.
131-
132-
* iOS can only use Python in "embedded" mode. There is no Python REPL, and no
133-
ability to execute binaries that are part of the normal Python developer
134-
experience, such as :program:`pip`. To add Python code to your iOS app, you must use
135-
the :ref:`Python embedding API <embedding>` to add a Python interpreter to an
136-
iOS app created with Xcode. See the :ref:`iOS usage guide <using-ios>` for
137-
more details.
138-
139-
* An iOS app cannot use any form of subprocessing, background processing, or
140-
inter-process communication. If an iOS app attempts to create a subprocess,
141-
the process creating the subprocess will either lock up, or crash. An iOS app
142-
has no visibility of other applications that are running, nor any ability to
143-
communicate with other running applications, outside of the iOS-specific APIs
144-
that exist for this purpose.
145-
146-
* iOS apps have limited access to modify system resources (such as the system
131+
there are several major differences:
132+
133+
* Mobile platforms can only use Python in "embedded" mode. There is no Python
134+
REPL, and no ability to use separate executables such as :program:`python` or
135+
:program:`pip`. To add Python code to your mobile app, you must use
136+
the :ref:`Python embedding API <embedding>`. For more details, see
137+
:ref:`using-android` and :ref:`using-ios`.
138+
139+
* Subprocesses:
140+
141+
* On Android, creating subprocesses is possible but `officially unsupported
142+
<https://issuetracker.google.com/issues/128554619#comment4>`__.
143+
In particular, Android does not support any part of the System V IPC API,
144+
so :mod:`multiprocessing` is not available.
145+
146+
* An iOS app cannot use any form of subprocessing, multiprocessing, or
147+
inter-process communication. If an iOS app attempts to create a subprocess,
148+
the process creating the subprocess will either lock up, or crash. An iOS app
149+
has no visibility of other applications that are running, nor any ability to
150+
communicate with other running applications, outside of the iOS-specific APIs
151+
that exist for this purpose.
152+
153+
* Mobile apps have limited access to modify system resources (such as the system
147154
clock). These resources will often be *readable*, but attempts to modify
148155
those resources will usually fail.
149156

150-
* iOS apps have a limited concept of console input and output. ``stdout`` and
151-
``stderr`` *exist*, and content written to ``stdout`` and ``stderr`` will be
152-
visible in logs when running in Xcode, but this content *won't* be recorded
153-
in the system log. If a user who has installed your app provides their app
154-
logs as a diagnostic aid, they will not include any detail written to
155-
``stdout`` or ``stderr``.
157+
* Console input and output:
158+
159+
* On Android, the native ``stdout`` and ``stderr`` are not connected to
160+
anything, so Python installs its own streams which redirect messages to the
161+
system log. These can be seen under the tags ``python.stdout`` and
162+
``python.stderr`` respectively.
163+
164+
* iOS apps have a limited concept of console output. ``stdout`` and
165+
``stderr`` *exist*, and content written to ``stdout`` and ``stderr`` will be
166+
visible in logs when running in Xcode, but this content *won't* be recorded
167+
in the system log. If a user who has installed your app provides their app
168+
logs as a diagnostic aid, they will not include any detail written to
169+
``stdout`` or ``stderr``.
156170

157-
iOS apps have no concept of ``stdin`` at all. While iOS apps can have a
158-
keyboard, this is a software feature, not something that is attached to
159-
``stdin``.
171+
* Mobile apps have no usable ``stdin`` at all. While apps can display an on-screen
172+
keyboard, this is a software feature, not something that is attached to
173+
``stdin``.
160174

161-
As a result, Python library that involve console manipulation (such as
162-
:mod:`curses` and :mod:`readline`) are not available on iOS.
175+
As a result, Python modules that involve console manipulation (such as
176+
:mod:`curses` and :mod:`readline`) are not available on mobile platforms.

Doc/library/multiprocessing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
--------------
1010

11-
.. include:: ../includes/wasm-ios-notavail.rst
11+
.. include:: ../includes/wasm-mobile-notavail.rst
1212

1313
Introduction
1414
------------

0 commit comments

Comments
 (0)