Build native packages for Android.
## Requirements
- Python;
- Android SDK;
The Android SDK can be installed from [Android Studio][].
Then set the environment variable [ANDROID_SDK_ROOT][] or ANDROID_HOME.
Finally, Python's [distutils][] package must be patched for cross-compiling.
The patch is in the patches directory. Apply it like so:
DESTLIB=$(python -c "import sysconfig; \
print(sysconfig.get_config_var('DESTLIB'))")
patch -p2 -d $DESTLIB < patches/patch-Python-3.10.0.txt
This patch should apply to any version of Python.
You may need to use sudo.
[Android Studio]: https://developer.android.com/studio/
[ANDROID_SDK_ROOT]: https://developer.android.com/studio/command-line/variables
[distutils]: https://docs.python.org/3/library/distutils.html
## Install androidenv
Install from the Python Package Index:
pip install androidenv
You can also copy the file androidenv.py to where you need it,
it is self contained.
## Usage
Build something from source:
cd thing
python -m androidenv setup.py build
python -m androidenv setup.py install
You really want to do this in a [virtual environment][venv].
[venv]: https://docs.python.org/3/library/venv.html
Use the --find-library option to find libraries like libandroid or liblog:
python -m androidenv --find-library android log
## Environment variables
This module works entirely with environment variables.
Input environment variables:
- ANDROID_SDK_ROOT or ANDROID_HOME (required);
- ABI (optional; armeabi-v7a or arm64-v8a);
- API (optional);
- DEBUG (optional; 0 or 1);
What is being built must respect the following evironment variables:
- AR
- AS
- CC
- CFLAGS
- CPP
- CPPFLAGS
- CXX
- CXXFLAGS
- LD
- LDFLAGS
- PATH
- RANLIB
- READELF
- STRIP
Many packages do, many don't. Python itself (distutils) does not respect
RANLIB; CMake does not respect CPPFLAGS; and many more. Fixing that is
your homework.
### setup.cfg
Some useful configuration options when building for Android:
[build]
build-base = build
build-temp = build/tmp
build-lib = build/lib
Metadata
Release files for androidenv 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| androidenv-1.0.tar.gz | 5.8 kB | Without provenance | Details |
Release files / androidenv-1.0.tar.gz
| Download URL | androidenv-1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7a9677031f181f789f543a4cca61586684b52ee85bcd286ef8a2e271d95c620
|
|
BLAKE2b-256 checksum How to use checksums |
4fc869533b74b74e5dda4d09d05803e353f6b3f73ef4c8b4d8ca76edb9c47ef2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for androidenv 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.