Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38943be

Browse files
[3.13]gh-131531: Addandroid.py package command (GH-131532) (#131960)
Adds a `package` entry point to the `android.py` build script to supportcreating an Android distribution artefact.(cherry picked from commitfe5c4c5)Co-authored-by: Malcolm Smith <smith@chaquo.com>
1 parent67087d9 commit38943be

File tree

7 files changed

+288
-125
lines changed

7 files changed

+288
-125
lines changed

‎Android/README.md

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
#Python for Android
22

3-
These instructions are only needed if you're planning to compile Python for
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.
3+
If you obtained this README as part of a release package, then the only
4+
applicable sections are "Prerequisites", "Testing", and "Using in your own app".
75

6+
If you obtained this README as part of the CPython source tree, then you can
7+
also follow the other sections to compile Python for Android yourself.
8+
9+
However, most app developers should not need to do any of these things manually.
10+
Instead, use one of the tools listed
11+
[here](https://docs.python.org/3/using/android.html), which will provide a much
12+
easier experience.
813

9-
##Prerequisites
1014

11-
First, make sure you have all the usual tools and libraries needed to build
12-
Python for your development machine.
15+
##Prerequisites
1316

14-
Second, you'll needan Android SDK. If you already havetheSDK installed,
15-
export the`ANDROID_HOME`environment variable to point at its location.
16-
Otherwise, here's how to installit:
17+
If you already havean Android SDK installed, exportthe`ANDROID_HOME`
18+
environment variable to point at its location. Otherwise, here's how to install
19+
it:
1720

1821
* Download the "Command line tools" from<https://developer.android.com/studio>.
1922
* Create a directory`android-sdk/cmdline-tools`, and unzip the command line
@@ -27,15 +30,16 @@ The `android.py` script also requires the following commands to be on the `PATH`
2730
*`curl`
2831
*`java` (or set the`JAVA_HOME` environment variable)
2932
*`tar`
30-
*`unzip`
3133

3234

3335
##Building
3436

3537
Python can be built for Android on any POSIX platform supported by the Android
36-
development tools, which currently means Linux or macOS. This involves doing a
37-
cross-build where you use a "build" Python (for your development machine) to
38-
help produce a "host" Python for Android.
38+
development tools, which currently means Linux or macOS.
39+
40+
First we'll make a "build" Python (for your development machine), then use it to
41+
help produce a "host" Python for Android. So make sure you have all the usual
42+
tools and libraries needed to build Python for your development machine.
3943

4044
The easiest way to do a build is to use the`android.py` script. You can either
4145
have it perform the entire build process from start to finish in one step, or
@@ -60,8 +64,8 @@ To do all steps in a single command, run:
6064
./android.py build HOST
6165
```
6266

63-
In the end you should have a build Python in`cross-build/build`, andan Android
64-
build in`cross-build/HOST`.
67+
In the end you should have a build Python in`cross-build/build`, anda host
68+
Python in`cross-build/HOST`.
6569

6670
You can use`--` as a separator for any of the`configure`-related commands –
6771
including`build` itself – to pass arguments to the underlying`configure`
@@ -73,14 +77,27 @@ call. For example, if you want a pydebug build that also caches the results from
7377
```
7478

7579

80+
##Packaging
81+
82+
After building an architecture as described in the section above, you can
83+
package it for release with this command:
84+
85+
```sh
86+
./android.py package HOST
87+
```
88+
89+
`HOST` is defined in the section above.
90+
91+
This will generate a tarball in`cross-build/HOST/dist`, whose structure is
92+
similar to the`Android` directory of the CPython source tree.
93+
94+
7695
##Testing
7796

78-
The test suite can be run on Linux, macOS, or Windows:
97+
ThePythontest suite can be run on Linux, macOS, or Windows:
7998

8099
* On Linux, the emulator needs access to the KVM virtualization interface, and
81100
a DISPLAY environment variable pointing at an X server.
82-
* On Windows, you won't be able to do the build on the same machine, so you'll
83-
have to copy the`cross-build/HOST` directory from somewhere else.
84101

85102
The test suite can usually be run on a device with 2 GB of RAM, but this is
86103
borderline, so you may need to increase it to 4 GB. As of Android
@@ -90,9 +107,16 @@ and find `hw.ramSize` in both config.ini and hardware-qemu.ini. Either set these
90107
manually to the same value, or use the Android Studio Device Manager, which will
91108
update both files.
92109

93-
Before running the test suite, follow the instructions in the previous section
94-
to build the architecture you want to test. Then run the test script in one of
95-
the following modes:
110+
You can run the test suite either:
111+
112+
* Within the CPython repository, after doing a build as described above. On
113+
Windows, you won't be able to do the build on the same machine, so you'll have
114+
to copy the`cross-build/HOST/prefix` directory from somewhere else.
115+
116+
* Or by taking a release package built using the`package` command, extracting
117+
it wherever you want, and using its own copy of`android.py`.
118+
119+
The test script supports the following modes:
96120

97121
* In`--connected` mode, it runs on a device or emulator you have already
98122
connected to the build machine. List the available devices with
@@ -133,4 +157,4 @@ until you re-run `android.py make-host` or `build`.
133157

134158
##Using in your own app
135159

136-
See`Doc/using/android.rst`.
160+
Seehttps://docs.python.org/3/using/android.html.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp