From 95cceabb70e782aa96e69140a5afd320b9d0ab98 Mon Sep 17 00:00:00 2001 From: Lucy Phipps Date: Sun, 11 Feb 2024 13:13:18 +0000 Subject: [PATCH 01/18] python: bump to 3.12.4 --- packages/python/0002-no-setuid-servers.patch | 21 ------------------- .../0003-ctypes-util-use-llvm-tools.patch | 2 -- .../python/0005-impl-multiprocessing.patch | 14 ------------- packages/python/0007-disable-multiarch.patch | 8 +++---- packages/python/0008-do-not-use-link.patch | 8 +++---- packages/python/0009-build-with-fPIC.patch | 4 ++-- .../python/0010-use-android-logging.patch | 12 ----------- .../python/0011-disable-parallel-build.patch | 13 ------------ .../python/0012-do-not-include-langinfo.patch | 14 ------------- packages/python/build.sh | 6 +++--- 10 files changed, 12 insertions(+), 90 deletions(-) delete mode 100644 packages/python/0010-use-android-logging.patch delete mode 100644 packages/python/0011-disable-parallel-build.patch delete mode 100644 packages/python/0012-do-not-include-langinfo.patch diff --git a/packages/python/0002-no-setuid-servers.patch b/packages/python/0002-no-setuid-servers.patch index 1be01d43f894e2..38832867bd78b4 100644 --- a/packages/python/0002-no-setuid-servers.patch +++ b/packages/python/0002-no-setuid-servers.patch @@ -11,24 +11,3 @@ os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) os.execve(scriptfile, args, env) ---- a/Lib/smtpd.py -+++ b/Lib/smtpd.py -@@ -9,7 +9,8 @@ - -n - This program generally tries to setuid `nobody', unless this flag is - set. The setuid call will fail if this program is not run as root (in -- which case, use this flag). -+ which case, use this flag). Ignored in Termux as no setuid done on this -+ platform. - - --version - -V -@@ -863,7 +864,7 @@ - - - class Options: -- setuid = True -+ setuid = False - classname = 'PureProxy' - size_limit = None - enable_SMTPUTF8 = False diff --git a/packages/python/0003-ctypes-util-use-llvm-tools.patch b/packages/python/0003-ctypes-util-use-llvm-tools.patch index 3b5b6bf3146c8b..9229e35c78ed41 100644 --- a/packages/python/0003-ctypes-util-use-llvm-tools.patch +++ b/packages/python/0003-ctypes-util-use-llvm-tools.patch @@ -1,5 +1,3 @@ -https://github.com/termux/termux-packages/issues/8478 - --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -172,7 +172,7 @@ diff --git a/packages/python/0005-impl-multiprocessing.patch b/packages/python/0005-impl-multiprocessing.patch index a5fe39cd45c847..330a06f1b74798 100644 --- a/packages/python/0005-impl-multiprocessing.patch +++ b/packages/python/0005-impl-multiprocessing.patch @@ -1,17 +1,3 @@ ---- a/setup.py -+++ b/setup.py -@@ -1328,8 +1329,8 @@ - sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED') - ): - multiprocessing_srcs.append('_multiprocessing/semaphore.c') -- self.addext(Extension('_multiprocessing', multiprocessing_srcs)) -- self.addext(Extension('_posixshmem', ['_multiprocessing/posixshmem.c'])) -+ self.addext(Extension('_multiprocessing', multiprocessing_srcs, libraries=["android-posix-semaphore"])) -+ self.addext(Extension('_posixshmem', ['_multiprocessing/posixshmem.c','_multiprocessing/posix-shm-extension.c'])) - - def detect_uuid(self): - # Build the _uuid module if possible - --- a/Lib/multiprocessing/heap.py +++ b/Lib/multiprocessing/heap.py @@ -70,7 +70,7 @@ diff --git a/packages/python/0007-disable-multiarch.patch b/packages/python/0007-disable-multiarch.patch index dd4c4ab35f41a2..79c1c787135fee 100644 --- a/packages/python/0007-disable-multiarch.patch +++ b/packages/python/0007-disable-multiarch.patch @@ -1,10 +1,8 @@ -https://github.com/termux/termux-packages/issues/11870 - --- a/configure +++ b/configure -@@ -6202,6 +6202,8 @@ - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multiarch" >&5 - $as_echo_n "checking for multiarch... " >&6; } +@@ -6939,6 +6939,8 @@ + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for multiarch" >&5 + printf %s "checking for multiarch... " >&6; } case $ac_sys_system in #( + Linux-android) : + MULTIARCH="" ;; #( diff --git a/packages/python/0008-do-not-use-link.patch b/packages/python/0008-do-not-use-link.patch index b65cf0c7fcaab2..15b100f1ed7ad1 100644 --- a/packages/python/0008-do-not-use-link.patch +++ b/packages/python/0008-do-not-use-link.patch @@ -1,10 +1,10 @@ --- a/configure +++ b/configure -@@ -15331,7 +15333,6 @@ - $as_echo "$ac_cv_func_link" >&6; } - if test "x$ac_cv_func_link" = xyes; then : +@@ -18772,7 +18774,6 @@ + if test "x$ac_cv_func_link" = xyes + then : --$as_echo "#define HAVE_LINK 1" >>confdefs.h +-printf "%s\n" "#define HAVE_LINK 1" >>confdefs.h fi diff --git a/packages/python/0009-build-with-fPIC.patch b/packages/python/0009-build-with-fPIC.patch index 233c0f341932aa..5fd66f38140d1f 100644 --- a/packages/python/0009-build-with-fPIC.patch +++ b/packages/python/0009-build-with-fPIC.patch @@ -1,6 +1,6 @@ --- a/configure +++ b/configure -@@ -11027,7 +11029,7 @@ +@@ -12838,7 +12840,7 @@ then CCSHARED="-fPIC"; else CCSHARED="+z"; fi;; @@ -8,4 +8,4 @@ + Linux-android*) CCSHARED="-fPIC";; Linux*|GNU*) CCSHARED="-fPIC";; Emscripten*|WASI*) - if test "x$enable_wasm_dynamic_linking" = xyes; then : + if test "x$enable_wasm_dynamic_linking" = xyes diff --git a/packages/python/0010-use-android-logging.patch b/packages/python/0010-use-android-logging.patch deleted file mode 100644 index 6d3cea77cd0fc6..00000000000000 --- a/packages/python/0010-use-android-logging.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/setup.py -+++ b/setup.py -@@ -981,7 +981,8 @@ - - # Lance Ellinghaus's syslog module - # syslog daemon interface -- self.addext(Extension('syslog', ['syslogmodule.c'])) -+ # Termux: Add 'log' android library since we use android logging -+ self.addext(Extension('syslog', ['syslogmodule.c'], libraries=['log'])) - - # Python interface to subinterpreter C-API. - self.addext(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'])) diff --git a/packages/python/0011-disable-parallel-build.patch b/packages/python/0011-disable-parallel-build.patch deleted file mode 100644 index 5c0695af2bed82..00000000000000 --- a/packages/python/0011-disable-parallel-build.patch +++ /dev/null @@ -1,13 +0,0 @@ -https://github.com/termux/termux-packages/issues/15908 - ---- a/setup.py -+++ b/setup.py -@@ -306,8 +306,6 @@ - self.failed_on_import = [] - self.missing = [] - self.disabled_configure = [] -- if '-j' in os.environ.get('MAKEFLAGS', ''): -- self.parallel = True - - def add(self, ext): - self.extensions.append(ext) diff --git a/packages/python/0012-do-not-include-langinfo.patch b/packages/python/0012-do-not-include-langinfo.patch deleted file mode 100644 index d6a0700931cb6d..00000000000000 --- a/packages/python/0012-do-not-include-langinfo.patch +++ /dev/null @@ -1,14 +0,0 @@ -We use libandroid-support when building Python, but Python does not -use LDFLAGS when building modules (and not much point in this case). - ---- a/Modules/_cursesmodule.c -+++ b/Modules/_cursesmodule.c -@@ -121,7 +121,7 @@ - #include - #endif - --#ifdef HAVE_LANGINFO_H -+#if defined(HAVE_LANGINFO_H) && !defined(__ANDROID__) - #include - #endif - diff --git a/packages/python/build.sh b/packages/python/build.sh index f187c9328a606b..e87a7a165aab6f 100644 --- a/packages/python/build.sh +++ b/packages/python/build.sh @@ -4,9 +4,9 @@ TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear p TERMUX_PKG_LICENSE="custom" TERMUX_PKG_LICENSE_FILE="LICENSE" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION=3.11.10 +TERMUX_PKG_VERSION=3.12.4 TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=07a4356e912900e61a15cb0949a06c4a05012e213ecd6b4e84d0f67aabbee372 +TERMUX_PKG_SHA256=f6d419a6d8743ab26700801b4908d26d97e8b986e14f95de31b32de2b0e79554 TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_DEPENDS="gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libexpat, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib" TERMUX_PKG_BUILD_DEPENDS="tk" @@ -18,7 +18,7 @@ TERMUX_PKG_REPLACES="python-dev" TERMUX_PKG_PROVIDES="python3" # https://github.com/termux/termux-packages/issues/15908 -TERMUX_PKG_MAKE_PROCESSES=1 +TERMUX_MAKE_PROCESSES=1 _MAJOR_VERSION="${TERMUX_PKG_VERSION%.*}" From 7c9f9d7cc1e56693869d3498360ab7cd75864ed0 Mon Sep 17 00:00:00 2001 From: Chongyun Lee Date: Thu, 27 Jun 2024 22:31:23 +0800 Subject: [PATCH 02/18] python: fix for multiprocessing module --- .../python/0005-impl-multiprocessing.patch | 128 ++++++++---------- packages/python/build.sh | 3 + 2 files changed, 58 insertions(+), 73 deletions(-) diff --git a/packages/python/0005-impl-multiprocessing.patch b/packages/python/0005-impl-multiprocessing.patch index 330a06f1b74798..a4468610ae4185 100644 --- a/packages/python/0005-impl-multiprocessing.patch +++ b/packages/python/0005-impl-multiprocessing.patch @@ -24,94 +24,76 @@ --- a/Modules/_multiprocessing/posixshmem.c +++ b/Modules/_multiprocessing/posixshmem.c -@@ -11,6 +11,9 @@ +@@ -11,6 +11,72 @@ #include #endif -+int shm_open(const char *, int, mode_t); -+int shm_unlink(const char *); ++#ifdef __ANDROID__ ++#include ++#include ++#include ++#include ++#include ++static int shm_unlink(const char *name) { ++ size_t namelen; ++ char *fname; + - /*[clinic input] - module _posixshmem - [clinic start generated code]*/ - ---- a/Modules/_multiprocessing/posix-shm-extension.c -+++ b/Modules/_multiprocessing/posix-shm-extension.c -@@ -0,0 +1,76 @@ -+/* This file is a port of posix shared memory for Python3 on Termux Android, -+ based on musl-libc which is licensed under the following standard MIT -+ license. The ported files are listed as following. ++ /* Construct the filename. */ ++ while (name[0] == '/') ++name; + -+ File(s): src/mman/shm_open.c ++ if (name[0] == '\0') { ++ /* The name "/" is not supported. */ ++ errno = EINVAL; ++ return -1; ++ } + -+ Copyright © 2005-2020 Rich Felker, et al. ++ namelen = strlen(name); ++ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1); ++ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1); ++ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1); + -+ Permission is hereby granted, free of charge, to any person obtaining -+ a copy of this software and associated documentation files (the -+ "Software"), to deal in the Software without restriction, including -+ without limitation the rights to use, copy, modify, merge, publish, -+ distribute, sublicense, and/or sell copies of the Software, and to -+ permit persons to whom the Software is furnished to do so, subject to -+ the following conditions: ++ return unlink(fname); ++} + -+ The above copyright notice and this permission notice shall be -+ included in all copies or substantial portions of the Software. ++static int shm_open(const char *name, int oflag, mode_t mode) { ++ size_t namelen; ++ char *fname; ++ int fd; + -+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ */ ++ /* Construct the filename. */ ++ while (name[0] == '/') ++name; + -+#include // open() -+#include // strlen(), memcpy() -+#include // errno -+#include // NAME_MAX -+#include // unlink() ++ if (name[0] == '\0') { ++ /* The name "/" is not supported. */ ++ errno = EINVAL; ++ return -1; ++ } + -+#define SHM_PREFIX "@TERMUX_PREFIX@/tmp/shm." ++ namelen = strlen(name); ++ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1); ++ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1); ++ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1); + -+static __inline__ char *__strchrnul(const char *s, int c) -+{ -+ c = (unsigned char)c; -+ if (!c) return (char *)s + strlen(s); -+ for (; *s && *(unsigned char *)s != c; s++); -+ return (char *)s; -+} ++ fd = open(fname, oflag, mode); ++ if (fd != -1) { ++ /* We got a descriptor. Now set the FD_CLOEXEC bit. */ ++ int flags = fcntl(fd, F_GETFD, 0); ++ flags |= FD_CLOEXEC; ++ flags = fcntl(fd, F_SETFD, flags); + -+static char *__shm_mapname(const char *name, char *buf) -+{ -+ char *p; -+ while (*name == '/') name++; -+ if (*(p = __strchrnul(name, '/')) || p==name || -+ (p-name <= 2 && name[0]=='.' && p[-1]=='.')) { -+ errno = EINVAL; -+ return 0; -+ } -+ if (p-name > NAME_MAX-4) { -+ errno = ENAMETOOLONG; -+ return 0; ++ if (flags == -1) { ++ /* Something went wrong. We cannot return the descriptor. */ ++ int save_errno = errno; ++ close(fd); ++ fd = -1; ++ errno = save_errno; ++ } + } -+ memcpy(buf, SHM_PREFIX, strlen(SHM_PREFIX)); -+ memcpy(buf+strlen(SHM_PREFIX), name, p-name+1); -+ return buf; -+} + -+int shm_open(const char *name, int flag, mode_t mode) -+{ -+ char buf[NAME_MAX+strlen(SHM_PREFIX)+1]; -+ if (!(name = __shm_mapname(name, buf))) return -1; -+ int fd = open(name, flag|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK, mode); + return fd; +} ++#endif + -+int shm_unlink(const char *name) -+{ -+ char buf[NAME_MAX+strlen(SHM_PREFIX)+1]; -+ if (!(name = __shm_mapname(name, buf))) return -1; -+ return unlink(name); -+} - + /*[clinic input] + module _posixshmem + [clinic start generated code]*/ diff --git a/packages/python/build.sh b/packages/python/build.sh index e87a7a165aab6f..60a9dc118c3d21 100644 --- a/packages/python/build.sh +++ b/packages/python/build.sh @@ -75,6 +75,9 @@ termux_step_pre_configure() { TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-build-python=python$_MAJOR_VERSION" fi + # For multiprocessing libs + export LDFLAGS+=" -landroid-posix-semaphore" + export LIBCRYPT_LIBS="-lcrypt" } From 54139817460dec65006f981ee5061854ef2524ee Mon Sep 17 00:00:00 2001 From: Chongyun Lee Date: Thu, 27 Jun 2024 22:33:13 +0800 Subject: [PATCH 03/18] python: link modules against libpython --- .../0010-link-modules-against-libpython.patch | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/python/0010-link-modules-against-libpython.patch diff --git a/packages/python/0010-link-modules-against-libpython.patch b/packages/python/0010-link-modules-against-libpython.patch new file mode 100644 index 00000000000000..541eb1ea0c0a1c --- /dev/null +++ b/packages/python/0010-link-modules-against-libpython.patch @@ -0,0 +1,23 @@ +Borrowed from https://github.com/msys2-contrib/cpython-mingw/commit/c4c698ec8fd7413068fce2de966938b3f8462de8 + +--- a/Modules/makesetup ++++ b/Modules/makesetup +@@ -97,6 +97,9 @@ + ExtraLibDir='$(LIBPL)' + fi + ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";; ++Linux*) ++ ExtraLibs='$(BLDLIBRARY)' ++ ExtraLibDepends='$(LIBRARY_DEPS)';; + esac + + # Main loop +@@ -285,7 +288,7 @@ + BUILT_SHARED="$BUILT_SHARED $mod" + ;; + esac +- rule="$file: $objs" ++ rule="$file: $objs $ExtraLibDepends" + rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file" + echo "$rule" >>$rulesf + done From 1afa42f1b70154650f773ee79ae6ca5ced859b7b Mon Sep 17 00:00:00 2001 From: Chongyun Lee Date: Thu, 27 Jun 2024 22:36:16 +0800 Subject: [PATCH 04/18] termux_setup_python_pip: support python3.12 --- scripts/build/setup/termux_setup_python_pip.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/build/setup/termux_setup_python_pip.sh b/scripts/build/setup/termux_setup_python_pip.sh index 2a51f91e6deb08..1ac6369b6b09eb 100644 --- a/scripts/build/setup/termux_setup_python_pip.sh +++ b/scripts/build/setup/termux_setup_python_pip.sh @@ -59,6 +59,13 @@ termux_setup_python_pip() { fi . "${TERMUX_PYTHON_CROSSENV_PREFIX}/bin/activate" + # Since 3.12, distutils is removed from python, but setuptools>=60 provides it + build-pip install 'setuptools==67.6.1' wheel + cross-pip install 'setuptools==67.6.1' wheel + if [ "${TERMUX_PYTHON_VERSION#*.}" -lt "12" ]; then + export SETUPTOOLS_USE_DISTUTILS=stdlib + fi + export PATH="${PATH}:${TERMUX_PYTHON_CROSSENV_PREFIX}/build/bin" fi } From 22671e4e7b664f71c89216160cbcaf1e8f30029f Mon Sep 17 00:00:00 2001 From: Chongyun Lee Date: Thu, 27 Jun 2024 23:03:30 +0800 Subject: [PATCH 05/18] python-pip: revbump to rebuild --- packages/python-pip/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/python-pip/build.sh b/packages/python-pip/build.sh index 0d4fd1768ead4b..e9a48b58ba236c 100644 --- a/packages/python-pip/build.sh +++ b/packages/python-pip/build.sh @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="The PyPA recommended tool for installing Python packages TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="24.2" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://github.com/pypa/pip/archive/$TERMUX_PKG_VERSION.tar.gz TERMUX_PKG_SHA256=e527f2366551b8483fa3a8ac2954aa79f2461e6600d917f3b6ae741d708cb982 TERMUX_PKG_AUTO_UPDATE=true From 632fdcfa20cd0bd6c8004ef8967453455ae5b62b Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Wed, 25 Sep 2024 21:59:52 +0200 Subject: [PATCH 06/18] bump(main/python): 3.12.6 --- packages/python/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/build.sh b/packages/python/build.sh index 60a9dc118c3d21..39132d0b12d180 100644 --- a/packages/python/build.sh +++ b/packages/python/build.sh @@ -4,9 +4,9 @@ TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear p TERMUX_PKG_LICENSE="custom" TERMUX_PKG_LICENSE_FILE="LICENSE" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION=3.12.4 +TERMUX_PKG_VERSION=3.12.6 TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=f6d419a6d8743ab26700801b4908d26d97e8b986e14f95de31b32de2b0e79554 +TERMUX_PKG_SHA256=1999658298cf2fb837dffed8ff3c033ef0c98ef20cf73c5d5f66bed5ab89697c TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_DEPENDS="gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libexpat, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib" TERMUX_PKG_BUILD_DEPENDS="tk" From 3caa31a09ce7fbbbb1571b6651e7cadbe2cf8cee Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 3 Oct 2024 12:58:45 +0200 Subject: [PATCH 07/18] bump(main/python): 3.12.7 --- packages/python/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python/build.sh b/packages/python/build.sh index 39132d0b12d180..c2408962ecb1f0 100644 --- a/packages/python/build.sh +++ b/packages/python/build.sh @@ -4,9 +4,9 @@ TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear p TERMUX_PKG_LICENSE="custom" TERMUX_PKG_LICENSE_FILE="LICENSE" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION=3.12.6 +TERMUX_PKG_VERSION=3.12.7 TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=1999658298cf2fb837dffed8ff3c033ef0c98ef20cf73c5d5f66bed5ab89697c +TERMUX_PKG_SHA256=24887b92e2afd4a2ac602419ad4b596372f67ac9b077190f459aba390faf5550 TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_DEPENDS="gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libexpat, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib" TERMUX_PKG_BUILD_DEPENDS="tk" From 68ba5951c784fe61bc420774a630e51c8c5ae38b Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 3 Oct 2024 13:35:41 +0200 Subject: [PATCH 08/18] fix(scripts): Use termux python version in crossenv prefix Use the termux python version in the crossenv prefix to avoid pointing at a crossenv for an earlier python version in case of developers building locally. --- scripts/build/termux_step_setup_variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/termux_step_setup_variables.sh b/scripts/build/termux_step_setup_variables.sh index 5f14bf0cd0ade1..0f70d2e749384a 100644 --- a/scripts/build/termux_step_setup_variables.sh +++ b/scripts/build/termux_step_setup_variables.sh @@ -187,7 +187,7 @@ termux_step_setup_variables() { TERMUX_PKG_PYTHON_TARGET_DEPS="" # python modules to be installed via pip3 TERMUX_PKG_PYTHON_BUILD_DEPS="" # python modules to be installed via build-pip TERMUX_PKG_PYTHON_COMMON_DEPS="" # python modules to be installed via pip3 or build-pip - TERMUX_PYTHON_CROSSENV_PREFIX="$TERMUX_TOPDIR/python-crossenv-prefix-$TERMUX_PACKAGE_LIBRARY-$TERMUX_ARCH" # python modules dependency location (only used in non-devices) + TERMUX_PYTHON_CROSSENV_PREFIX="$TERMUX_TOPDIR/python${TERMUX_PYTHON_VERSION}-crossenv-prefix-$TERMUX_PACKAGE_LIBRARY-$TERMUX_ARCH" # python modules dependency location (only used in non-devices) TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION} # location of python libraries TERMUX_PKG_MESON_NATIVE=false TERMUX_PKG_CMAKE_CROSSCOMPILING=true From 5b44207222646968cbc386968661a6f1bbea7487 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 00:01:11 +0200 Subject: [PATCH 09/18] fix(main/libtorrent-rasterbar): Fix build with python 3.12 --- packages/libtorrent-rasterbar/7649.patch | 124 ++++++++++++++++++ .../bindings-python-CMakeLists.txt.patch | 21 +++ packages/libtorrent-rasterbar/build.sh | 1 + 3 files changed, 146 insertions(+) create mode 100644 packages/libtorrent-rasterbar/7649.patch create mode 100644 packages/libtorrent-rasterbar/bindings-python-CMakeLists.txt.patch diff --git a/packages/libtorrent-rasterbar/7649.patch b/packages/libtorrent-rasterbar/7649.patch new file mode 100644 index 00000000000000..ad995be0c4a8b7 --- /dev/null +++ b/packages/libtorrent-rasterbar/7649.patch @@ -0,0 +1,124 @@ +From 5970ff3d5eb26e35cf08397f55c2d11311f4f7bd Mon Sep 17 00:00:00 2001 +From: arvidn +Date: Mon, 11 Mar 2024 14:45:52 +0100 +Subject: [PATCH] fix setup.py to not use distutils (as it has been removed in + python 3.12) + +--- + bindings/python/setup.py | 47 +++++++++--------------------------- + 2 files changed, 13 insertions(+), 36 deletions(-) + +diff --git a/bindings/python/setup.py b/bindings/python/setup.py +index 0eb07c2b5c6..d720c475beb 100644 +--- a/bindings/python/setup.py ++++ b/bindings/python/setup.py +@@ -1,14 +1,9 @@ + #!/usr/bin/env python3 + + import contextlib +-from distutils import log +-import distutils.cmd +-import distutils.command.install_data as install_data_lib +-import distutils.debug +-import distutils.errors +-import distutils.sysconfig + import functools + import itertools ++import logging as log + import os + import pathlib + import re +@@ -75,11 +70,11 @@ def b2_version() -> Tuple[int, ...]: + class B2Distribution(setuptools.Distribution): + def reinitialize_command( + self, command: str, reinit_subcommands: int = 0 +- ) -> distutils.cmd.Command: ++ ) -> setuptools.Command: + if command == "build_ext": +- return cast(distutils.cmd.Command, self.get_command_obj("build_ext")) ++ return cast(setuptools.Command, self.get_command_obj("build_ext")) + return cast( +- distutils.cmd.Command, ++ setuptools.Command, + super().reinitialize_command( + command, reinit_subcommands=reinit_subcommands + ), +@@ -155,13 +150,11 @@ def write_b2_python_config( + # other words we apply debian's override everywhere, and hope no other + # overrides ever disagree with us. + +- # Note that sysconfig and distutils.sysconfig disagree here, especially on +- # windows. +- ext_suffix = distutils.sysconfig.get_config_var("EXT_SUFFIX") ++ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") + ext_suffix = str(ext_suffix or "") + + # python.jam appends the platform-specific final suffix on its own. I can't +- # find a consistent value from sysconfig or distutils.sysconfig for this. ++ # find a consistent value from sysconfig for this. + for plat_suffix in (".pyd", ".dll", ".so", ".sl"): + if ext_suffix.endswith(plat_suffix): + ext_suffix = ext_suffix[: -len(plat_suffix)] +@@ -271,7 +264,7 @@ def finalize_options(self) -> None: + super().finalize_options() + + if self.config_mode not in self.CONFIG_MODES: +- raise distutils.errors.DistutilsOptionError( ++ raise setuptools.errors.DistutilsOptionError( + f"--config-mode must be one of {self.CONFIG_MODES}" + ) + +@@ -382,10 +375,10 @@ def _configure_b2_with_distutils(self) -> Iterator[None]: + if os.name == "nt": + self._maybe_add_arg("--abbreviate-paths") + +- if distutils.debug.DEBUG: +- self._maybe_add_arg("--debug-configuration") +- self._maybe_add_arg("--debug-building") +- self._maybe_add_arg("--debug-generators") ++ # if distutils.debug.DEBUG: ++ # self._maybe_add_arg("--debug-configuration") ++ # self._maybe_add_arg("--debug-building") ++ # self._maybe_add_arg("--debug-generators") + + if sys.platform == "darwin": + # boost.build defaults to toolset=clang on mac. However python.jam +@@ -411,7 +404,7 @@ def _configure_b2_with_distutils(self) -> Iterator[None]: + # macOS uses multi-arch binaries. Attempt to match the + # configuration of the running python by translating distutils + # platform modes to b2 architecture modes +- machine = distutils.util.get_platform().split("-")[-1] ++ machine = sysconfig.get_platform().split("-")[-1] + if machine == "arm64": + self._maybe_add_arg("architecture=arm") + elif machine in ("ppc", "ppc64"): +@@ -500,21 +493,6 @@ def _find_project_config(self) -> Optional[pathlib.Path]: + return None + + +-class InstallDataToLibDir(install_data_lib.install_data): +- def finalize_options(self) -> None: +- # install_data installs to the *base* directory, which is useless. +- # Nothing ever gets installed there, no tools search there. You could +- # only make use of it by manually picking the right install paths. +- # This instead defaults the "install_dir" option to be "install_lib", +- # which is "where packages are normally installed". +- self.set_undefined_options( +- "install", +- ("install_lib", "install_dir"), # note "install_lib" +- ("root", "root"), +- ("force", "force"), +- ) +- +- + def find_all_files(path: str) -> Iterator[str]: + for dirpath, _, filenames in os.walk(path): + for filename in filenames: +@@ -532,7 +510,6 @@ def find_all_files(path: str) -> Iterator[str]: + ext_modules=[StubExtension("libtorrent.__init__")], + cmdclass={ + "build_ext": LibtorrentBuildExt, +- "install_data": InstallDataToLibDir, + }, + distclass=B2Distribution, + data_files=[ diff --git a/packages/libtorrent-rasterbar/bindings-python-CMakeLists.txt.patch b/packages/libtorrent-rasterbar/bindings-python-CMakeLists.txt.patch new file mode 100644 index 00000000000000..b3beeb8396c29f --- /dev/null +++ b/packages/libtorrent-rasterbar/bindings-python-CMakeLists.txt.patch @@ -0,0 +1,21 @@ +diff -u -r ../libtorrent-rasterbar-2.0.10/bindings/python/CMakeLists.txt ./bindings/python/CMakeLists.txt +--- ../libtorrent-rasterbar-2.0.10/bindings/python/CMakeLists.txt 2024-02-19 12:16:53.000000000 +0000 ++++ ./bindings/python/CMakeLists.txt 2024-10-04 21:47:58.878498289 +0000 +@@ -19,7 +19,7 @@ + # See https://devguide.python.org/#status-of-python-branches for supported python versions + function(_get_compatible_python_versions _ret) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 20) +- list(APPEND _tmp 3.6 3.7 3.8 3.9 3.10 3.11) ++ list(APPEND _tmp 3.6 3.7 3.8 3.9 3.10 3.11 3.12) + endif() + set(${_ret} ${_tmp} PARENT_SCOPE) + endfunction() +@@ -95,7 +95,7 @@ + else() + execute_process( + COMMAND "${Python3_EXECUTABLE}" -c [=[ +-import distutils.sysconfig ++from setuptools import distutils + print(distutils.sysconfig.get_python_lib(prefix='', plat_specific=True)) + ]=] + OUTPUT_VARIABLE _PYTHON3_SITE_ARCH diff --git a/packages/libtorrent-rasterbar/build.sh b/packages/libtorrent-rasterbar/build.sh index d90a21b7d31970..e76f66a0a8496c 100644 --- a/packages/libtorrent-rasterbar/build.sh +++ b/packages/libtorrent-rasterbar/build.sh @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="A feature complete C++ bittorrent implementation focusin TERMUX_PKG_LICENSE="BSD 3-Clause" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="2.0.10" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://github.com/arvidn/libtorrent/releases/download/v${TERMUX_PKG_VERSION}/libtorrent-rasterbar-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=fc935b8c1daca5c0a4d304bff59e64e532be16bb877c012aea4bda73d9ca885d TERMUX_PKG_AUTO_UPDATE=true From dd845907b0f8472211de31ed2e3b7f602a64121f Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 00:01:34 +0200 Subject: [PATCH 10/18] revbump(python-numpy): Revbump after python 3.12 update --- packages/python-numpy/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/python-numpy/build.sh b/packages/python-numpy/build.sh index 2e97a745e67c81..c29b2a7ecf2847 100644 --- a/packages/python-numpy/build.sh +++ b/packages/python-numpy/build.sh @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="The fundamental package for scientific computing with Py TERMUX_PKG_LICENSE="BSD 3-Clause" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="2.1.2" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=git+https://github.com/numpy/numpy TERMUX_PKG_DEPENDS="libc++, libopenblas, python" TERMUX_PKG_AUTO_UPDATE=true From e0ab9036c6ae05e134eee20f662d24e0f69feb9f Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 00:19:22 +0200 Subject: [PATCH 11/18] fix(main/borgbackup): Fix building with python 3.12 Remove pinning of setuptools to 65 to fix build with python 3.12. --- packages/borgbackup/build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/borgbackup/build.sh b/packages/borgbackup/build.sh index 80558ff99cfdeb..095552f5360375 100644 --- a/packages/borgbackup/build.sh +++ b/packages/borgbackup/build.sh @@ -3,13 +3,11 @@ TERMUX_PKG_DESCRIPTION="Deduplicating and compressing backup program" TERMUX_PKG_LICENSE="BSD 3-Clause" TERMUX_PKG_MAINTAINER="Joshua Kahn @TomJo2000" TERMUX_PKG_VERSION="1.4.0" -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 TERMUX_PKG_SRCURL=https://github.com/borgbackup/borg/releases/download/${TERMUX_PKG_VERSION}/borgbackup-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=c54c45155643fa66fed7f9ff2d134ea0a58d0ac197c18781ddc2fb236bf6ed29 TERMUX_PKG_DEPENDS="libacl, liblz4, openssl, python, xxhash, zstd" -# FIXME: Force use setuptools 65. This should be no more needed after PR 18078 -# FIXME: is merged or builder image bumps to Ubuntu 24. -TERMUX_PKG_PYTHON_COMMON_DEPS="build, Cython, pkgconfig, 'setuptools==65.7.0', setuptools-scm, wheel" +TERMUX_PKG_PYTHON_COMMON_DEPS="build, Cython, pkgconfig, setuptools, setuptools-scm, wheel" TERMUX_PKG_PYTHON_TARGET_DEPS="'msgpack==1.0.8', packaging" TERMUX_PKG_AUTO_UPDATE=true From 2f4afa58b8929bf3835b934779a3b2b3efdc13ef Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 00:20:05 +0200 Subject: [PATCH 12/18] fix(main/python-pyarrow): Fix building with python 3.12 Remove pinning of setuptools to 65 to fix build with python 3.12. --- packages/python-pyarrow/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/python-pyarrow/build.sh b/packages/python-pyarrow/build.sh index bf510836e78dd7..d597134c724a7b 100644 --- a/packages/python-pyarrow/build.sh +++ b/packages/python-pyarrow/build.sh @@ -4,13 +4,13 @@ TERMUX_PKG_LICENSE="Apache-2.0" TERMUX_PKG_MAINTAINER="@termux" # Align the version with `libarrow-cpp` package. TERMUX_PKG_VERSION="17.0.0" -TERMUX_PKG_REVISION=2 +TERMUX_PKG_REVISION=3 TERMUX_PKG_SRCURL=https://github.com/apache/arrow/archive/refs/tags/apache-arrow-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=8379554d89f19f2c8db63620721cabade62541f47a4e706dfb0a401f05a713ef TERMUX_PKG_AUTO_UPDATE=true TERMUX_PKG_UPDATE_METHOD=repology TERMUX_PKG_DEPENDS="abseil-cpp, libarrow-cpp (>= ${TERMUX_PKG_VERSION}), libc++, python, python-numpy" -TERMUX_PKG_PYTHON_COMMON_DEPS="build, Cython, numpy, 'setuptools==65.7.0', setuptools-scm, wheel" +TERMUX_PKG_PYTHON_COMMON_DEPS="build, Cython, numpy, setuptools, setuptools-scm, wheel" TERMUX_PKG_PROVIDES="libarrow-python" termux_step_pre_configure() { From 3e56094fdecbe5db452507fdcb81fb507ba2e9bb Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 01:13:22 +0200 Subject: [PATCH 13/18] fix(main/python-msgpack): Fix building with python 3.12 Remove pinning of setuptools to 65 to fix build with python 3.12. --- packages/python-msgpack/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/python-msgpack/build.sh b/packages/python-msgpack/build.sh index fb89f7992b94a4..18c385582e487b 100644 --- a/packages/python-msgpack/build.sh +++ b/packages/python-msgpack/build.sh @@ -3,12 +3,13 @@ TERMUX_PKG_DESCRIPTION="MessagePack serializer implementation for Python" TERMUX_PKG_LICENSE="Apache-2.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="1.1.0" +TERMUX_PKG_REVISION=1 # _cmsgpack.c is absent in https://github.com/msgpack/msgpack-python/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SRCURL=https://pypi.org/packages/source/m/msgpack/msgpack-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=dd432ccc2c72b914e4cb77afce64aab761c1137cc698be3984eee260bcb2896e TERMUX_PKG_AUTO_UPDATE=true TERMUX_PKG_DEPENDS="libc++, python" -TERMUX_PKG_PYTHON_COMMON_DEPS="build, Cython, 'setuptools==65.7.0', wheel" +TERMUX_PKG_PYTHON_COMMON_DEPS="build, Cython, setuptools, wheel" termux_step_make() { PYTHONPATH='' python -m build -w -n -x "$TERMUX_PKG_SRCDIR" From 1f7a4d16545b4532fbada9f2d0d884d30f4962aa Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 01:30:15 +0200 Subject: [PATCH 14/18] revbump(x11/pyqt5): Revbump after python 3.12 update --- x11-packages/pyqt5/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x11-packages/pyqt5/build.sh b/x11-packages/pyqt5/build.sh index 20de442b3e1f46..ad53f974088826 100644 --- a/x11-packages/pyqt5/build.sh +++ b/x11-packages/pyqt5/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Comprehensive Python Bindings for Qt v5" TERMUX_PKG_LICENSE="GPL-3.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="5.15.10" -TERMUX_PKG_REVISION=2 +TERMUX_PKG_REVISION=3 TERMUX_PKG_SRCURL=https://files.pythonhosted.org/packages/source/P/PyQt5/PyQt5-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=d46b7804b1b10a4ff91753f8113e5b5580d2b4462f3226288e2d84497334898a TERMUX_PKG_DEPENDS="libc++, python, qt5-qtbase, qt5-qtdeclarative, qt5-qtlocation, qt5-qtmultimedia, qt5-qtsensors, qt5-qtsvg, qt5-qttools, qt5-qtwebchannel, qt5-qtwebkit, qt5-qtwebsockets, qt5-qtx11extras, qt5-qtxmlpatterns, python-pip" From 1645d25b7785f9f88064aab5d204441aa12a4f6f Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 01:30:56 +0200 Subject: [PATCH 15/18] revbump(main/boost): Revbump after python 3.12 update --- packages/boost/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/boost/build.sh b/packages/boost/build.sh index 50b9037330e857..6b326e47684b69 100644 --- a/packages/boost/build.sh +++ b/packages/boost/build.sh @@ -5,7 +5,7 @@ TERMUX_PKG_MAINTAINER="@termux" # Never forget to always bump revision of reverse dependencies and rebuild them # when bumping version. TERMUX_PKG_VERSION="1.83.0" -TERMUX_PKG_REVISION=2 +TERMUX_PKG_REVISION=3 TERMUX_PKG_SRCURL=https://boostorg.jfrog.io/artifactory/main/release/$TERMUX_PKG_VERSION/source/boost_${TERMUX_PKG_VERSION//./_}.tar.bz2 TERMUX_PKG_SHA256=6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e TERMUX_PKG_AUTO_UPDATE=false From 21f4fc542293a565e56c87da4f339e07d8577fe1 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 01:35:28 +0200 Subject: [PATCH 16/18] chore(disabled-packages/python3.11): Add disabled copy of python3.11 --- .../python3.11/0001-fix-hardcoded-paths.patch | 78 +++++++++++ .../python3.11/0002-no-setuid-servers.patch | 34 +++++ .../0003-ctypes-util-use-llvm-tools.patch | 31 +++++ .../python3.11/0004-impl-getprotobyname.patch | 77 ++++++++++ .../0005-impl-multiprocessing.patch | 131 ++++++++++++++++++ .../python3.11/0006-do-not-use-xattr.patch | 13 ++ .../python3.11/0007-disable-multiarch.patch | 13 ++ .../python3.11/0008-do-not-use-link.patch | 10 ++ .../python3.11/0009-build-with-fPIC.patch | 11 ++ .../python3.11/0010-use-android-logging.patch | 12 ++ .../0011-disable-parallel-build.patch | 13 ++ .../0012-do-not-include-langinfo.patch | 14 ++ disabled-packages/python3.11/build.sh | 130 +++++++++++++++++ .../python-ensurepip-wheels.subpackage.sh | 7 + .../python3.11/python-tkinter.subpackage.sh | 13 ++ 15 files changed, 587 insertions(+) create mode 100644 disabled-packages/python3.11/0001-fix-hardcoded-paths.patch create mode 100644 disabled-packages/python3.11/0002-no-setuid-servers.patch create mode 100644 disabled-packages/python3.11/0003-ctypes-util-use-llvm-tools.patch create mode 100644 disabled-packages/python3.11/0004-impl-getprotobyname.patch create mode 100644 disabled-packages/python3.11/0005-impl-multiprocessing.patch create mode 100644 disabled-packages/python3.11/0006-do-not-use-xattr.patch create mode 100644 disabled-packages/python3.11/0007-disable-multiarch.patch create mode 100644 disabled-packages/python3.11/0008-do-not-use-link.patch create mode 100644 disabled-packages/python3.11/0009-build-with-fPIC.patch create mode 100644 disabled-packages/python3.11/0010-use-android-logging.patch create mode 100644 disabled-packages/python3.11/0011-disable-parallel-build.patch create mode 100644 disabled-packages/python3.11/0012-do-not-include-langinfo.patch create mode 100644 disabled-packages/python3.11/build.sh create mode 100644 disabled-packages/python3.11/python-ensurepip-wheels.subpackage.sh create mode 100644 disabled-packages/python3.11/python-tkinter.subpackage.sh diff --git a/disabled-packages/python3.11/0001-fix-hardcoded-paths.patch b/disabled-packages/python3.11/0001-fix-hardcoded-paths.patch new file mode 100644 index 00000000000000..16a7a683194ea1 --- /dev/null +++ b/disabled-packages/python3.11/0001-fix-hardcoded-paths.patch @@ -0,0 +1,78 @@ +--- a/Lib/aifc.py ++++ b/Lib/aifc.py +@@ -920,7 +920,7 @@ + if __name__ == '__main__': + import sys + if not sys.argv[1:]: +- sys.argv.append('/usr/demos/data/audio/bach.aiff') ++ sys.argv.append('@TERMUX_PREFIX@/demos/data/audio/bach.aiff') + fn = sys.argv[1] + with open(fn, 'r') as f: + print("Reading", fn) +--- a/Lib/mailcap.py ++++ b/Lib/mailcap.py +@@ -55,7 +55,8 @@ + # Don't bother with getpwuid() + home = '.' # Last resort + mailcaps = [home + '/.mailcap', '/etc/mailcap', +- '/usr/etc/mailcap', '/usr/local/etc/mailcap'] ++ '/usr/etc/mailcap', '/usr/local/etc/mailcap', ++ '@TERMUX_PREFIX@/etc/mailcap'] + return mailcaps + + +--- a/Lib/mimetypes.py ++++ b/Lib/mimetypes.py +@@ -49,6 +49,7 @@ + "/usr/local/lib/netscape/mime.types", + "/usr/local/etc/httpd/conf/mime.types", # Apache 1.2 + "/usr/local/etc/mime.types", # Apache 1.3 ++ "@TERMUX_PREFIX@/etc/mime.types", # Termux + ] + + inited = False +--- a/Lib/posixpath.py ++++ b/Lib/posixpath.py +@@ -32,7 +32,7 @@ + extsep = '.' + sep = '/' + pathsep = ':' +-defpath = '/bin:/usr/bin' ++defpath = '@TERMUX_PREFIX@/bin' + altsep = None + devnull = '/dev/null' + +--- a/Lib/uuid.py ++++ b/Lib/uuid.py +@@ -361,7 +361,6 @@ + + try: + path_dirs = os.environ.get('PATH', os.defpath).split(os.pathsep) +- path_dirs.extend(['/sbin', '/usr/sbin']) + executable = shutil.which(command, path=os.pathsep.join(path_dirs)) + if executable is None: + return None +--- a/Lib/subprocess.py ++++ b/Lib/subprocess.py +@@ -1389,9 +1389,7 @@ + args = list(args) + + if shell: +- # On Android the default shell is at '/system/bin/sh'. +- unix_shell = ('/system/bin/sh' if +- hasattr(sys, 'getandroidapilevel') else '/bin/sh') ++ unix_shell = ('@TERMUX_PREFIX@/bin/sh') + args = [unix_shell, "-c"] + args + if executable: + args[0] = executable +--- a/Lib/tempfile.py ++++ b/Lib/tempfile.py +@@ -124,7 +124,7 @@ + if _os.name == 'nt': + dirlist.extend([ r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ]) + else: +- dirlist.extend([ '/tmp', '/var/tmp', '/usr/tmp' ]) ++ dirlist.extend([ '@TERMUX_PREFIX@/tmp' ]) + + # As a last resort, the current directory. + try: diff --git a/disabled-packages/python3.11/0002-no-setuid-servers.patch b/disabled-packages/python3.11/0002-no-setuid-servers.patch new file mode 100644 index 00000000000000..1be01d43f894e2 --- /dev/null +++ b/disabled-packages/python3.11/0002-no-setuid-servers.patch @@ -0,0 +1,34 @@ +--- a/Lib/http/server.py ++++ b/Lib/http/server.py +@@ -1165,10 +1165,6 @@ + return + # Child + try: +- try: +- os.setuid(nobody) +- except OSError: +- pass + os.dup2(self.rfile.fileno(), 0) + os.dup2(self.wfile.fileno(), 1) + os.execve(scriptfile, args, env) +--- a/Lib/smtpd.py ++++ b/Lib/smtpd.py +@@ -9,7 +9,8 @@ + -n + This program generally tries to setuid `nobody', unless this flag is + set. The setuid call will fail if this program is not run as root (in +- which case, use this flag). ++ which case, use this flag). Ignored in Termux as no setuid done on this ++ platform. + + --version + -V +@@ -863,7 +864,7 @@ + + + class Options: +- setuid = True ++ setuid = False + classname = 'PureProxy' + size_limit = None + enable_SMTPUTF8 = False diff --git a/disabled-packages/python3.11/0003-ctypes-util-use-llvm-tools.patch b/disabled-packages/python3.11/0003-ctypes-util-use-llvm-tools.patch new file mode 100644 index 00000000000000..3b5b6bf3146c8b --- /dev/null +++ b/disabled-packages/python3.11/0003-ctypes-util-use-llvm-tools.patch @@ -0,0 +1,31 @@ +https://github.com/termux/termux-packages/issues/8478 + +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -172,7 +172,7 @@ + # assuming GNU binutils / ELF + if not f: + return None +- objdump = shutil.which('objdump') ++ objdump = shutil.which('llvm-objdump') + if not objdump: + # objdump is not available, give up + return None +@@ -209,7 +209,7 @@ + expr = os.fsencode(expr) + + try: +- proc = subprocess.Popen(('/sbin/ldconfig', '-r'), ++ proc = subprocess.Popen(('@TERMUX_PREFIX@/bin/ldconfig', '-r'), + stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL) + except OSError: # E.g. command not found +@@ -300,7 +300,7 @@ + def _findLib_ld(name): + # See issue #9998 for why this is needed + expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) +- cmd = ['ld', '-t'] ++ cmd = ['ld.lld', '-t'] + libpath = os.environ.get('LD_LIBRARY_PATH') + if libpath: + for d in libpath.split(':'): diff --git a/disabled-packages/python3.11/0004-impl-getprotobyname.patch b/disabled-packages/python3.11/0004-impl-getprotobyname.patch new file mode 100644 index 00000000000000..86dc57b7f4a75f --- /dev/null +++ b/disabled-packages/python3.11/0004-impl-getprotobyname.patch @@ -0,0 +1,77 @@ +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -5373,17 +5373,74 @@ + This only returns the protocol number, since the other info is + already known or not useful (like the list of aliases). */ + ++#ifdef __ANDROID__ ++struct protocol_name_and_number { ++ char* name; ++ int number; ++}; ++#endif ++ + /*ARGSUSED*/ + static PyObject * + socket_getprotobyname(PyObject *self, PyObject *args) + { ++#ifdef __ANDROID__ ++ /* http://git.musl-libc.org/cgit/musl/tree/src/network/proto.c */ ++ static const struct protocol_name_and_number protocols[] = { ++ {"ip", 0}, ++ {"icmp", 1}, ++ {"igmp", 2}, ++ {"ggp", 3}, ++ {"ipencap", 4}, ++ {"st", 5}, ++ {"tcp", 6}, ++ {"egp", 8}, ++ {"pup", 12}, ++ {"udp", 17}, ++ {"hmp", 20}, ++ {"xns-idp", 22}, ++ {"iso-tp4", 29}, ++ {"xtp", 36}, ++ {"ddp", 37}, ++ {"idpr-cmtp", 38}, ++ {"ipv6", 41}, ++ {"ipv6-route", 43}, ++ {"ipv6-frag", 44}, ++ {"idrp", 45}, ++ {"rsvp", 46}, ++ {"gre", 47}, ++ {"esp", 50}, ++ {"ah", 51}, ++ {"skip", 57}, ++ {"ipv6-icmp", 58}, ++ {"ipv6-nonxt", 59}, ++ {"ipv6-opts", 60}, ++ {"rspf", 73}, ++ {"vmtp", 81}, ++ {"ospf", 89}, ++ {"ipip", 94}, ++ {"encap", 98}, ++ {"pim", 103}, ++ {"raw", 255} ++ }; ++ int i; ++#endif + const char *name; + struct protoent *sp; + if (!PyArg_ParseTuple(args, "s:getprotobyname", &name)) + return NULL; ++#ifdef __ANDROID__ ++ for (i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { ++ if (strcmp(protocols[i].name, name) == 0) { ++ return PyLong_FromLong((long) protocols[i].number); ++ } ++ } ++ sp = NULL; ++#else + Py_BEGIN_ALLOW_THREADS + sp = getprotobyname(name); + Py_END_ALLOW_THREADS ++#endif + if (sp == NULL) { + PyErr_SetString(PyExc_OSError, "protocol not found"); + return NULL; diff --git a/disabled-packages/python3.11/0005-impl-multiprocessing.patch b/disabled-packages/python3.11/0005-impl-multiprocessing.patch new file mode 100644 index 00000000000000..a5fe39cd45c847 --- /dev/null +++ b/disabled-packages/python3.11/0005-impl-multiprocessing.patch @@ -0,0 +1,131 @@ +--- a/setup.py ++++ b/setup.py +@@ -1328,8 +1329,8 @@ + sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED') + ): + multiprocessing_srcs.append('_multiprocessing/semaphore.c') +- self.addext(Extension('_multiprocessing', multiprocessing_srcs)) +- self.addext(Extension('_posixshmem', ['_multiprocessing/posixshmem.c'])) ++ self.addext(Extension('_multiprocessing', multiprocessing_srcs, libraries=["android-posix-semaphore"])) ++ self.addext(Extension('_posixshmem', ['_multiprocessing/posixshmem.c','_multiprocessing/posix-shm-extension.c'])) + + def detect_uuid(self): + # Build the _uuid module if possible + +--- a/Lib/multiprocessing/heap.py ++++ b/Lib/multiprocessing/heap.py +@@ -70,7 +70,7 @@ + """ + + if sys.platform == 'linux': +- _dir_candidates = ['/dev/shm'] ++ _dir_candidates = [] + else: + _dir_candidates = [] + + +--- a/Modules/_multiprocessing/multiprocessing.c ++++ b/Modules/_multiprocessing/multiprocessing.c +@@ -172,7 +172,7 @@ + _MULTIPROCESSING_RECV_METHODDEF + _MULTIPROCESSING_SEND_METHODDEF + #endif +-#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__) ++#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) + _MULTIPROCESSING_SEM_UNLINK_METHODDEF + #endif + {NULL} + +--- a/Modules/_multiprocessing/posixshmem.c ++++ b/Modules/_multiprocessing/posixshmem.c +@@ -11,6 +11,9 @@ + #include + #endif + ++int shm_open(const char *, int, mode_t); ++int shm_unlink(const char *); ++ + /*[clinic input] + module _posixshmem + [clinic start generated code]*/ + +--- a/Modules/_multiprocessing/posix-shm-extension.c ++++ b/Modules/_multiprocessing/posix-shm-extension.c +@@ -0,0 +1,76 @@ ++/* This file is a port of posix shared memory for Python3 on Termux Android, ++ based on musl-libc which is licensed under the following standard MIT ++ license. The ported files are listed as following. ++ ++ File(s): src/mman/shm_open.c ++ ++ Copyright © 2005-2020 Rich Felker, et al. ++ ++ Permission is hereby granted, free of charge, to any person obtaining ++ a copy of this software and associated documentation files (the ++ "Software"), to deal in the Software without restriction, including ++ without limitation the rights to use, copy, modify, merge, publish, ++ distribute, sublicense, and/or sell copies of the Software, and to ++ permit persons to whom the Software is furnished to do so, subject to ++ the following conditions: ++ ++ The above copyright notice and this permission notice shall be ++ included in all copies or substantial portions of the Software. ++ ++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ++ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY ++ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#include // open() ++#include // strlen(), memcpy() ++#include // errno ++#include // NAME_MAX ++#include // unlink() ++ ++#define SHM_PREFIX "@TERMUX_PREFIX@/tmp/shm." ++ ++static __inline__ char *__strchrnul(const char *s, int c) ++{ ++ c = (unsigned char)c; ++ if (!c) return (char *)s + strlen(s); ++ for (; *s && *(unsigned char *)s != c; s++); ++ return (char *)s; ++} ++ ++static char *__shm_mapname(const char *name, char *buf) ++{ ++ char *p; ++ while (*name == '/') name++; ++ if (*(p = __strchrnul(name, '/')) || p==name || ++ (p-name <= 2 && name[0]=='.' && p[-1]=='.')) { ++ errno = EINVAL; ++ return 0; ++ } ++ if (p-name > NAME_MAX-4) { ++ errno = ENAMETOOLONG; ++ return 0; ++ } ++ memcpy(buf, SHM_PREFIX, strlen(SHM_PREFIX)); ++ memcpy(buf+strlen(SHM_PREFIX), name, p-name+1); ++ return buf; ++} ++ ++int shm_open(const char *name, int flag, mode_t mode) ++{ ++ char buf[NAME_MAX+strlen(SHM_PREFIX)+1]; ++ if (!(name = __shm_mapname(name, buf))) return -1; ++ int fd = open(name, flag|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK, mode); ++ return fd; ++} ++ ++int shm_unlink(const char *name) ++{ ++ char buf[NAME_MAX+strlen(SHM_PREFIX)+1]; ++ if (!(name = __shm_mapname(name, buf))) return -1; ++ return unlink(name); ++} + diff --git a/disabled-packages/python3.11/0006-do-not-use-xattr.patch b/disabled-packages/python3.11/0006-do-not-use-xattr.patch new file mode 100644 index 00000000000000..1f4996315c4a9c --- /dev/null +++ b/disabled-packages/python3.11/0006-do-not-use-xattr.patch @@ -0,0 +1,13 @@ +https://github.com/termux/termux-packages/issues/16879 + +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -280,7 +280,7 @@ + # undef HAVE_SCHED_SETAFFINITY + #endif + +-#if defined(HAVE_SYS_XATTR_H) && defined(HAVE_LINUX_LIMITS_H) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) ++#if defined(HAVE_SYS_XATTR_H) && defined(HAVE_LINUX_LIMITS_H) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) && !defined(__ANDROID__) + # define USE_XATTRS + # include // Needed for XATTR_SIZE_MAX on musl libc. + #endif diff --git a/disabled-packages/python3.11/0007-disable-multiarch.patch b/disabled-packages/python3.11/0007-disable-multiarch.patch new file mode 100644 index 00000000000000..dd4c4ab35f41a2 --- /dev/null +++ b/disabled-packages/python3.11/0007-disable-multiarch.patch @@ -0,0 +1,13 @@ +https://github.com/termux/termux-packages/issues/11870 + +--- a/configure ++++ b/configure +@@ -6202,6 +6202,8 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multiarch" >&5 + $as_echo_n "checking for multiarch... " >&6; } + case $ac_sys_system in #( ++ Linux-android) : ++ MULTIARCH="" ;; #( + Darwin*) : + MULTIARCH="" ;; #( + FreeBSD*) : diff --git a/disabled-packages/python3.11/0008-do-not-use-link.patch b/disabled-packages/python3.11/0008-do-not-use-link.patch new file mode 100644 index 00000000000000..b65cf0c7fcaab2 --- /dev/null +++ b/disabled-packages/python3.11/0008-do-not-use-link.patch @@ -0,0 +1,10 @@ +--- a/configure ++++ b/configure +@@ -15331,7 +15333,6 @@ + $as_echo "$ac_cv_func_link" >&6; } + if test "x$ac_cv_func_link" = xyes; then : + +-$as_echo "#define HAVE_LINK 1" >>confdefs.h + + fi + diff --git a/disabled-packages/python3.11/0009-build-with-fPIC.patch b/disabled-packages/python3.11/0009-build-with-fPIC.patch new file mode 100644 index 00000000000000..233c0f341932aa --- /dev/null +++ b/disabled-packages/python3.11/0009-build-with-fPIC.patch @@ -0,0 +1,11 @@ +--- a/configure ++++ b/configure +@@ -11027,7 +11029,7 @@ + then CCSHARED="-fPIC"; + else CCSHARED="+z"; + fi;; +- Linux-android*) ;; ++ Linux-android*) CCSHARED="-fPIC";; + Linux*|GNU*) CCSHARED="-fPIC";; + Emscripten*|WASI*) + if test "x$enable_wasm_dynamic_linking" = xyes; then : diff --git a/disabled-packages/python3.11/0010-use-android-logging.patch b/disabled-packages/python3.11/0010-use-android-logging.patch new file mode 100644 index 00000000000000..6d3cea77cd0fc6 --- /dev/null +++ b/disabled-packages/python3.11/0010-use-android-logging.patch @@ -0,0 +1,12 @@ +--- a/setup.py ++++ b/setup.py +@@ -981,7 +981,8 @@ + + # Lance Ellinghaus's syslog module + # syslog daemon interface +- self.addext(Extension('syslog', ['syslogmodule.c'])) ++ # Termux: Add 'log' android library since we use android logging ++ self.addext(Extension('syslog', ['syslogmodule.c'], libraries=['log'])) + + # Python interface to subinterpreter C-API. + self.addext(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'])) diff --git a/disabled-packages/python3.11/0011-disable-parallel-build.patch b/disabled-packages/python3.11/0011-disable-parallel-build.patch new file mode 100644 index 00000000000000..5c0695af2bed82 --- /dev/null +++ b/disabled-packages/python3.11/0011-disable-parallel-build.patch @@ -0,0 +1,13 @@ +https://github.com/termux/termux-packages/issues/15908 + +--- a/setup.py ++++ b/setup.py +@@ -306,8 +306,6 @@ + self.failed_on_import = [] + self.missing = [] + self.disabled_configure = [] +- if '-j' in os.environ.get('MAKEFLAGS', ''): +- self.parallel = True + + def add(self, ext): + self.extensions.append(ext) diff --git a/disabled-packages/python3.11/0012-do-not-include-langinfo.patch b/disabled-packages/python3.11/0012-do-not-include-langinfo.patch new file mode 100644 index 00000000000000..d6a0700931cb6d --- /dev/null +++ b/disabled-packages/python3.11/0012-do-not-include-langinfo.patch @@ -0,0 +1,14 @@ +We use libandroid-support when building Python, but Python does not +use LDFLAGS when building modules (and not much point in this case). + +--- a/Modules/_cursesmodule.c ++++ b/Modules/_cursesmodule.c +@@ -121,7 +121,7 @@ + #include + #endif + +-#ifdef HAVE_LANGINFO_H ++#if defined(HAVE_LANGINFO_H) && !defined(__ANDROID__) + #include + #endif + diff --git a/disabled-packages/python3.11/build.sh b/disabled-packages/python3.11/build.sh new file mode 100644 index 00000000000000..f187c9328a606b --- /dev/null +++ b/disabled-packages/python3.11/build.sh @@ -0,0 +1,130 @@ +TERMUX_PKG_HOMEPAGE=https://python.org/ +TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear programs" +# License: PSF-2.0 +TERMUX_PKG_LICENSE="custom" +TERMUX_PKG_LICENSE_FILE="LICENSE" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=3.11.10 +TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz +TERMUX_PKG_SHA256=07a4356e912900e61a15cb0949a06c4a05012e213ecd6b4e84d0f67aabbee372 +TERMUX_PKG_AUTO_UPDATE=false +TERMUX_PKG_DEPENDS="gdbm, libandroid-posix-semaphore, libandroid-support, libbz2, libcrypt, libexpat, libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline, zlib" +TERMUX_PKG_BUILD_DEPENDS="tk" +TERMUX_PKG_RECOMMENDS="python-ensurepip-wheels, python-pip" +TERMUX_PKG_SUGGESTS="python-tkinter" +TERMUX_PKG_BREAKS="python2 (<= 2.7.15), python-dev" +TERMUX_PKG_REPLACES="python-dev" +# Let "python3" will be alias to this package. +TERMUX_PKG_PROVIDES="python3" + +# https://github.com/termux/termux-packages/issues/15908 +TERMUX_PKG_MAKE_PROCESSES=1 + +_MAJOR_VERSION="${TERMUX_PKG_VERSION%.*}" + +# Set ac_cv_func_wcsftime=no to avoid errors such as "character U+ca0025 is not in range [U+0000; U+10ffff]" +# when executing e.g. "from time import time, strftime, localtime; print(strftime(str('%Y-%m-%d %H:%M'), localtime()))" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_func_wcsftime=no" +# Avoid trying to include which does not exist on android-21: +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_ftime=no" +# Avoid trying to use AT_EACCESS which is not defined: +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_faccessat=no" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --build=$TERMUX_BUILD_TUPLE --with-system-ffi --with-system-expat --without-ensurepip" +# Hard links does not work on Android 6: +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_linkat=no" +# Do not assume getaddrinfo is buggy when cross compiling: +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_buggy_getaddrinfo=no" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --enable-loadable-sqlite-extensions" +# Fix https://github.com/termux/termux-packages/issues/2236: +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_little_endian_double=yes" +# Force enable posix semaphores. +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_posix_semaphores_enabled=yes" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_sem_open=yes" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_sem_timedwait=yes" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_sem_getvalue=yes" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_sem_unlink=yes" +# Force enable posix shared memory. +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_shm_open=yes" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_shm_unlink=yes" + +TERMUX_PKG_RM_AFTER_INSTALL=" +lib/python${_MAJOR_VERSION}/test +lib/python${_MAJOR_VERSION}/*/test +lib/python${_MAJOR_VERSION}/*/tests +lib/python${_MAJOR_VERSION}/site-packages/*/ +" + +termux_step_pre_configure() { + # -O3 gains some additional performance on at least aarch64. + CFLAGS="${CFLAGS/-Oz/-O3}" + + # Needed when building with clang, as setup.py only probes + # gcc for include paths when finding headers for determining + # if extension modules should be built (specifically, the + # zlib extension module is not built without this): + CPPFLAGS+=" -I$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include" + LDFLAGS+=" -L$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib" + if [ $TERMUX_ARCH = x86_64 ]; then LDFLAGS+=64; fi + + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then + # Python's configure script fails with + # Fatal: you must define __ANDROID_API__ + # if __ANDROID_API__ is not defined. + CPPFLAGS+=" -D__ANDROID_API__=$(getprop ro.build.version.sdk)" + else + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-build-python=python$_MAJOR_VERSION" + fi + + export LIBCRYPT_LIBS="-lcrypt" +} + +termux_step_post_make_install() { + (cd $TERMUX_PREFIX/bin + ln -sf idle${_MAJOR_VERSION} idle + ln -sf python${_MAJOR_VERSION} python + ln -sf python${_MAJOR_VERSION}-config python-config + ln -sf pydoc${_MAJOR_VERSION} pydoc) + (cd $TERMUX_PREFIX/share/man/man1 + ln -sf python${_MAJOR_VERSION}.1 python.1) +} + +termux_step_post_massage() { + # Verify that desired modules have been included: + for module in _bz2 _curses _lzma _sqlite3 _ssl _tkinter zlib; do + if [ ! -f "${TERMUX_PREFIX}/lib/python${_MAJOR_VERSION}/lib-dynload/${module}".*.so ]; then + termux_error_exit "Python module library $module not built" + fi + done +} + +termux_step_create_debscripts() { + # This is a temporary script and will therefore be removed when python is updated to 3.12 + cat <<- POSTINST_EOF > ./postinst + #!$TERMUX_PREFIX/bin/bash + + if [[ -f "$TERMUX_PREFIX/bin/pip" && \ + ! (("$TERMUX_PACKAGE_FORMAT" = "debian" && -f $TERMUX_PREFIX/var/lib/dpkg/info/python-pip.list) || \ + ("$TERMUX_PACKAGE_FORMAT" = "pacman" && \$(ls $TERMUX_PREFIX/var/lib/pacman/local/python-pip-* 2>/dev/null))) ]]; then + echo "Removing pip..." + rm -f $TERMUX_PREFIX/bin/pip $TERMUX_PREFIX/bin/pip3* $TERMUX_PREFIX/bin/easy_install $TERMUX_PREFIX/bin/easy_install-3* + rm -Rf $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/site-packages/pip + rm -Rf ${TERMUX_PREFIX}/lib/python${_MAJOR_VERSION}/site-packages/pip-*.dist-info + fi + + if [ ! -f "$TERMUX_PREFIX/bin/pip" ]; then + echo + echo "== Note: pip is now separate from python ==" + echo "To install, enter the following command:" + echo " pkg install python-pip" + echo + fi + + exit 0 + POSTINST_EOF + + chmod 0755 postinst + + if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ]; then + echo "post_install" > postupg + fi +} diff --git a/disabled-packages/python3.11/python-ensurepip-wheels.subpackage.sh b/disabled-packages/python3.11/python-ensurepip-wheels.subpackage.sh new file mode 100644 index 00000000000000..283b44c8fbfd3e --- /dev/null +++ b/disabled-packages/python3.11/python-ensurepip-wheels.subpackage.sh @@ -0,0 +1,7 @@ +TERMUX_SUBPKG_DESCRIPTION="Wheels for Python ensurepip" +TERMUX_SUBPKG_PLATFORM_INDEPENDENT=true +TERMUX_SUBPKG_INCLUDE=" +lib/python${_MAJOR_VERSION}/ensurepip/_bundled/ +" +TERMUX_SUBPKG_BREAKS="python (<< 3.11.1-3)" +TERMUX_SUBPKG_REPLACES="python (<< 3.11.1-3)" diff --git a/disabled-packages/python3.11/python-tkinter.subpackage.sh b/disabled-packages/python3.11/python-tkinter.subpackage.sh new file mode 100644 index 00000000000000..45364d37133bb8 --- /dev/null +++ b/disabled-packages/python3.11/python-tkinter.subpackage.sh @@ -0,0 +1,13 @@ +TERMUX_SUBPKG_DESCRIPTION="Tkinter support for Python 3" +TERMUX_SUBPKG_DEPENDS="tcl, tk" +TERMUX_SUBPKG_INCLUDE=" +bin/idle* +lib/python${_MAJOR_VERSION}/idlelib +lib/python${_MAJOR_VERSION}/tkinter +lib/python${_MAJOR_VERSION}/turtle.py +lib/python${_MAJOR_VERSION}/turtledemo +lib/python${_MAJOR_VERSION}/lib-dynload/_tkinter.*.so +lib/python${_MAJOR_VERSION}/__pycache__/turtle.*.pyc +" +TERMUX_SUBPKG_BREAKS="python (<< 3.11.1-3)" +TERMUX_SUBPKG_REPLACES="python (<< 3.11.1-3)" From a19eea2158c60fb89fd87c6939948097ba7e5506 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 5 Oct 2024 11:45:48 +0200 Subject: [PATCH 17/18] revbump(x11/python-torch): Revbump after python 3.12 update --- x11-packages/python-torch/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/x11-packages/python-torch/build.sh b/x11-packages/python-torch/build.sh index 555036eb230fee..7dea22fd876408 100644 --- a/x11-packages/python-torch/build.sh +++ b/x11-packages/python-torch/build.sh @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Tensors and Dynamic neural networks in Python" TERMUX_PKG_LICENSE="BSD 3-Clause" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="2.4.1" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=git+https://github.com/pytorch/pytorch TERMUX_PKG_UPDATE_TAG_TYPE="latest-release-tag" TERMUX_PKG_DEPENDS="abseil-cpp, ffmpeg, fmt, libc++, libopenblas, libprotobuf, libzmq, opencv, python, python-numpy, python-pip" From ff61dfc3d27c6c4d58b8d3f668b2d7a279adec3b Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sun, 6 Oct 2024 10:13:05 +0200 Subject: [PATCH 18/18] chore(main/python): Inform about the python 3.12 update in postinst --- packages/python/build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/python/build.sh b/packages/python/build.sh index c2408962ecb1f0..44c125e2dae84d 100644 --- a/packages/python/build.sh +++ b/packages/python/build.sh @@ -122,6 +122,14 @@ termux_step_create_debscripts() { echo fi + if [ -d $TERMUX_PREFIX/lib/python3.11/site-packages ]; then + echo + echo "NOTE: The system python package has been updated to 3.12." + echo "NOTE: Run 'pkg upgrade' to update system python packages." + echo "NOTE: Packages installed using pip needs to be re-installed." + echo + fi + exit 0 POSTINST_EOF