Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: update to 3.12 #18078

Merged
merged 18 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions disabled-packages/python3.11/0001-fix-hardcoded-paths.patch
Original file line number Diff line number Diff line change
@@ -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:
34 changes: 34 additions & 0 deletions disabled-packages/python3.11/0002-no-setuid-servers.patch
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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(':'):
77 changes: 77 additions & 0 deletions disabled-packages/python3.11/0004-impl-getprotobyname.patch
Original file line number Diff line number Diff line change
@@ -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;
131 changes: 131 additions & 0 deletions disabled-packages/python3.11/0005-impl-multiprocessing.patch
Original file line number Diff line number Diff line change
@@ -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 <sys/mman.h>
#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 <fcntl.h> // open()
+#include <string.h> // strlen(), memcpy()
+#include <errno.h> // errno
+#include <limits.h> // NAME_MAX
+#include <unistd.h> // 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);
+}

13 changes: 13 additions & 0 deletions disabled-packages/python3.11/0006-do-not-use-xattr.patch
Original file line number Diff line number Diff line change
@@ -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 <linux/limits.h> // Needed for XATTR_SIZE_MAX on musl libc.
#endif
13 changes: 13 additions & 0 deletions disabled-packages/python3.11/0007-disable-multiarch.patch
Original file line number Diff line number Diff line change
@@ -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*) :
10 changes: 10 additions & 0 deletions disabled-packages/python3.11/0008-do-not-use-link.patch
Original file line number Diff line number Diff line change
@@ -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

Loading