From dd12a3a9008f1eda351f48c85fc7dcf9aa1e2b25 Mon Sep 17 00:00:00 2001 From: termux-pacman-bot Date: Sun, 6 Oct 2024 15:09:28 +0000 Subject: [PATCH] Update repo --- .../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 ++ .../build/setup/termux_setup_python_pip.sh | 7 + scripts/build/termux_step_setup_variables.sh | 2 +- 17 files changed, 595 insertions(+), 1 deletion(-) 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 0000000000..16a7a68319 --- /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 0000000000..1be01d43f8 --- /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 0000000000..3b5b6bf314 --- /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 0000000000..86dc57b7f4 --- /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 0000000000..a5fe39cd45 --- /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 0000000000..1f4996315c --- /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 0000000000..dd4c4ab35f --- /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 0000000000..b65cf0c7fc --- /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 0000000000..233c0f3419 --- /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 0000000000..6d3cea77cd --- /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 0000000000..5c0695af2b --- /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 0000000000..d6a0700931 --- /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 0000000000..f187c9328a --- /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 0000000000..283b44c8fb --- /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 0000000000..45364d3713 --- /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)" diff --git a/scripts/build/setup/termux_setup_python_pip.sh b/scripts/build/setup/termux_setup_python_pip.sh index 2a51f91e6d..1ac6369b6b 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 } diff --git a/scripts/build/termux_step_setup_variables.sh b/scripts/build/termux_step_setup_variables.sh index 5f14bf0cd0..0f70d2e749 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