This Magisk module contains Python3 3.15 for Android 

ASUS_I006D:/ $ python3 --version                                                                                                                       
Python 3.15.0
ASUS_I006D:/ $ 


Also included in this Magisk Module are the libraries required by the included python modules. These libaries are in the directory 

/system/usr/lib


The Python module to install other modules, pip, is already installed:

ASUS_I006D:/ $ pip --version
pip 26.2.1 from /system/usr/lib/python3.15/pip (python 3.15)
ASUS_I006D:/ $ 


The python binary was linked with a static python library - it does not need the python library libpython3.15.so.1.0 from the Module

But note that the compiled python modules in the Magisk module need the library libpython3.15.so.1.0.


Because /system is read-only in Android, the module contains a wrapper script for python:

/system/bin/python_wrapper 

This wrapper script is used to execute the python executables:

ASUS_I006D:/ $  ls -l /system/bin | grep python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 17:57 idle3 -> ./python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 17:57 pip -> ./python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 17:57 pip3 -> ./python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 17:57 pip3.15 -> ./python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 17:57 pydoc3 -> ./python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 20:47 python3 -> ./python_wrapper
lrwxrwxrwx 1 system system      16 2025-11-07 17:57 python3-config -> ./python_wrapper
-rwxr-xr-x 1 root   shell     2579 2026-10-13 11:16 python_wrapper
ASUS_I006D:/ $ 


The wrapper script sets the LD_LIBRARY_PATH and some other environment variables for Python (see below).


The configured directories for site-packages are:

ASUS_I006D:/ $ python3 -m site                                                                                                                                                                                      
sys.path = [
    '/',
    '/data/local/tmp/home/python/site-packages',
    '/data/local/tmp/home/python3.15/site-packages',
    '/system/usr/lib/python315.zip',
    '/system/usr/lib/python3.15',
    '/system/usr/lib/python3.15/lib-dynload',
    '/system/usr/lib/python3.15/site-packages',
]
USER_BASE: '/data/local/tmp/home/.local' (doesn't exist)
USER_SITE: '/data/local/tmp/home/.local/lib/python3.15/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
ASUS_I006D:/ $ 


The installed python modules are:

ASUS_I006D:/data/local/tmp $ pip list -v                                                                                                                   
Package      Version Location                   Installer
------------ ------- -------------------------- ---------
pip          26.2.1  /system/usr/lib/python3.15 pip
pycheck-tool 0.1.4   /system/usr/lib/python3.15 pip
ASUS_I006D:/data/local/tmp $ 


The directories in /data/local/tmp are writable by the user shell and can be used to add additional site-packages.

pip can be used to install additional Python modules; the target directory for these modules defined in the wrapper script is

/data/local/tmp/home/python/site-packages

To use another target directory for the Python modules export the variable PIP_TARGET before executing pip.
Or use the parameter "--target=<dir>" for pip to set the target directory.

Note that the python scripts installed with pip are then in the directory /data/local/tmp/home/python/site-packages/bin.



The wrapper script defines the environment variable SSL_CERT_DIR with the value /system/etc/security/cacerts if it is not already defined.

Use 

python3 -c "import ssl; print(ssl.get_default_verify_paths()) "  

to show which certificate paths are being used.



The wrapper script defines the environment variable PYTHONPYCACHEPREFIX with 

/data/local/tmp/home/python/cache

This directory is then used for the compiled Python scripts. The customization script creates this directory if it does not yet exist.


The wrapper script defines the variable TERMINFO with 

/system/etc/terminfo 

or 

/system_ext/etc/terminfo

if one of these directories exists and the variable TERMINFO is not already defined


The wrapper scripts sets the environment variable LD_LIBRARY_PATH to 

/system/usr/lib


If the directory 

/data/local/tmp/home/libs 

exists, the directory is also added to the environment variable LD_LIBRARY_PATH.

This directory should be used for additional library files required by the Python scripts.


Set the variable DEBUG to any non-empty string before executing python to execute the wrapper script with "set -x", e.g.:

DEBUG=yes python --version           


If the file

/data/local/tmp/home/python_init.sh

exists, it will be sourced in by the wrapper script before executing the Python binary.

The file /data/local/tmp/home/python_init.sh can be used to define or overwrite the environment variables for Python ( ... or do anything else)

(see https://docs.python.org/3/using/cmdline.html for a list of supported environment variables; use the variable "$0" in the script to distinguish between the executables)


 ------------------------------------------------------------------------------

Some files used for building the python binaries are in the directory /system/usr/share/python3_3.15:

ASUS_I006D:/ $ ls -l /system/usr/share/python3_3.15/                                                                                                                                                                                  
total 84
-rw-r--r-- 1 root root  2573 2026-10-13 15:22 myconfigure
-rw-r--r-- 1 root root 76182 2026-10-13 15:22 python3_in_system_tests.log
-rw-r--r-- 1 root root  1126 2026-10-13 15:22 run_tests.sh
ASUS_I006D:/ $ 


The configure options used to compile the python files in this Magisk Module can be found in the file

myconfigure

(The build was done on a PC running Linux with the Android NDK)

All modules included in Python 3.15 are compiled except these modules:

_dbm                  _multiprocessing      _posixshmem       
_tkinter 


To run the python test suite the script

run_tests.sh

can be used.

The python test suite is not part of this Magisk Module. To install the python test suite download the tar archive with the source files for Python 3.15  

https://www.python.org/ftp/python/3.15.0/Python-3.15.0.tar.xz

and copy the directory ./Python-3.15.0/Lib from the tar file to the phone.

You can then run “run_test.sh” in this directory to execute one or more tests from the test suite.


Note:

Run “/system/usr/share/python3_3.15/run_tests.sh -h” to view help on running the test suite; some of the tests always fail on Android 


The log file created when running the test suite with the Python files from this Magisk module is

python3_in_system_tests.log


see 

http://bnsmb.de/Magisk_Modules.html#Documentation_for_the_Magisk_Module_with_Python_3.15

for the detailed documentation for this Magisk Module


History

14.10.2026 v1.0.0
  initial release

