This Magisk module contains Python3 3.14 for Android compiled using the source files for the official released Python 3.14


Also included in the Magisk Module are the OpenSSL libraries necessary to use SSL in Python scripts (in /system/usr/lib). 
The Python module to install other modules, pip, is already installed.

ASUS_I006D:/system/usr/share/python314 $ python --version
Python 3.14.0
ASUS_I006D:/system/usr/share/python314 $ 

ASUS_I006D:/system/usr/share/python314 $ pip --version
pip 25.2 from /system/usr/lib/python3.14/site-packages/pip (python 3.14)
ASUS_I006D:/system/usr/share/python314 $ 


There are two Python executables in the module, the binary python3.14 needs the Python library in /system/usr/lib and the binary python3.14-static only needs the standard Android OS libraries:

ASUS_I006D:/ $ LD_LIBRARY_PATH=/system/usr/lib ldd /system/usr/bin/python3.14
	linux-vdso.so.1 => [vdso] (0x76de2a8000)
	libc.so => /apex/com.android.runtime/lib64/bionic/libc.so (0x76db8f0000)
	libpython3.14.so.1.0 => /system/usr/lib/libpython3.14.so.1.0 (0x76d6a32000)
	libdl.so => /apex/com.android.runtime/lib64/bionic/libdl.so (0x76dd018000)
	liblog.so => /system/lib64/liblog.so (0x76dce88000)
	libm.so => /apex/com.android.runtime/lib64/bionic/libm.so (0x76dce41000)
	libc++.so => /system/lib64/libc++.so (0x76dceda000)
ASUS_I006D:/ $ 

ASUS_I006D:/ $ ldd /system/usr/bin/python3.14-static
	linux-vdso.so.1 => [vdso] (0x799baa5000)
	libc.so => /apex/com.android.runtime/lib64/bionic/libc.so (0x79930ac000)
	libdl.so => /apex/com.android.runtime/lib64/bionic/libdl.so (0x799a87a000)
	liblog.so => /system/lib64/liblog.so (0x7995cad000)
	libm.so => /apex/com.android.runtime/lib64/bionic/libm.so (0x7995c40000)
	libc++.so => /system/lib64/libc++.so (0x7995cc3000)
ASUS_I006D:/ $ 


The module also contains a "static" binary with stripped symbols:

ASUS_I006D:/ $ file /system/usr/bin/python3.14-static  /system/usr/bin/python3.14-static-stripped
/system/usr/bin/python3.14-static:          ELF shared object, 64-bit LSB arm64, dynamic (/system/bin/linker64), for Android 31, built by NDK r27b (12297006), not stripped
/system/usr/bin/python3.14-static-stripped: ELF shared object, 64-bit LSB arm64, dynamic (/system/bin/linker64), for Android 31, built by NDK r27b (12297006), stripped
ASUS_I006D:/ $ 

ASUS_I006D:/ $ ls -lh /system/usr/bin/python3.14-static  /system/usr/bin/python3.14-static-stripped
-rwxr-xr-x 1 root root 35M 2025-10-08 16:22 /system/usr/bin/python3.14-static
-rwxr-xr-x 1 root root 15M 2025-10-08 16:22 /system/usr/bin/python3.14-static-stripped
ASUS_I006D:/ $ 


Please note that a "real" static binary for Python is not really usefull because static binaries in Android can not resolve hostnames via DNS.



The standard executable is the binary that requires the Python library; therefor the wrapper script 

/system/bin/python_wrapper 

is used to execute the python executables:

ASUS_I006D:/ $ ls -l /system/bin | grep python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 idle3 -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 pip -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 pip3 -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 pip3.14 -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 pydoc3 -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 python3 -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 python3-config -> ./python_wrapper
lrwxrwxrwx 1 root root       16 1970-01-08 21:03 python3.14-static -> ./python_wrapper
-rwxr-xr-x 1 root root     1241 2025-04-01 14:36 python_wrapper
ASUS_I006D:/ $ 

Note that the wrapper script also sets other environment variables for Python (see below).


The configured directories for site-packages are:

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


The directories 

/data/local/tmp/home/python3.14/site-packages 
/data/local/tmp/home/python/site-packages
/data/local/tmp/home/.local/lib/python3.14/site-packages

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.


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

Use 

python -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 it is also added to the environment variable LD_LIBRARY_PATH. This directory should be used for addition 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)


The Python executables from this Magisk Module were compiled on an ASUS Zenfone 8 with the clang19 toolchain for android 

see 

  http://bnsmb.de/My_HowTos_for_Android.html#How_to_install_a_Toolchain_for_clang_on_phones_without_root_access

or 

  https://xdaforums.com/t/guide-how-to-install-a-toolchain-for-clang-on-phones-without-root-access.4710235/


The clang19 toolchain is also available on github: 

  https://github.com/bnsmb/clang19_toolchain_for_android/


As the Python make scripts now support Android, no patches from Termux are applied.

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

Configure options and logs of the tests are in the directory

/system/usr/share/python314:


ASUS_I006D:/system/usr/share/python314 $ ls -ltr
total 5580
-rw-r--r-- 1 root root    1022 2025-10-08 16:22 myconfigure
-rw-r--r-- 1 root root 1119223 2025-10-08 16:22 make_test_root.log
-rw-r--r-- 1 root root 2605744 2025-10-08 16:22 make_test_shell.log
-rw-r--r-- 1 root root 1974652 2025-10-08 16:22 config.log
ASUS_I006D:/system/usr/share/python314 $ 

All modules included in Python 3.14 are compiled execpt these modules:

_posixshmem               _tkinter                                         


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


History

06.10.2024 v1.0.0
  initial release

08.04.2025 v2.0.0
  added pip 25.0.1
  recompiled the files with clang19 and the prefix /system
  added an additional Python executable that only needs the standard Android OS libraries: python3.14-static
  some Python scripts in the previous version of the module used a shebang with /data/local/tmp/python3/usr/bin/python3 instead of /system/bin/python3  -- fixed
  added the libraries necessary for using SSL in Python programs ; the libraries are in the directory /system/usr/lib to not overwrite the SSL libraries from the OS
  the wrapper script now defines the environment variable SSL_CERT_DIR with the value /system/etc/security/cacerts if it is not already defined
  the wrapper script now defines the environment variable PIP_TARGET with the value /data/local/tmp/home/python/site-packages if it is not already defined
  the wrapper script now defines the environment variable TERMINFO if it is not already set with either /system/etc/terminfo or /system_ext/etc/terminfo
    if one of the directories exist
  the wrapper script now adds the directory /data/local/tmp/home/libs to the environment variable LD_LIBRARY_PATH if it exists

08.10.2025 v2.1.0
  all files were compiled using the source code of the official released Python version 3.14
  added a static binary with stripped symbols


