I looked a bit more into this and managed to run python 3.10.0rc2 on android in termux. No additional patches were needed, but the build process isn't straight forward.

Some packages don't build on-device and have to be built on a computer. Python is one of them (https://github.com/termux/termux-packages/issues/4157. The issue is closed because making all packages build on-device is no longer a goal of termux)

Follow https://github.com/termux/termux-packages/wiki/Build-environment to set up your termux build environment. You can use Docker, Vagrant, Ubuntu or Arch Linux. I used docker.

Next build and install python3.10.0rc2 *on the build machine*. You need python3.10 installed to cross-compile python3.10.

After that go back to the termux packages and change packages/python/build.sh. All you need to change is version number, url and hash. Here's a patch anyways:

diff --git a/packages/python/build.sh b/packages/python/build.sh
index c36bff5e5..d9fd86d02 100644
--- a/packages/python/build.sh
+++ b/packages/python/build.sh
@@ -2,10 +2,11 @@ TERMUX_PKG_HOMEPAGE=https://python.org/
 TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear programs"
 TERMUX_PKG_LICENSE="PythonPL"
 TERMUX_PKG_MAINTAINER="@termux"
-_MAJOR_VERSION=3.9
-TERMUX_PKG_VERSION=${_MAJOR_VERSION}.7
-TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz
-TERMUX_PKG_SHA256=f8145616e68c00041d1a6399b76387390388f8359581abc24432bb969b5e3c57
+_MAJOR_VERSION=3.10
+_MINOR_VERSION=.0
+TERMUX_PKG_VERSION=${_MAJOR_VERSION}${_MINOR_VERSION}rc2
+TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${_MAJOR_VERSION}${_MINOR_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz
+TERMUX_PKG_SHA256=e75b56088548b7b9ad1f2571e6f5a2315e4808cb6b5fbe8288502afc802b2f24
 TERMUX_PKG_DEPENDS="gdbm, libandroid-support, libbz2, libcrypt, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib"
 TERMUX_PKG_RECOMMENDS="clang, make, pkg-config"
 TERMUX_PKG_SUGGESTS="python-tkinter"

Finally just run "./build-package.sh -i -f python" and send "output/python*.deb" to your phone, where you can install it using dpkg -i.


Adrian

On 9/16/21 14:27, Adrian Freund wrote:

As you are using termux it might be worth checking out the build arguments and patches termux uses to build their own version of python (Currently 3.9.7): https://github.com/termux/termux-packages/tree/master/packages/python

I'm not sure if this will be enough to build python3.10 or if additional patches and build arguments are needed though.


Adrian


On 9/15/21 19:06, Sandeep Gupta wrote:
I am trying to compile Python3.10rc2 on rather unusual platform (termux on android). The
gcc version is listed below:
~ $ g++ -v
clang version 12.0.1
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

I get following warnings and errors:
Python/pytime.c:398:10: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conver
sion]
   if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {

Python/bootstrap_hash.c:141:17: error: implicit declaration of function 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           n = getrandom(dest, n, flags);
               ^
Python/bootstrap_hash.c:145:17: error: implicit declaration of function 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           n = getrandom(dest, n, flags);

Not sure if this is limitation of the platform or Python codebase needs fixes.

Thanks
-S

_______________________________________________
Python-Dev mailing list --python-dev@python.org
To unsubscribe send an email topython-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived 
athttps://mail.python.org/archives/list/python-dev@python.org/message/KEURSMCLUVI7VPKM6M2VUV4JIW6FP66Z/
Code of Conduct:http://python.org/psf/codeofconduct/

_______________________________________________
Python-Dev mailing list --python-dev@python.org
To unsubscribe send an email topython-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived 
athttps://mail.python.org/archives/list/python-dev@python.org/message/WFKYODUXY3UHENII7U47XQPUIZQFJDG4/
Code of Conduct:http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/2V5AVBB4QDN2NSEUFBQJ4X2M2FC6IMUA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to