This Magisk module contains Python3 3.10 for Android

┌shell@localhost:/
└─$ python --version
Python 3.10.15+
┌shell@localhost:/
└─$ 

 ---

Python3 has been compiled with these configure options:

---

export LD_LIBRARY_PATH=/data/local/tmp/develop/sysroot/usr/lib

export CFLAGS="$CFLAGS -D__ANDROID_API__=21 -O3 -Wno-error=implicit-function-declaration"
export CPPFLAGS="$CFLAGS"

export TARGET_ROOT=/data/local/tmp/python3.10

AC_OPTIONS="ac_cv_func_shm_unlink=no  ac_cv_func_shm_open=yesac_cv_posix_semaphores_enabled=yes ac_cv_func_linkat=no ac_cv_func_faccessat=no  ac_cv_file__dev_ptc=no" 


# --enable-optimizations
eval ${AC_OPTIONS} ./configure  --prefix=${TARGET_ROOT}/usr --with-openssl=/data/local/tmp/develop/sysroot/usr \
   --enable-loadable-sqlite-extensions --enable-shared   --with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2,sha256,sha512 \
   --with-system-expat --without-ensurepip  --with-tzpath=/system/usr/share/zoneinfo --with-system_libmpdec 


Result:

The necessary bits to build these optional modules were not found:
_dbm                  _posixshmem           _tkinter          
nis                   spwd                                    
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time              


Failed to build these modules:
grp                                                           

---

The cache directory for compiled Python scripts is defined in the wrapper script:

PYTHONPYCACHEPREFIX="/data/local/tmp/home/python/cache"


Configured directories for site-packages:

┌shell@localhost:/
└─$ python -m site
sys.path = [
    '/',
    '/system/usr/lib/python310.zip',
    '/system/usr/lib/python3.10',
    '/system/usr/lib/python3.10/lib-dynload',
    '/system/usr/lib/python3.10/site-packages',
    '/data/local/tmp/home/python3.10/site-packages',
    '/data/local/tmp/home/python/site-packages',
]
USER_BASE: '/data/local/tmp/home/.local' (doesn't exist)
USER_SITE: '/data/local/tmp/home/.local/lib/python3.10/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
┌shell@localhost:/


The directories 

/data/local/tmp/home/python3.10/site-packages 
/data/local/tmp/home/python/site-packages

are writable by the user shell and can be used to add additional site-packages.


The Wrapper script for the Python executables executes the file

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

before executing the "real" python executable if it exists.

This file can be used to define environment variables for Python ( ... or do anything else)
(see https://docs.python.org/3/using/cmdline.htm for a list of supported environment variables)


The Python executables from this Magisk Module are compiled on an ASUS Zenfone 8 with the GCC Toolchain (version 1.0.0) from this Magisk Module:

https://github.com/Googlers-Repo/gcc/

All approbiate patches from the Termux repository for Python

https://github.com/termux/termux-packages/tree/master/packages/python

as of 06.10.2024 are applied.

The patches applied are in the directory source/patches in the Magisk Module.


History

10.10.2024 v1.1.0
  initial release


