From ba2315f7ea69c6fc8945106ca48bf86f803d9550 Mon Sep 17 00:00:00 2001 From: OscarL Date: Sun, 4 Aug 2024 03:53:25 -0300 Subject: [PATCH] python3.9: update to version 3.9.19. (#10785) .patchset changes after the ones done for 3.10. --- ....18.patchset => python3.9-3.9.19.patchset} | 1681 +++++++++-------- .../patches/python3.9_x86-3.9.18.patchset | 45 - dev-lang/python/python3.9-3.9.18.recipe | 253 --- dev-lang/python/python3.9-3.9.19.recipe | 400 ++++ 4 files changed, 1334 insertions(+), 1045 deletions(-) rename dev-lang/python/patches/{python3.9-3.9.18.patchset => python3.9-3.9.19.patchset} (74%) delete mode 100644 dev-lang/python/patches/python3.9_x86-3.9.18.patchset delete mode 100644 dev-lang/python/python3.9-3.9.18.recipe create mode 100644 dev-lang/python/python3.9-3.9.19.recipe diff --git a/dev-lang/python/patches/python3.9-3.9.18.patchset b/dev-lang/python/patches/python3.9-3.9.19.patchset similarity index 74% rename from dev-lang/python/patches/python3.9-3.9.18.patchset rename to dev-lang/python/patches/python3.9-3.9.19.patchset index 68322ed62..70b912022 100644 --- a/dev-lang/python/patches/python3.9-3.9.18.patchset +++ b/dev-lang/python/patches/python3.9-3.9.19.patchset @@ -1,8 +1,18 @@ -From 43c073e23a07c104fbd177ce6e34b918033b7f66 Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Thu, 10 Apr 2014 16:03:33 +0000 -Subject: initial Haiku patch +From 51b4fea86a77470571df56e9bfe8421ed05da358 Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Thu, 25 Jul 2024 17:26:26 -0300 +Subject: Initial Haiku patch (re-worked a bit). +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +This combines: + +* The original "initial Haiku patch" from Jérôme Duval. +* A variation of Adrien Destugues changes in setup.py from his x86 patch. + +Ideally, we can continue moving changes from here into "per topic" commits, +leaving here mostly only make/config related changes, for example. diff --git a/Include/pyport.h b/Include/pyport.h index 4bd4eb4..5354912 100644 @@ -17,6 +27,728 @@ index 4bd4eb4..5354912 100644 /* Use UTF-8 as filesystem encoding */ # define _Py_FORCE_UTF8_FS_ENCODING #endif +diff --git a/Lib/plat-haiku1/regen b/Lib/plat-haiku1/regen +new file mode 100644 +index 0000000..4372ee2 +--- /dev/null ++++ b/Lib/plat-haiku1/regen +@@ -0,0 +1,4 @@ ++#! /bin/sh ++HEADERS=/boot/develop/headers ++set -v ++eval $PYTHON_FOR_BUILD ../../Tools/scripts/h2py.py -i "'(u_long)'" $HEADERS/posix/netinet/in.h +diff --git a/Makefile.pre.in b/Makefile.pre.in +index a276d53..3fbb872 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -141,7 +141,7 @@ BINDIR= @bindir@ + LIBDIR= @libdir@ + MANDIR= @mandir@ + INCLUDEDIR= @includedir@ +-CONFINCLUDEDIR= $(exec_prefix)/include ++CONFINCLUDEDIR= $(INCLUDEDIR) + PLATLIBDIR= @PLATLIBDIR@ + SCRIPTDIR= $(prefix)/$(PLATLIBDIR) + ABIFLAGS= @ABIFLAGS@ +diff --git a/Modules/resource.c b/Modules/resource.c +index ddbf80b..6b50f0b 100644 +--- a/Modules/resource.c ++++ b/Modules/resource.c +@@ -99,6 +99,7 @@ resource_getrusage_impl(PyObject *module, int who) + PyFloat_FromDouble(doubletime(ru.ru_utime))); + PyStructSequence_SET_ITEM(result, 1, + PyFloat_FromDouble(doubletime(ru.ru_stime))); ++#ifndef __HAIKU__ + PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss)); + PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss)); + PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss)); +@@ -113,7 +114,22 @@ resource_getrusage_impl(PyObject *module, int who) + PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals)); + PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw)); + PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw)); +- ++#else ++ PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(0)); ++ PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(0)); ++#endif + if (PyErr_Occurred()) { + Py_DECREF(result); + return NULL; +@@ -367,19 +383,19 @@ resource_exec(PyObject *module) + } + + /* insert constants */ +-#ifdef RLIMIT_CPU ++#if !defined(__HAIKU__) && defined(RLIMIT_CPU) + ADD_INT(module, RLIMIT_CPU); + #endif + +-#ifdef RLIMIT_FSIZE ++#if !defined(__HAIKU__) && defined(RLIMIT_FSIZE) + ADD_INT(module, RLIMIT_FSIZE); + #endif + +-#ifdef RLIMIT_DATA ++#if !defined(__HAIKU__) && defined(RLIMIT_DATA) + ADD_INT(module, RLIMIT_DATA); + #endif + +-#ifdef RLIMIT_STACK ++#if !defined(__HAIKU__) && defined(RLIMIT_STACK) + ADD_INT(module, RLIMIT_STACK); + #endif + +@@ -391,31 +407,31 @@ resource_exec(PyObject *module) + ADD_INT(module, RLIMIT_NOFILE); + #endif + +-#ifdef RLIMIT_OFILE ++#if !defined(__HAIKU__) && defined(RLIMIT_OFILE) + ADD_INT(module, RLIMIT_OFILE); + #endif + +-#ifdef RLIMIT_VMEM ++#if !defined(__HAIKU__) && defined(RLIMIT_VMEM) + ADD_INT(module, RLIMIT_VMEM); + #endif + +-#ifdef RLIMIT_AS ++#if !defined(__HAIKU__) && defined(RLIMIT_AS) + ADD_INT(module, RLIMIT_AS); + #endif + +-#ifdef RLIMIT_RSS ++#if !defined(__HAIKU__) && defined(RLIMIT_RSS) + ADD_INT(module, RLIMIT_RSS); + #endif + +-#ifdef RLIMIT_NPROC ++#if !defined(__HAIKU__) && defined(RLIMIT_NPROC) + ADD_INT(module, RLIMIT_NPROC); + #endif + +-#ifdef RLIMIT_MEMLOCK ++#if !defined(__HAIKU__) && defined(RLIMIT_MEMLOCK) + ADD_INT(module, RLIMIT_MEMLOCK); + #endif + +-#ifdef RLIMIT_SBSIZE ++#if !defined(__HAIKU__) && defined(RLIMIT_SBSIZE) + ADD_INT(module, RLIMIT_SBSIZE); + #endif + +diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c +index 9e0223b..230a269 100644 +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -7519,7 +7519,9 @@ PyInit__socket(void) + /* SOCK_RAW is marked as optional in the POSIX specification */ + PyModule_AddIntMacro(m, SOCK_RAW); + #endif ++#ifndef __HAIKU__ + PyModule_AddIntMacro(m, SOCK_SEQPACKET); ++#endif + #if defined(SOCK_RDM) + PyModule_AddIntMacro(m, SOCK_RDM); + #endif +diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h +index ba2c9f5..df2abcd 100644 +--- a/Modules/socketmodule.h ++++ b/Modules/socketmodule.h +@@ -104,6 +104,10 @@ typedef int socklen_t; + # undef AF_QIPCRTR + #endif + ++#if defined(__HAIKU__) ++#undef HAVE_BLUETOOTH_BLUETOOTH_H ++#endif ++ + #ifdef HAVE_BLUETOOTH_BLUETOOTH_H + #include + #include +diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c +index 1601ec0..4c98fe8 100644 +--- a/Modules/spwdmodule.c ++++ b/Modules/spwdmodule.c +@@ -9,6 +9,7 @@ + #ifdef HAVE_SHADOW_H + #include + #endif ++#include + + #include "clinic/spwdmodule.c.h" + +@@ -138,7 +139,12 @@ spwd_getspnam_impl(PyObject *module, PyObject *arg) + if (PyBytes_AsStringAndSize(bytes, &name, NULL) == -1) + goto out; + if ((p = getspnam(name)) == NULL) { ++// Haiku sets ENOENT if invalid user is specified. Ignore it to make KeyError is set. ++#ifdef __HAIKU__ ++ if (errno != 0 && errno != ENOENT) ++#else + if (errno != 0) ++#endif + PyErr_SetFromErrno(PyExc_OSError); + else + PyErr_SetString(PyExc_KeyError, "getspnam(): name not found"); +diff --git a/configure.ac b/configure.ac +index aa515da..2c7f344 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1172,6 +1172,16 @@ if test $enable_shared = "yes"; then + PY3LIBRARY=libpython3.so + fi + ;; ++ Haiku*) ++ LDLIBRARY='libpython$(LDVERSION).so' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ RUNSHARED=LIBRARY_PATH=`pwd`${LIBRARY_PATH:+:${LIBRARY_PATH}} ++ INSTSONAME="$LDLIBRARY".$SOVERSION ++ if test "$with_pydebug" != yes ++ then ++ PY3LIBRARY=libpython3.so ++ fi ++ ;; + hp*|HP*) + case `uname -m` in + ia64) +@@ -1247,6 +1257,7 @@ AC_PROG_MKDIR_P + AC_SUBST(LN) + if test -z "$LN" ; then + case $ac_sys_system in ++ Haiku*) LN="ln -s";; + CYGWIN*) LN="ln -s";; + *) LN=ln;; + esac +@@ -2681,7 +2692,7 @@ then + BLDSHARED="$LDSHARED" + fi + ;; +- Linux*|GNU*|QNX*|VxWorks*) ++ Linux*|GNU*|QNX*|VxWorks*|Haiku*) + LDSHARED='$(CC) -shared' + LDCXXSHARED='$(CXX) -shared';; + FreeBSD*) +@@ -2748,7 +2759,7 @@ then + else CCSHARED="+z"; + fi;; + Linux-android*) ;; +- Linux*|GNU*) CCSHARED="-fPIC";; ++ Linux*|GNU*|Haiku*) CCSHARED="-fPIC";; + FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; + OpenUNIX*|UnixWare*) + if test "$GCC" = "yes" +@@ -2776,7 +2787,7 @@ then + LINKFORSHARED="-Wl,-E -Wl,+s";; + # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; + Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; +- Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; ++ Linux*|GNU*|Haiku*) LINKFORSHARED="-Xlinker -export-dynamic";; + # -u libsys_s pulls in all symbols in libsys + Darwin/*) + LINKFORSHARED="$extra_undefs -framework CoreFoundation" +@@ -3076,6 +3087,12 @@ LDFLAGS="-fsanitize=undefined $LDFLAGS" + AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 + AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets + ++# Haiku's sockets are stashed in libnetwork. ++case "$ac_sys_system" in ++ Haiku*) ++ AC_CHECK_LIB(network, socket, [LIBS="-lnetwork $LIBS"], [], $LIBS);; ++esac ++ + AC_MSG_CHECKING(for --with-libs) + AC_ARG_WITH(libs, + AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs (default is no)]), +@@ -4458,6 +4475,7 @@ AC_CHECK_FUNC(__fpu_control, + AC_SUBST(LIBM) + case $ac_sys_system in + Darwin) ;; ++Haiku) ;; + *) LIBM=-lm + esac + AC_MSG_CHECKING(for --with-libm=STRING) +diff --git a/setup.py b/setup.py +index 0bec170..45955d4 100644 +--- a/setup.py ++++ b/setup.py +@@ -65,6 +65,7 @@ CYGWIN = (HOST_PLATFORM == 'cygwin') + MACOS = (HOST_PLATFORM == 'darwin') + AIX = (HOST_PLATFORM.startswith('aix')) + VXWORKS = ('vxworks' in HOST_PLATFORM) ++HAIKU = (HOST_PLATFORM == 'haiku1') + CC = os.environ.get("CC") + if not CC: + CC = sysconfig.get_config_var("CC") +@@ -780,6 +781,18 @@ class PyBuildExt(build_ext): + with open(config_h) as file: + self.config_h_vars = sysconfig.parse_config_h(file) + ++ # Haiku-specific library locations ++ if HAIKU: ++ self.inc_dirs += ['/boot/develop/headers/posix'] ++ # Are we on x86 32 bits?: ++ import platform ++ if platform.machine() == 'BePC': ++ self.inc_dirs += ['/boot/system/develop/headers/x86'] ++ self.lib_dirs += ['/boot/system/develop/lib/x86'] ++ else: ++ self.inc_dirs += ['/boot/system/develop/headers'] ++ self.lib_dirs += ['/boot/system/develop/lib'] ++ + # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) + if HOST_PLATFORM in ['osf1', 'unixware7', 'openunix8']: + self.lib_dirs += ['/usr/ccs/lib'] +@@ -825,14 +838,14 @@ class PyBuildExt(build_ext): + extra_compile_args=['-DPy_BUILD_CORE_MODULE'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], +- libraries=['m'])) ++ libraries=[])) + + # complex math library functions + self.add(Extension('cmath', ['cmathmodule.c'], + extra_compile_args=['-DPy_BUILD_CORE_MODULE'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], +- libraries=['m'])) ++ libraries=[])) + + # time libraries: librt may be needed for clock_gettime() + time_libs = [] +@@ -846,7 +859,7 @@ class PyBuildExt(build_ext): + # libm is needed by delta_new() that uses round() and by accum() that + # uses modf(). + self.add(Extension('_datetime', ['_datetimemodule.c'], +- libraries=['m'])) ++ libraries=[])) + # zoneinfo module + self.add(Extension('_zoneinfo', ['_zoneinfo.c'])), + # random number generator implemented in C +@@ -938,7 +951,7 @@ class PyBuildExt(build_ext): + # + # audioop needs libm for floor() in multiple functions. + self.add(Extension('audioop', ['audioop.c'], +- libraries=['m'])) ++ libraries=[])) + + # CSV files + self.add(Extension('_csv', ['_csv.c'])) +@@ -2148,7 +2161,7 @@ class PyBuildExt(build_ext): + # function my_sqrt() needs libm for sqrt() + self.add(Extension('_ctypes_test', + sources=['_ctypes/_ctypes_test.c'], +- libraries=['m'])) ++ libraries=[])) + + ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR") + ffi_lib = None +@@ -2213,7 +2226,7 @@ class PyBuildExt(build_ext): + 'Modules', + '_decimal', + 'libmpdec'))] +- libraries = ['m'] ++ libraries = [] + sources = [ + '_decimal/_decimal.c', + '_decimal/libmpdec/basearith.c', +@@ -2446,7 +2459,7 @@ class PyBuildExt(build_ext): + )) + + def detect_nis(self): +- if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6': ++ if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6' or HAIKU: + self.missing.append('nis') + return + +-- +2.45.2 + + +From 6fe696528a8967acc7eeca0de5278f2f9331c67e Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Sun, 16 Apr 2017 10:05:42 +0200 +Subject: fix for negative errnos + + +diff --git a/Lib/subprocess.py b/Lib/subprocess.py +index 8579d3f..e6abe57 100644 +--- a/Lib/subprocess.py ++++ b/Lib/subprocess.py +@@ -1825,6 +1825,8 @@ class Popen(object): + SubprocessError) + if issubclass(child_exception_type, OSError) and hex_errno: + errno_num = int(hex_errno, 16) ++ if sys.platform.startswith('haiku'): ++ errno_num = -errno_num; + child_exec_never_called = (err_msg == "noexec") + if child_exec_never_called: + err_msg = "" +diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c +index d64e0a1..0885a30 100644 +--- a/Modules/_posixsubprocess.c ++++ b/Modules/_posixsubprocess.c +@@ -590,6 +590,10 @@ error: + char *cur; + _Py_write_noraise(errpipe_write, "OSError:", 8); + cur = hex_errno + sizeof(hex_errno); ++#ifdef __HAIKU__ ++ if (saved_errno < 0) ++ saved_errno = -saved_errno; ++#endif + while (saved_errno != 0 && cur != hex_errno) { + *--cur = Py_hexdigits[saved_errno % 16]; + saved_errno /= 16; +-- +2.45.2 + + +From 1a8211aeebaba1d78f149f4dfa7cd9ab099ee955 Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Sat, 6 Apr 2024 23:49:30 -0300 +Subject: Implement CTypes's find_library for Haiku + +This combines: + - the original patch by Philippe Houdoin + - A slight variation of Adrien Destugues' fix for x86 32 bits. + +diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py +index 0c2510e..6b88fc8 100644 +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -1,4 +1,5 @@ + import os ++import platform + import shutil + import subprocess + import sys +@@ -265,6 +266,60 @@ elif os.name == "posix": + def find_library(name, is64 = False): + return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name)) + ++ elif sys.platform.startswith("haiku"): ++ ++ def _num_version(libname): ++ # "libxyz.so.MAJOR.MINOR" => [ MAJOR, MINOR ] ++ parts = libname.split('.') ++ nums = [] ++ try: ++ while parts: ++ nums.insert(0, int(parts.pop())) ++ except ValueError: ++ pass ++ return nums or [sys.maxint] ++ ++ def find_library(name): ++ if name in ('c', 'm'): ++ return find_library('root') ++ for directory in os.environ['LIBRARY_PATH'].split(os.pathsep): ++ if directory.startswith("%A/"): ++ directory = directory.replace('%A', ++ os.path.dirname(os.path.abspath(sys.argv[0] or os.getcwd()))) ++ ++ # Are we on x86 32 bits?: ++ if platform.machine() == 'BePC': ++ directory = os.path.join(directory, "x86") ++ ++ if not os.path.isdir(directory): ++ continue ++ ++ # try direct match ++ fname = os.path.join(directory, name) ++ if os.path.isfile(fname): ++ return fname ++ ++ fname = os.path.join(directory, 'lib%s.so' % name) ++ if os.path.isfile(fname): ++ return fname ++ ++ # no exact matching in this directroy ++ # collect versioned candidates, if any ++ candidates = [] ++ pattern = re.compile(r'lib%s\.so\.\S+' % re.escape(name)) ++ for entry in os.listdir(directory): ++ if not os.path.isfile(os.path.join(directory, entry)): ++ continue ++ ++ if re.match(pattern, entry): ++ candidates.append(os.path.join(directory, entry)) ++ ++ if candidates: ++ # return latest version found ++ candidates.sort(key=_num_version) ++ return candidates[-1] ++ ++ return None + else: + + def _findSoname_ldconfig(name): +@@ -367,6 +422,12 @@ def test(): + print(f"crypt\t:: {cdll.LoadLibrary(find_library('crypt'))}") + print(f"crypto\t:: {find_library('crypto')}") + print(f"crypto\t:: {cdll.LoadLibrary(find_library('crypto'))}") ++ elif sys.platform.startswith("haiku"): ++ print(find_library("libbz2.so.1.0")) ++ print(find_library("tracker")) ++ print(find_library("media")) ++ print(cdll.LoadLibrary(find_library("tracker"))) ++ print(cdll.LoadLibrary("libmedia.so")) + else: + print(cdll.LoadLibrary("libm.so")) + print(cdll.LoadLibrary("libcrypt.so")) +-- +2.45.2 + + +From da42418d47ed2e82dfc6b27f83513950a224a718 Mon Sep 17 00:00:00 2001 +From: Philipp Wolfer +Date: Mon, 23 Sep 2019 09:14:58 +0200 +Subject: webbrowser: Support for default browsers on Haiku + + +diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py +index 6023c1e..8359531 100755 +--- a/Lib/webbrowser.py ++++ b/Lib/webbrowser.py +@@ -543,6 +543,11 @@ def register_standard_browsers(): + "netscape", "opera", iexplore): + if shutil.which(browser): + register(browser, None, BackgroundBrowser(browser)) ++ elif sys.platform[:5] == "haiku": ++ # First try to use the default configured browser ++ register("haiku-default", None, GenericBrowser("open")) ++ # Fall back to WebPositive as the standard browser of Haiku ++ register("webpositive", None, BackgroundBrowser("WebPositive")) + else: + # Prefer X browsers if present + if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"): +-- +2.45.2 + + +From bf39460776f78b69ef0beb97d9d5e1a29b4d2235 Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Fri, 4 Oct 2019 22:02:35 +0200 +Subject: since 3.8, don't reinit locks on fork. + + +diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py +index 1ab35a8..c6b54e4 100644 +--- a/Lib/logging/__init__.py ++++ b/Lib/logging/__init__.py +@@ -234,7 +234,7 @@ def _releaseLock(): + + # Prevent a held logging lock from blocking a child from logging. + +-if not hasattr(os, 'register_at_fork'): # Windows and friends. ++if sys.platform.startswith('haiku') or not hasattr(os, 'register_at_fork'): # Windows and friends. + def _register_at_fork_reinit_lock(instance): + pass # no-op when os.register_at_fork does not exist. + else: +-- +2.45.2 + + +From 88164d557262b9ae5290f353838253cf55fca31e Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Fri, 15 May 2020 15:20:57 +0200 +Subject: handle errors returned by internal_connect() + +upstream bug #40628 by Ryan C. Gordon + +diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c +index 230a269..37d0d16 100644 +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -3329,7 +3329,7 @@ sock_connect(PySocketSockObject *s, PyObject *addro) + } + + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 1); +- if (res < 0) ++ if (res == -1) + return NULL; + + Py_RETURN_NONE; +@@ -3360,7 +3360,7 @@ sock_connect_ex(PySocketSockObject *s, PyObject *addro) + } + + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 0); +- if (res < 0) ++ if (res == -1) + return NULL; + + return PyLong_FromLong((long) res); +-- +2.45.2 + + +From 6b7f6aad49328a54181734a1252795b6e09a1253 Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Mon, 19 Oct 2020 18:03:09 +0200 +Subject: ttyname_r can use MAXPATHLEN + + +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index bf4e648..c8850d6 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -3039,11 +3039,14 @@ static PyObject * + os_ttyname_impl(PyObject *module, int fd) + /*[clinic end generated code: output=c424d2e9d1cd636a input=9ff5a58b08115c55]*/ + { +- ++#ifndef __HAIKU__ + long size = sysconf(_SC_TTY_NAME_MAX); + if (size == -1) { + return posix_error(); + } ++#else ++ long size = MAXPATHLEN; ++#endif + char *buffer = (char *)PyMem_RawMalloc(size); + if (buffer == NULL) { + return PyErr_NoMemory(); +-- +2.45.2 + + +From b00d8e4e5d41daaba8ef53295d4ef7bc7fb8ba6a Mon Sep 17 00:00:00 2001 +From: begasus +Date: Mon, 23 May 2022 08:45:31 +0200 +Subject: Fix search paths for tcl/tk + + +diff --git a/configure.ac b/configure.ac +index 2c7f344..8905063 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3202,8 +3202,13 @@ then + then + AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither]) + fi +- TCLTK_INCLUDES="" +- TCLTK_LIBS="" ++ if test -n "$PKG_CONFIG" && "$PKG_CONFIG" --exists tcl tk; then ++ TCLTK_INCLUDES="`"$PKG_CONFIG" tcl tk --cflags-only-I 2>/dev/null`" ++ TCLTK_LIBS="`"$PKG_CONFIG" tcl tk --libs 2>/dev/null`" ++ else ++ TCLTK_INCLUDES="" ++ TCLTK_LIBS="" ++ fi + else + TCLTK_INCLUDES="$with_tcltk_includes" + TCLTK_LIBS="$with_tcltk_libs" +-- +2.45.2 + + +From 9077a00e9fcacc591587f6a559f0d66b4b197c0c Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Thu, 25 Jul 2024 17:27:04 -0300 +Subject: Miscellaneous "Lib/test/" fixes for Haiku. + +This combines test_fileio.py changes from the "initial Haiku patch", plus... + +"Lib/test: require the "largefile" usage flag for I/O heavy tests.": + +The same was done for Windows and MacOSX already. + +This avoids needing several GBs of storage to run the tests +(unless they "largefile" resource usage flag is enabled). + +diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py +index 2671d6a..d80a5c4 100644 +--- a/Lib/test/test_fileio.py ++++ b/Lib/test/test_fileio.py +@@ -385,6 +385,7 @@ class OtherFileTests: + self.assertEqual(f.writable(), True) + if sys.platform != "darwin" and \ + 'bsd' not in sys.platform and \ ++ 'haiku' not in sys.platform and \ + not sys.platform.startswith(('sunos', 'aix')): + # Somehow /dev/tty appears seekable on some BSDs + self.assertEqual(f.seekable(), False) +diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py +index feee861..4f76448 100644 +--- a/Lib/test/test_io.py ++++ b/Lib/test/test_io.py +@@ -594,7 +594,7 @@ class IOTest(unittest.TestCase): + # On Windows and Mac OSX this test consumes large resources; It takes + # a long time to build the >2 GiB file and takes >2 GiB of disk space + # therefore the resource must be enabled to run this test. +- if sys.platform[:3] == 'win' or sys.platform == 'darwin': ++ if sys.platform[:3] == 'win' or sys.platform == 'darwin' or sys.platform == 'haiku1': + support.requires( + 'largefile', + 'test requires %s bytes and a long time to run' % self.LARGE) +diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py +index a99b4ba..1fb24ce 100644 +--- a/Lib/test/test_largefile.py ++++ b/Lib/test/test_largefile.py +@@ -250,7 +250,7 @@ def setUpModule(): + # takes a long time to build the >2 GiB file and takes >2 GiB of disk + # space therefore the resource must be enabled to run this test. + # If not, nothing after this line stanza will be executed. +- if sys.platform[:3] == 'win' or sys.platform == 'darwin': ++ if sys.platform[:3] == 'win' or sys.platform == 'darwin' or sys.platform == 'haiku1': + requires('largefile', + 'test requires %s bytes and a long time to run' % str(size)) + else: +diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py +index 89ada50..df35017 100644 +--- a/Lib/test/test_mmap.py ++++ b/Lib/test/test_mmap.py +@@ -810,7 +810,7 @@ class LargeMmapTests(unittest.TestCase): + unlink(TESTFN) + + def _make_test_file(self, num_zeroes, tail): +- if sys.platform[:3] == 'win' or sys.platform == 'darwin': ++ if sys.platform[:3] == 'win' or sys.platform == 'darwin' or sys.platform == 'haiku1': + requires('largefile', + 'test requires %s bytes and a long time to run' % str(0x180000000)) + f = open(TESTFN, 'w+b') +-- +2.45.2 + + +From 2e4551efd3c09f40e38b8a0d067ecb5b672111fc Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Sat, 3 Aug 2024 03:32:57 -0300 +Subject: _getuserbase(), getsitepackages(), and INSTALL_SCHEMES for Haiku +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This combines (at least parts of) previous "commits" on older ".patchset"s: + +* Initial Haiku patch. +* default schemes for Haiku +* sysconfig: add haiku schemes + +from Jérôme Duval + +* syncronize both _getuserbase() copies on site.py and sysconfig.py. +* Add missing 'platinclude' to sysconfig's _INSTALL_SCHEMES. +* Adjust test_sysconfig.test_get_scheme_names for Haiku. + +by me, plus: + +new changes to allow Python to find modules installed via 'pkgman -H'. + +The idea was to have all _getuserbase()/INSTALL_SCHEMES related changes in "one place". + diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py index aaa300e..8c85eb7 100644 --- a/Lib/distutils/command/install.py @@ -152,777 +884,100 @@ index 37feae5..f2e2d0f 100644 elif os.name == "nt": if standard_lib: return os.path.join(prefix, "Lib") -diff --git a/Lib/plat-haiku1/regen b/Lib/plat-haiku1/regen -new file mode 100644 -index 0000000..4372ee2 ---- /dev/null -+++ b/Lib/plat-haiku1/regen -@@ -0,0 +1,4 @@ -+#! /bin/sh -+HEADERS=/boot/develop/headers -+set -v -+eval $PYTHON_FOR_BUILD ../../Tools/scripts/h2py.py -i "'(u_long)'" $HEADERS/posix/netinet/in.h diff --git a/Lib/site.py b/Lib/site.py -index 9e617af..03b5a28 100644 +index 54ffc4f..6cbf2ac 100644 --- a/Lib/site.py +++ b/Lib/site.py -@@ -259,6 +259,14 @@ def _getuserbase(): +@@ -268,6 +268,14 @@ def _getuserbase(): return joinuser("~", "Library", sys._framework, "%d.%d" % sys.version_info[:2]) + if sys.platform.startswith('haiku'): + try: + import subprocess -+ return subprocess.run(['finddir', 'B_USER_NONPACKAGED_DIRECTORY'], -+ stdout=subprocess.PIPE, check=True).stdout.rstrip().decode('utf-8') ++ return subprocess.check_output( ++ ['finddir', 'B_USER_NONPACKAGED_DIRECTORY']).rstrip().decode('utf-8') + except: + pass + return joinuser("~", ".local") -@@ -338,7 +346,14 @@ def getsitepackages(prefixes=None): +@@ -347,7 +355,31 @@ def getsitepackages(prefixes=None): if sys.platlibdir != "lib": libdirs.append("lib") - if os.sep == '/': + if sys.platform.startswith('haiku'): -+ sitepackages.append(os.path.join(prefix, "non-packaged", "lib", -+ "python" + sys.version[:3], -+ "site-packages")) -+ sitepackages.append(os.path.join(prefix, "lib", -+ "python" + sys.version[:3], -+ "vendor-packages")) ++ # Locations under /system/ ++ sitepackages.append(os.path.join(prefix, "non-packaged", "lib", ++ "python" + sys.version[:3], ++ "site-packages")) ++ sitepackages.append(os.path.join(prefix, "lib", ++ "python" + sys.version[:3], ++ "vendor-packages")) ++ ++ # For .hpkg installed under ~/config/ (pkgman install -H) ++ # ("pip install --user" uses ~/config/non-packaged/, and gets ++ # handled by the "haiku_user" install scheme. ++ try: ++ import subprocess ++ _home_prefix = subprocess.check_output( ++ ['finddir', 'B_USER_CONFIG_DIRECTORY']).rstrip().decode('utf-8') ++ except: ++ # print("'finddir B_USER_CONFIG_DIRECTORY' failed.") ++ _home_prefix = None ++ ++ if _home_prefix is not None: ++ sitepackages.append(os.path.join(_home_prefix, "lib", ++ "python" + sys.version[:3], ++ "vendor-packages")) + elif os.sep == '/': for libdir in libdirs: path = os.path.join(prefix, libdir, "python%d.%d" % sys.version_info[:2], -@@ -443,8 +458,16 @@ def enablerlcompleter(): - # each interpreter exit when readline was already configured - # through a PYTHONSTARTUP hook, see: - # http://bugs.python.org/issue5845#msg198636 -- history = os.path.join(os.path.expanduser('~'), -- '.python_history') -+ import subprocess -+ try: -+ history = os.path.join(subprocess.run(['finddir', 'B_USER_VAR_DIRECTORY'], -+ check=True, stdout=subprocess.PIPE).stdout.rstrip().decode('utf-8'), -+ 'python', 'history') -+ if not os.path.exists(os.path.dirname(history)): -+ os.makedirs(os.path.dirname(history)) -+ except subprocess.CalledProcessError: -+ history = os.path.join(os.path.expanduser('~'), -+ '.python_history') - try: - readline.read_history_file(history) - except OSError: -diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py -index 2671d6a..d80a5c4 100644 ---- a/Lib/test/test_fileio.py -+++ b/Lib/test/test_fileio.py -@@ -385,6 +385,7 @@ class OtherFileTests: - self.assertEqual(f.writable(), True) - if sys.platform != "darwin" and \ - 'bsd' not in sys.platform and \ -+ 'haiku' not in sys.platform and \ - not sys.platform.startswith(('sunos', 'aix')): - # Somehow /dev/tty appears seekable on some BSDs - self.assertEqual(f.seekable(), False) -diff --git a/Makefile.pre.in b/Makefile.pre.in -index c0272bf..a13bd6b 100644 ---- a/Makefile.pre.in -+++ b/Makefile.pre.in -@@ -141,7 +141,7 @@ BINDIR= @bindir@ - LIBDIR= @libdir@ - MANDIR= @mandir@ - INCLUDEDIR= @includedir@ --CONFINCLUDEDIR= $(exec_prefix)/include -+CONFINCLUDEDIR= $(INCLUDEDIR) - PLATLIBDIR= @PLATLIBDIR@ - SCRIPTDIR= $(prefix)/$(PLATLIBDIR) - ABIFLAGS= @ABIFLAGS@ -diff --git a/Modules/resource.c b/Modules/resource.c -index ddbf80b..6b50f0b 100644 ---- a/Modules/resource.c -+++ b/Modules/resource.c -@@ -99,6 +99,7 @@ resource_getrusage_impl(PyObject *module, int who) - PyFloat_FromDouble(doubletime(ru.ru_utime))); - PyStructSequence_SET_ITEM(result, 1, - PyFloat_FromDouble(doubletime(ru.ru_stime))); -+#ifndef __HAIKU__ - PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss)); - PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss)); - PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss)); -@@ -113,7 +114,22 @@ resource_getrusage_impl(PyObject *module, int who) - PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals)); - PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw)); - PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw)); -- -+#else -+ PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(0)); -+ PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(0)); -+#endif - if (PyErr_Occurred()) { - Py_DECREF(result); - return NULL; -@@ -367,19 +383,19 @@ resource_exec(PyObject *module) - } - - /* insert constants */ --#ifdef RLIMIT_CPU -+#if !defined(__HAIKU__) && defined(RLIMIT_CPU) - ADD_INT(module, RLIMIT_CPU); - #endif - --#ifdef RLIMIT_FSIZE -+#if !defined(__HAIKU__) && defined(RLIMIT_FSIZE) - ADD_INT(module, RLIMIT_FSIZE); - #endif - --#ifdef RLIMIT_DATA -+#if !defined(__HAIKU__) && defined(RLIMIT_DATA) - ADD_INT(module, RLIMIT_DATA); - #endif - --#ifdef RLIMIT_STACK -+#if !defined(__HAIKU__) && defined(RLIMIT_STACK) - ADD_INT(module, RLIMIT_STACK); - #endif - -@@ -391,31 +407,31 @@ resource_exec(PyObject *module) - ADD_INT(module, RLIMIT_NOFILE); - #endif - --#ifdef RLIMIT_OFILE -+#if !defined(__HAIKU__) && defined(RLIMIT_OFILE) - ADD_INT(module, RLIMIT_OFILE); - #endif - --#ifdef RLIMIT_VMEM -+#if !defined(__HAIKU__) && defined(RLIMIT_VMEM) - ADD_INT(module, RLIMIT_VMEM); - #endif - --#ifdef RLIMIT_AS -+#if !defined(__HAIKU__) && defined(RLIMIT_AS) - ADD_INT(module, RLIMIT_AS); - #endif - --#ifdef RLIMIT_RSS -+#if !defined(__HAIKU__) && defined(RLIMIT_RSS) - ADD_INT(module, RLIMIT_RSS); - #endif - --#ifdef RLIMIT_NPROC -+#if !defined(__HAIKU__) && defined(RLIMIT_NPROC) - ADD_INT(module, RLIMIT_NPROC); - #endif - --#ifdef RLIMIT_MEMLOCK -+#if !defined(__HAIKU__) && defined(RLIMIT_MEMLOCK) - ADD_INT(module, RLIMIT_MEMLOCK); - #endif - --#ifdef RLIMIT_SBSIZE -+#if !defined(__HAIKU__) && defined(RLIMIT_SBSIZE) - ADD_INT(module, RLIMIT_SBSIZE); - #endif - -diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c -index 133470f..b29283e 100644 ---- a/Modules/socketmodule.c -+++ b/Modules/socketmodule.c -@@ -7513,7 +7513,9 @@ PyInit__socket(void) - /* SOCK_RAW is marked as optional in the POSIX specification */ - PyModule_AddIntMacro(m, SOCK_RAW); - #endif -+#ifndef __HAIKU__ - PyModule_AddIntMacro(m, SOCK_SEQPACKET); -+#endif - #if defined(SOCK_RDM) - PyModule_AddIntMacro(m, SOCK_RDM); - #endif -diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h -index ba2c9f5..df2abcd 100644 ---- a/Modules/socketmodule.h -+++ b/Modules/socketmodule.h -@@ -104,6 +104,10 @@ typedef int socklen_t; - # undef AF_QIPCRTR - #endif - -+#if defined(__HAIKU__) -+#undef HAVE_BLUETOOTH_BLUETOOTH_H -+#endif -+ - #ifdef HAVE_BLUETOOTH_BLUETOOTH_H - #include - #include -diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c -index 1601ec0..4c98fe8 100644 ---- a/Modules/spwdmodule.c -+++ b/Modules/spwdmodule.c -@@ -9,6 +9,7 @@ - #ifdef HAVE_SHADOW_H - #include - #endif -+#include - - #include "clinic/spwdmodule.c.h" - -@@ -138,7 +139,12 @@ spwd_getspnam_impl(PyObject *module, PyObject *arg) - if (PyBytes_AsStringAndSize(bytes, &name, NULL) == -1) - goto out; - if ((p = getspnam(name)) == NULL) { -+// Haiku sets ENOENT if invalid user is specified. Ignore it to make KeyError is set. -+#ifdef __HAIKU__ -+ if (errno != 0 && errno != ENOENT) -+#else - if (errno != 0) -+#endif - PyErr_SetFromErrno(PyExc_OSError); - else - PyErr_SetString(PyExc_KeyError, "getspnam(): name not found"); -diff --git a/configure.ac b/configure.ac -index aa515da..2c7f344 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1172,6 +1172,16 @@ if test $enable_shared = "yes"; then - PY3LIBRARY=libpython3.so - fi - ;; -+ Haiku*) -+ LDLIBRARY='libpython$(LDVERSION).so' -+ BLDLIBRARY='-L. -lpython$(LDVERSION)' -+ RUNSHARED=LIBRARY_PATH=`pwd`${LIBRARY_PATH:+:${LIBRARY_PATH}} -+ INSTSONAME="$LDLIBRARY".$SOVERSION -+ if test "$with_pydebug" != yes -+ then -+ PY3LIBRARY=libpython3.so -+ fi -+ ;; - hp*|HP*) - case `uname -m` in - ia64) -@@ -1247,6 +1257,7 @@ AC_PROG_MKDIR_P - AC_SUBST(LN) - if test -z "$LN" ; then - case $ac_sys_system in -+ Haiku*) LN="ln -s";; - CYGWIN*) LN="ln -s";; - *) LN=ln;; - esac -@@ -2681,7 +2692,7 @@ then - BLDSHARED="$LDSHARED" - fi - ;; -- Linux*|GNU*|QNX*|VxWorks*) -+ Linux*|GNU*|QNX*|VxWorks*|Haiku*) - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared';; - FreeBSD*) -@@ -2748,7 +2759,7 @@ then - else CCSHARED="+z"; - fi;; - Linux-android*) ;; -- Linux*|GNU*) CCSHARED="-fPIC";; -+ Linux*|GNU*|Haiku*) CCSHARED="-fPIC";; - FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; - OpenUNIX*|UnixWare*) - if test "$GCC" = "yes" -@@ -2776,7 +2787,7 @@ then - LINKFORSHARED="-Wl,-E -Wl,+s";; - # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; - Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; -- Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; -+ Linux*|GNU*|Haiku*) LINKFORSHARED="-Xlinker -export-dynamic";; - # -u libsys_s pulls in all symbols in libsys - Darwin/*) - LINKFORSHARED="$extra_undefs -framework CoreFoundation" -@@ -3076,6 +3087,12 @@ LDFLAGS="-fsanitize=undefined $LDFLAGS" - AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 - AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets - -+# Haiku's sockets are stashed in libnetwork. -+case "$ac_sys_system" in -+ Haiku*) -+ AC_CHECK_LIB(network, socket, [LIBS="-lnetwork $LIBS"], [], $LIBS);; -+esac -+ - AC_MSG_CHECKING(for --with-libs) - AC_ARG_WITH(libs, - AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs (default is no)]), -@@ -4458,6 +4475,7 @@ AC_CHECK_FUNC(__fpu_control, - AC_SUBST(LIBM) - case $ac_sys_system in - Darwin) ;; -+Haiku) ;; - *) LIBM=-lm - esac - AC_MSG_CHECKING(for --with-libm=STRING) -diff --git a/setup.py b/setup.py -index 0bec170..3b862fa 100644 ---- a/setup.py -+++ b/setup.py -@@ -65,6 +65,7 @@ CYGWIN = (HOST_PLATFORM == 'cygwin') - MACOS = (HOST_PLATFORM == 'darwin') - AIX = (HOST_PLATFORM.startswith('aix')) - VXWORKS = ('vxworks' in HOST_PLATFORM) -+HAIKU = (HOST_PLATFORM == 'haiku1') - CC = os.environ.get("CC") - if not CC: - CC = sysconfig.get_config_var("CC") -@@ -780,6 +781,11 @@ class PyBuildExt(build_ext): - with open(config_h) as file: - self.config_h_vars = sysconfig.parse_config_h(file) - -+ # Haiku-specific library locations -+ if HAIKU: -+ self.inc_dirs += ['/boot/develop/headers/posix', -+ '/boot/system/develop/headers'] -+ self.lib_dirs += ['/boot/system/develop/lib'] - # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) - if HOST_PLATFORM in ['osf1', 'unixware7', 'openunix8']: - self.lib_dirs += ['/usr/ccs/lib'] -@@ -825,14 +831,14 @@ class PyBuildExt(build_ext): - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], - extra_objects=[shared_math], - depends=['_math.h', shared_math], -- libraries=['m'])) -+ libraries=[])) - - # complex math library functions - self.add(Extension('cmath', ['cmathmodule.c'], - extra_compile_args=['-DPy_BUILD_CORE_MODULE'], - extra_objects=[shared_math], - depends=['_math.h', shared_math], -- libraries=['m'])) -+ libraries=[])) - - # time libraries: librt may be needed for clock_gettime() - time_libs = [] -@@ -846,7 +852,7 @@ class PyBuildExt(build_ext): - # libm is needed by delta_new() that uses round() and by accum() that - # uses modf(). - self.add(Extension('_datetime', ['_datetimemodule.c'], -- libraries=['m'])) -+ libraries=[])) - # zoneinfo module - self.add(Extension('_zoneinfo', ['_zoneinfo.c'])), - # random number generator implemented in C -@@ -938,7 +944,7 @@ class PyBuildExt(build_ext): - # - # audioop needs libm for floor() in multiple functions. - self.add(Extension('audioop', ['audioop.c'], -- libraries=['m'])) -+ libraries=[])) - - # CSV files - self.add(Extension('_csv', ['_csv.c'])) -@@ -2148,7 +2154,7 @@ class PyBuildExt(build_ext): - # function my_sqrt() needs libm for sqrt() - self.add(Extension('_ctypes_test', - sources=['_ctypes/_ctypes_test.c'], -- libraries=['m'])) -+ libraries=[])) - - ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR") - ffi_lib = None -@@ -2213,7 +2219,7 @@ class PyBuildExt(build_ext): - 'Modules', - '_decimal', - 'libmpdec'))] -- libraries = ['m'] -+ libraries = [] - sources = [ - '_decimal/_decimal.c', - '_decimal/libmpdec/basearith.c', -@@ -2446,7 +2452,7 @@ class PyBuildExt(build_ext): - )) - - def detect_nis(self): -- if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6': -+ if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6' or HAIKU: - self.missing.append('nis') - return - --- -2.37.3 - - -From b599abff2521708a1ff796319d1d2bb32526e4bd Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Sun, 16 Apr 2017 10:05:42 +0200 -Subject: fix for negative errnos - - -diff --git a/Lib/subprocess.py b/Lib/subprocess.py -index 8579d3f..e6abe57 100644 ---- a/Lib/subprocess.py -+++ b/Lib/subprocess.py -@@ -1825,6 +1825,8 @@ class Popen(object): - SubprocessError) - if issubclass(child_exception_type, OSError) and hex_errno: - errno_num = int(hex_errno, 16) -+ if sys.platform.startswith('haiku'): -+ errno_num = -errno_num; - child_exec_never_called = (err_msg == "noexec") - if child_exec_never_called: - err_msg = "" -diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c -index d64e0a1..0885a30 100644 ---- a/Modules/_posixsubprocess.c -+++ b/Modules/_posixsubprocess.c -@@ -590,6 +590,10 @@ error: - char *cur; - _Py_write_noraise(errpipe_write, "OSError:", 8); - cur = hex_errno + sizeof(hex_errno); -+#ifdef __HAIKU__ -+ if (saved_errno < 0) -+ saved_errno = -saved_errno; -+#endif - while (saved_errno != 0 && cur != hex_errno) { - *--cur = Py_hexdigits[saved_errno % 16]; - saved_errno /= 16; --- -2.37.3 - - -From 820dcebc11a4405cb892d42b7daff32cf3f805ad Mon Sep 17 00:00:00 2001 -From: Philippe Houdoin -Date: Wed, 24 May 2017 11:09:43 +0000 -Subject: Implement CTypes's find_library for Haiku - - -diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py -index 0c2510e..2b4f04c 100644 ---- a/Lib/ctypes/util.py -+++ b/Lib/ctypes/util.py -@@ -265,6 +265,56 @@ elif os.name == "posix": - def find_library(name, is64 = False): - return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name)) - -+ elif sys.platform.startswith("haiku"): -+ -+ def _num_version(libname): -+ # "libxyz.so.MAJOR.MINOR" => [ MAJOR, MINOR ] -+ parts = libname.split('.') -+ nums = [] -+ try: -+ while parts: -+ nums.insert(0, int(parts.pop())) -+ except ValueError: -+ pass -+ return nums or [sys.maxint] -+ -+ def find_library(name): -+ if name in ('c', 'm'): -+ return find_library('root') -+ for directory in os.environ['LIBRARY_PATH'].split(os.pathsep): -+ if directory.startswith("%A/"): -+ directory = directory.replace('%A', -+ os.path.dirname(os.path.abspath(sys.argv[0] or os.getcwd()))) -+ -+ if not os.path.isdir(directory): -+ continue -+ -+ # try direct match -+ fname = os.path.join(directory, name) -+ if os.path.isfile(fname): -+ return fname -+ -+ fname = os.path.join(directory, 'lib%s.so' % name) -+ if os.path.isfile(fname): -+ return fname -+ -+ # no exact matching in this directroy -+ # collect versioned candidates, if any -+ candidates = [] -+ pattern = re.compile(r'lib%s\.so\.\S+' % re.escape(name)) -+ for entry in os.listdir(directory): -+ if not os.path.isfile(os.path.join(directory, entry)): -+ continue -+ -+ if re.match(pattern, entry): -+ candidates.append(os.path.join(directory, entry)) -+ -+ if candidates: -+ # return latest version found -+ candidates.sort(key=_num_version) -+ return candidates[-1] -+ -+ return None - else: - - def _findSoname_ldconfig(name): -@@ -367,6 +417,12 @@ def test(): - print(f"crypt\t:: {cdll.LoadLibrary(find_library('crypt'))}") - print(f"crypto\t:: {find_library('crypto')}") - print(f"crypto\t:: {cdll.LoadLibrary(find_library('crypto'))}") -+ elif sys.platform.startswith("haiku"): -+ print(find_library("libbz2.so.1.0")) -+ print(find_library("tracker")) -+ print(find_library("media")) -+ print(cdll.LoadLibrary(find_library("tracker"))) -+ print(cdll.LoadLibrary("libmedia.so")) - else: - print(cdll.LoadLibrary("libm.so")) - print(cdll.LoadLibrary("libcrypt.so")) --- -2.37.3 - - -From 6c608a84f82fdd11df68f5d7fe9dd3aefe2a73b3 Mon Sep 17 00:00:00 2001 -From: Philipp Wolfer -Date: Mon, 23 Sep 2019 09:14:58 +0200 -Subject: webbrowser: Support for default browsers on Haiku - - -diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py -index 6023c1e..8359531 100755 ---- a/Lib/webbrowser.py -+++ b/Lib/webbrowser.py -@@ -543,6 +543,11 @@ def register_standard_browsers(): - "netscape", "opera", iexplore): - if shutil.which(browser): - register(browser, None, BackgroundBrowser(browser)) -+ elif sys.platform[:5] == "haiku": -+ # First try to use the default configured browser -+ register("haiku-default", None, GenericBrowser("open")) -+ # Fall back to WebPositive as the standard browser of Haiku -+ register("webpositive", None, BackgroundBrowser("WebPositive")) - else: - # Prefer X browsers if present - if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"): --- -2.37.3 - - -From 4f88341b84dd3b9745bbcb25b1e87ce6f2a5483b Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Fri, 4 Oct 2019 22:02:35 +0200 -Subject: since 3.8, don't reinit locks on fork. - - -diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py -index 1ab35a8..c6b54e4 100644 ---- a/Lib/logging/__init__.py -+++ b/Lib/logging/__init__.py -@@ -234,7 +234,7 @@ def _releaseLock(): - - # Prevent a held logging lock from blocking a child from logging. - --if not hasattr(os, 'register_at_fork'): # Windows and friends. -+if sys.platform.startswith('haiku') or not hasattr(os, 'register_at_fork'): # Windows and friends. - def _register_at_fork_reinit_lock(instance): - pass # no-op when os.register_at_fork does not exist. - else: --- -2.37.3 - - -From cb713611e36ca2764be44ced4896597fa45d2b16 Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Fri, 15 May 2020 15:20:57 +0200 -Subject: handle errors returned by internal_connect() - -upstream bug #40628 by Ryan C. Gordon - -diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c -index b29283e..7af682d 100644 ---- a/Modules/socketmodule.c -+++ b/Modules/socketmodule.c -@@ -3329,7 +3329,7 @@ sock_connect(PySocketSockObject *s, PyObject *addro) - } - - res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 1); -- if (res < 0) -+ if (res == -1) - return NULL; - - Py_RETURN_NONE; -@@ -3360,7 +3360,7 @@ sock_connect_ex(PySocketSockObject *s, PyObject *addro) - } - - res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 0); -- if (res < 0) -+ if (res == -1) - return NULL; - - return PyLong_FromLong((long) res); --- -2.37.3 - - -From a308b229f1478b10482539058ad5fed4eb084147 Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Mon, 19 Oct 2020 18:03:09 +0200 -Subject: ttyname_r can use MAXPATHLEN - - -diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c -index bf4e648..c8850d6 100644 ---- a/Modules/posixmodule.c -+++ b/Modules/posixmodule.c -@@ -3039,11 +3039,14 @@ static PyObject * - os_ttyname_impl(PyObject *module, int fd) - /*[clinic end generated code: output=c424d2e9d1cd636a input=9ff5a58b08115c55]*/ - { -- -+#ifndef __HAIKU__ - long size = sysconf(_SC_TTY_NAME_MAX); - if (size == -1) { - return posix_error(); - } -+#else -+ long size = MAXPATHLEN; -+#endif - char *buffer = (char *)PyMem_RawMalloc(size); - if (buffer == NULL) { - return PyErr_NoMemory(); --- -2.37.3 - - -From b83d3ac655d73f9d1d6437e3b67a52c2225eb3f2 Mon Sep 17 00:00:00 2001 -From: begasus -Date: Mon, 23 May 2022 08:45:31 +0200 -Subject: Fix search paths for tcl/tk - - -diff --git a/configure.ac b/configure.ac -index 2c7f344..8905063 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -3202,8 +3202,13 @@ then - then - AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither]) - fi -- TCLTK_INCLUDES="" -- TCLTK_LIBS="" -+ if test -n "$PKG_CONFIG" && "$PKG_CONFIG" --exists tcl tk; then -+ TCLTK_INCLUDES="`"$PKG_CONFIG" tcl tk --cflags-only-I 2>/dev/null`" -+ TCLTK_LIBS="`"$PKG_CONFIG" tcl tk --libs 2>/dev/null`" -+ else -+ TCLTK_INCLUDES="" -+ TCLTK_LIBS="" -+ fi - else - TCLTK_INCLUDES="$with_tcltk_includes" - TCLTK_LIBS="$with_tcltk_libs" --- -2.37.3 - - -From e73d5eac4396ca3ede2fe324808d94a993e3d127 Mon Sep 17 00:00:00 2001 -From: Oscar Lesta -Date: Fri, 21 Oct 2022 19:58:50 -0300 -Subject: Lib/test: require the "largefile" usage flag for I/O heavy tests. - -The same was done for Windows and MacOSX already. - -This avoids needing several GBs of storage to run the tests -(unless they "largefile" resource usage flag is enabled). - -diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py -index feee861..4f76448 100644 ---- a/Lib/test/test_io.py -+++ b/Lib/test/test_io.py -@@ -594,7 +594,7 @@ class IOTest(unittest.TestCase): - # On Windows and Mac OSX this test consumes large resources; It takes - # a long time to build the >2 GiB file and takes >2 GiB of disk space - # therefore the resource must be enabled to run this test. -- if sys.platform[:3] == 'win' or sys.platform == 'darwin': -+ if sys.platform[:3] == 'win' or sys.platform == 'darwin' or sys.platform == 'haiku1': - support.requires( - 'largefile', - 'test requires %s bytes and a long time to run' % self.LARGE) -diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py -index a99b4ba..1fb24ce 100644 ---- a/Lib/test/test_largefile.py -+++ b/Lib/test/test_largefile.py -@@ -250,7 +250,7 @@ def setUpModule(): - # takes a long time to build the >2 GiB file and takes >2 GiB of disk - # space therefore the resource must be enabled to run this test. - # If not, nothing after this line stanza will be executed. -- if sys.platform[:3] == 'win' or sys.platform == 'darwin': -+ if sys.platform[:3] == 'win' or sys.platform == 'darwin' or sys.platform == 'haiku1': - requires('largefile', - 'test requires %s bytes and a long time to run' % str(size)) - else: -diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py -index 5400f25..421025d 100644 ---- a/Lib/test/test_mmap.py -+++ b/Lib/test/test_mmap.py -@@ -805,7 +805,7 @@ class LargeMmapTests(unittest.TestCase): - unlink(TESTFN) - - def _make_test_file(self, num_zeroes, tail): -- if sys.platform[:3] == 'win' or sys.platform == 'darwin': -+ if sys.platform[:3] == 'win' or sys.platform == 'darwin' or sys.platform == 'haiku1': - requires('largefile', - 'test requires %s bytes and a long time to run' % str(0x180000000)) - f = open(TESTFN, 'w+b') --- -2.37.3 - - -From 11d6dae926568a5d460a7f01b5c0da9d60360bad Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Mon, 6 Mar 2023 22:51:40 +0100 -Subject: sysconfig: add haiku schemes - - diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index e3f79bf..574220b 100644 +index e3f79bf..8799679 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py -@@ -84,6 +84,33 @@ _INSTALL_SCHEMES = { +@@ -84,6 +84,36 @@ _INSTALL_SCHEMES = { 'scripts': '{userbase}/bin', 'data': '{userbase}', }, + 'haiku': { -+ 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', -+ 'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}', ++ 'stdlib': '{installed_base}/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/lib/python{py_version_short}', + 'purelib': '{base}/non-packaged/lib/python{py_version_short}/site-packages', -+ 'platlib': '{platbase}/non-packaged/{platlibdir}/python{py_version_short}/site-packages', -+ 'include': '{base}/non-packaged/develop/headers/python{py_version_short}', ++ 'platlib': '{platbase}/non-packaged/lib/python{py_version_short}/site-packages', ++ 'include': '{installed_base}/non-packaged/develop/headers/python{py_version_short}', ++ 'platinclude': '{installed_platbase}/develop/headers/python{py_version_short}', + 'scripts': '{base}/non-packaged/bin', + 'data' : '{base}/non-packaged', + }, + 'haiku_vendor': { -+ 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', -+ 'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}', ++ 'stdlib': '{installed_base}/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/lib/python{py_version_short}', + 'purelib': '{base}/lib/python{py_version_short}/vendor-packages', + 'platlib': '{platbase}/lib/python{py_version_short}/vendor-packages', -+ 'include': '{base}/develop/headers/python{py_version_short}', ++ 'include': '{installed_base}/develop/headers/python{py_version_short}', ++ 'platinclude': '{installed_platbase}/develop/headers/python{py_version_short}', + 'scripts': '{base}/bin', + 'data' : '{base}', + }, + 'haiku_home': { -+ 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', -+ 'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}', -+ 'purelib': '{userbase}/lib/python', -+ 'platlib': '{userbase}/lib/python', -+ 'include': '{userbase}/develop/headers/python/$dist_name', -+ 'scripts': '{userbase}/bin', -+ 'data' : '{userbase}', ++ 'stdlib': '{installed_base}/lib/python{py_version_short}', ++ 'platstdlib': '{base}/lib/python{py_version_short}', ++ 'purelib': '{base}/lib/python{py_version_short}', ++ 'platlib': '{base}/lib/python{py_version_short}', ++ 'include': '{installed_base}/develop/headers/python{py_version_short}', ++ 'platinclude': '{installed_base}/develop/headers/python{py_version_short}', ++ 'scripts': '{base}/bin', ++ 'data': '{base}', + }, } _SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include', -@@ -182,6 +209,10 @@ def _expand_vars(scheme, vars): +@@ -182,6 +212,10 @@ def _expand_vars(scheme, vars): def _get_default_scheme(): @@ -933,35 +988,167 @@ index e3f79bf..574220b 100644 if os.name == 'posix': # the default scheme for posix is posix_prefix return 'posix_prefix' --- -2.37.3 - - -From b6603db7aaeebbbb2c309f509ba4e74048253316 Mon Sep 17 00:00:00 2001 -From: Oscar Lesta -Date: Fri, 10 Mar 2023 19:24:51 -0300 -Subject: syncronize both _getuserbase() copies on site.py and sysconfig.py. - - -diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index 574220b..79c3ae5 100644 ---- a/Lib/sysconfig.py -+++ b/Lib/sysconfig.py -@@ -237,6 +237,14 @@ def _getuserbase(): +@@ -206,6 +240,14 @@ def _getuserbase(): return joinuser("~", "Library", sys._framework, "%d.%d" % sys.version_info[:2]) + if sys.platform.startswith('haiku'): + try: + import subprocess -+ return subprocess.run(['finddir', 'B_USER_NONPACKAGED_DIRECTORY'], -+ stdout=subprocess.PIPE, check=True).stdout.rstrip().decode('utf-8') ++ return subprocess.check_output( ++ ['finddir', 'B_USER_NONPACKAGED_DIRECTORY']).rstrip().decode('utf-8') + except: + pass + return joinuser("~", ".local") +diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py +index 0ca5c93..6704431 100644 +--- a/Lib/test/test_sysconfig.py ++++ b/Lib/test/test_sysconfig.py +@@ -229,7 +229,8 @@ class TestSysConfig(unittest.TestCase): + + def test_get_scheme_names(self): + wanted = ('nt', 'nt_user', 'osx_framework_user', +- 'posix_home', 'posix_prefix', 'posix_user') ++ 'posix_home', 'posix_prefix', 'posix_user', ++ 'haiku', 'haiku_vendor', 'haiku_home', 'haiku_user') + self.assertEqual(get_scheme_names(), wanted) + + @skip_unless_symlink -- -2.37.3 +2.45.2 + + +From 94a53c2c54fcba89c665a4a042cf158c65d1245e Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Thu, 25 Jul 2024 17:27:28 -0300 +Subject: Fix location of REPL's history file. + +Originally from "initial Haiku patch" by Jerome Duval. + +diff --git a/Lib/site.py b/Lib/site.py +index 6cbf2ac..5496e0c 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -484,8 +484,16 @@ def enablerlcompleter(): + # each interpreter exit when readline was already configured + # through a PYTHONSTARTUP hook, see: + # http://bugs.python.org/issue5845#msg198636 +- history = os.path.join(os.path.expanduser('~'), +- '.python_history') ++ import subprocess ++ try: ++ history = os.path.join(subprocess.check_output( ++ ['finddir', 'B_USER_VAR_DIRECTORY']).rstrip().decode('utf-8'), ++ 'python', 'history') ++ if not os.path.exists(os.path.dirname(history)): ++ os.makedirs(os.path.dirname(history)) ++ except subprocess.CalledProcessError: ++ history = os.path.join(os.path.expanduser('~'), ++ '.python_history') + try: + readline.read_history_file(history) + except OSError: +-- +2.45.2 + + +From 632d7535cdb016a5e37bc937c7df43a0d1cd6521 Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Sat, 10 Feb 2024 06:01:25 -0300 +Subject: Fix build on nightlies, following the addition of kqueue. + +Together with the patch for gh-109191, fixes HaikuPorts issue #10001. + +(back-ported from 3.10) + +diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c +index d4af4f7..59ad8d9 100644 +--- a/Modules/selectmodule.c ++++ b/Modules/selectmodule.c +@@ -2605,13 +2605,20 @@ PyInit_select(void) + #ifdef EVFILT_SIGNAL + PyModule_AddIntConstant(m, "KQ_FILTER_SIGNAL", EVFILT_SIGNAL); + #endif ++#ifdef EVFILT_TIMER + PyModule_AddIntConstant(m, "KQ_FILTER_TIMER", EVFILT_TIMER); +- ++#endif + /* event flags */ + PyModule_AddIntConstant(m, "KQ_EV_ADD", EV_ADD); + PyModule_AddIntConstant(m, "KQ_EV_DELETE", EV_DELETE); ++#ifdef EV_ENABLE + PyModule_AddIntConstant(m, "KQ_EV_ENABLE", EV_ENABLE); ++#else ++ PyModule_AddIntConstant(m, "KQ_EV_ENABLE", 0); // "test_kqueue.py" assumes KQ_EV_ENABLE exists ++#endif ++#ifdef EV_DISABLE + PyModule_AddIntConstant(m, "KQ_EV_DISABLE", EV_DISABLE); ++#endif + PyModule_AddIntConstant(m, "KQ_EV_ONESHOT", EV_ONESHOT); + PyModule_AddIntConstant(m, "KQ_EV_CLEAR", EV_CLEAR); + +@@ -2644,14 +2651,28 @@ PyInit_select(void) + /* PROC filter flags */ + #ifdef EVFILT_PROC + PyModule_AddIntConstant(m, "KQ_NOTE_EXIT", NOTE_EXIT); ++#ifdef NOTE_FORK + PyModule_AddIntConstant(m, "KQ_NOTE_FORK", NOTE_FORK); ++#endif ++#ifdef NOTE_EXEC + PyModule_AddIntConstant(m, "KQ_NOTE_EXEC", NOTE_EXEC); ++#endif ++#ifdef NOTE_PCTRLMASK + PyModule_AddIntConstant(m, "KQ_NOTE_PCTRLMASK", NOTE_PCTRLMASK); ++#endif ++#ifdef NOTE_PDATAMASK + PyModule_AddIntConstant(m, "KQ_NOTE_PDATAMASK", NOTE_PDATAMASK); ++#endif + ++#ifdef NOTE_TRACK + PyModule_AddIntConstant(m, "KQ_NOTE_TRACK", NOTE_TRACK); ++#endif ++#ifdef NOTE_CHILD + PyModule_AddIntConstant(m, "KQ_NOTE_CHILD", NOTE_CHILD); ++#endif ++#ifdef NOTE_TRACKERR + PyModule_AddIntConstant(m, "KQ_NOTE_TRACKERR", NOTE_TRACKERR); ++#endif + #endif + + /* NETDEV filter flags */ +-- +2.45.2 + + +From ddc695e40a048346de62c5d2797fc0a9f8e7dc96 Mon Sep 17 00:00:00 2001 +From: Alexander von Gluck IV +Date: Thu, 14 Mar 2024 12:54:33 -0500 +Subject: config.guess: Update to universal haiku arch guessing + +* Matches upstream config.guess as of 2022, python just + ships a really old one + +diff --git a/config.guess b/config.guess +index e81d3ae..366429c 100755 +--- a/config.guess ++++ b/config.guess +@@ -1364,8 +1364,11 @@ EOF + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + GUESS=i586-pc-haiku + ;; +- x86_64:Haiku:*:*) +- GUESS=x86_64-unknown-haiku ++ ppc:Haiku:*:*) ++ GUESS=powerpc-apple-haiku ++ ;; ++ *:Haiku:*:*) ++ GUESS=$UNAME_MACHINE-unknown-haiku + ;; + SX-4:SUPER-UX:*:*) + GUESS=sx4-nec-superux$UNAME_RELEASE +-- +2.45.2 diff --git a/dev-lang/python/patches/python3.9_x86-3.9.18.patchset b/dev-lang/python/patches/python3.9_x86-3.9.18.patchset deleted file mode 100644 index a235272c7..000000000 --- a/dev-lang/python/patches/python3.9_x86-3.9.18.patchset +++ /dev/null @@ -1,45 +0,0 @@ -From 672ea87bdc26e47c81052cecc9cfde9f4c7467a7 Mon Sep 17 00:00:00 2001 -From: Adrien Destugues -Date: Sat, 3 Feb 2018 11:33:49 +0100 -Subject: [PATCH] Fix include paths for secondary x86 - -This helps python find libraries and dependencies properly (openssl, -etc), so a few more modules are enabled. - -It also fixes a crash because python would try to load the gcc2 libroot -even when built with gcc5. ---- - Lib/ctypes/util.py | 1 + - setup.py | 4 ++-- - 2 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py -index b2e4095..34e56aa 100644 ---- a/Lib/ctypes/util.py -+++ b/Lib/ctypes/util.py -@@ -273,6 +273,7 @@ elif os.name == "posix": - directory = directory.replace('%A', - os.path.dirname(os.path.abspath(sys.argv[0] or os.getcwd()))) - -+ directory = os.path.join(directory, "x86") - if not os.path.isdir(directory): - continue - -diff --git a/setup.py b/setup.py -index 704e7ec..f480cc9 100644 ---- a/setup.py -+++ b/setup.py -@@ -696,8 +696,8 @@ class PyBuildExt(build_ext): - # Haiku-specific library locations - if HAIKU: - self.inc_dirs += ['/boot/develop/headers/posix', -- '/boot/system/develop/headers'] -- self.lib_dirs += ['/boot/system/develop/lib'] -+ '/boot/system/develop/headers/x86'] -+ self.lib_dirs += ['/boot/system/develop/lib/x86'] - # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) - if HOST_PLATFORM in ['osf1', 'unixware7', 'openunix8']: - self.lib_dirs += ['/usr/ccs/lib'] --- -2.23.0 - diff --git a/dev-lang/python/python3.9-3.9.18.recipe b/dev-lang/python/python3.9-3.9.18.recipe deleted file mode 100644 index b56bf161e..000000000 --- a/dev-lang/python/python3.9-3.9.18.recipe +++ /dev/null @@ -1,253 +0,0 @@ -SUMMARY="An interpreted, interactive, object-oriented programming language" -DESCRIPTION="Python is a programming language that lets you work more quickly \ -and integrate your systems more effectively. You can learn to use Python and \ -see almost immediate gains in productivity and lower maintenance costs. -Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java \ -and .NET virtual machines. -Python is free to use, even for commercial products, because of its \ -OSI-approved open source license." -HOMEPAGE="https://www.python.org" -LICENSE="Python" -COPYRIGHT="1990-2023 Python Software Foundation" -REVISION="1" -SOURCE_URI="https://www.python.org/ftp/python/$portVersion/Python-$portVersion.tar.xz" -CHECKSUM_SHA256="01597db0132c1cf7b331eff68ae09b5a235a3c3caa9c944c29cac7d1c4c4c00a" -SOURCE_DIR="Python-$portVersion" -PATCHES="python3.9-$portVersion.patchset" -if [ "$secondaryArchSuffix" = _x86 ] ; then - PATCHES+=" - python3.9_x86-$portVersion.patchset - " -fi - -ARCHITECTURES="all !x86_gcc2 ?x86" -SECONDARY_ARCHITECTURES="x86" - -# On x86_gcc2 we don't want to install the commands in bin//, but in bin/. -commandSuffix=$secondaryArchSuffix -commandBinDir=$binDir -if [ "$targetArchitecture" = x86_gcc2 ]; then - commandSuffix= - commandBinDir=$prefix/bin -fi - -PROVIDES=" - python3.9$secondaryArchSuffix = $portVersion compat >= 3.9 - python39$secondaryArchSuffix = $portVersion compat >= 3.9 - cmd:2to3_3.9 = $portVersion compat >= 3.9 - cmd:idle3.9 = $portVersion compat >= 3.9 - cmd:pydoc3.9 = $portVersion compat >= 3.9 - cmd:python3.9 = $portVersion compat >= 3.9 - cmd:python3.9_config = $portVersion compat >= 3.9 - devel:libpython3.9$secondaryArchSuffix = 1.0 - lib:libpython3.9$secondaryArchSuffix = 1.0 - " -REQUIRES=" - haiku$secondaryArchSuffix - cmd:file - lib:libbz2$secondaryArchSuffix - lib:libedit$secondaryArchSuffix - lib:libexpat$secondaryArchSuffix - lib:libffi$secondaryArchSuffix - lib:libintl$secondaryArchSuffix - lib:liblzma$secondaryArchSuffix - lib:libncurses$secondaryArchSuffix - lib:libsqlite3$secondaryArchSuffix - lib:libssl$secondaryArchSuffix - lib:libz$secondaryArchSuffix - " -BUILD_REQUIRES=" - haiku${secondaryArchSuffix}_devel - devel:libbz2$secondaryArchSuffix - devel:libedit$secondaryArchSuffix - devel:libexpat$secondaryArchSuffix - devel:libffi$secondaryArchSuffix - devel:liblzma$secondaryArchSuffix - devel:libncurses$secondaryArchSuffix - devel:libsqlite3$secondaryArchSuffix - devel:libssl$secondaryArchSuffix - devel:libtclstub8.6$secondaryArchSuffix - devel:libtk8.6$secondaryArchSuffix - devel:libz$secondaryArchSuffix - " -BUILD_PREREQUIRES=" - autoconf_archive - cmd:aclocal - cmd:autoconf - cmd:find - cmd:gcc$secondaryArchSuffix - cmd:ld$secondaryArchSuffix - cmd:libtoolize$secondaryArchSuffix - cmd:make - cmd:pkg_config$secondaryArchSuffix - " - -GLOBAL_WRITABLE_FILES=" - non-packaged/lib/python3.9/site-packages directory keep-old - " - -BUILD() -{ - autoreconf -fi - - # From ./configure: - # "compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just - # for debug/optimization stuff. BASECFLAGS is for flags that are required - # just to get things to compile and link." - export BASECFLAGS="-D_BSD_SOURCE" - - # Not exporting OPT ends up with "-g -fwrapv -O3 -Wall" being used, - # and using OPT="" means the build ends up being "-O0". - export OPT="-fwrapv -O3 -Wall" - - runConfigure --omit-dirs binDir,includeDir ./configure \ - --bindir=$commandBinDir \ - --includedir=$developDir/headers \ - --enable-optimizations \ - --enable-shared \ - --with-ensurepip=no \ - --with-system-expat \ - --with-system-ffi - # "configure: WARNING: --with(out)-system-ffi is ignored on this platform" - - # prevent make from rebuilding stuff that requires python - touch Parser/asdl* Python/Python-ast.c Include/Python-ast.h - - rm -f python - - # NOTE: When using "--enable-optimizations" above, using "make $jobArgs" might be unreliable. - # make clean # Uncomment when doing repeated builds (for testing different flags/options). - make $jobArgs -} - -INSTALL() -{ - # altinstall avoids clobbering $prefix/bin/{2to3,idle3,pydoc3,python3,python3-config} - make altinstall - - rm $libDir/libpython3.so - - if [ "$targetArchitecture" = x86_gcc2 ]; then - # On x86_gcc2, move lib-dynload to lib/python3.x/ - mv $libDir/python3.9/lib-dynload $prefix/lib/python3.9/ - fi - prepareInstalledDevelLibs libpython3.9 - fixPkgconfig - if [ "$targetArchitecture" = x86_gcc2 ]; then - # fix pkgconfig to match configure flags - sed -i -e 's,headers/x86,headers,' $developLibDir/pkgconfig/python*.pc - fi - - mkdir -p $prefix/lib/python3.9/vendor-packages - echo 'This directory contains packaged python modules.' \ - >$prefix/lib/python3.9/vendor-packages/README - - mkdir -p $prefix/non-packaged/lib/python3.9 - mv $prefix/lib/python3.9/site-packages $prefix/non-packaged/lib/python3.9/ - - # drop testsuite altogether; move to a separate package if needed - cd $prefix/lib/python3.9 - rm -rf ctypes/test distutils/tests idlelib/idle_test lib2to3/tests \ - sqlite3/test test tkinter/test unittest/test -} - -# Some of the test will crash, invoking the crash dialog, and will hang waiting for -# user's interaction. To avoid that, make sure to configure your system by adding -# the following lines in the file "~/config/settings/system/debug_server/settings": -##--- -# executable_actions { -# /sources/Python-$portVersion/python kill -# } -##--- -# Replace $portVersion as necessary. - -# For some tests that purposefully crash, it would make sense to add support for -# crash-report suppression (as done for other platforms) on "tests/support/__init__,py"'s -# SuppressCrashReport class. -# But that needs support from Haiku's debug_server, as we can't change settings from -# the recipe's building environment at the moment (https://dev.haiku-os.org/ticket/10301) - -TEST() -{ - # Remove tests data left-overs, if any - rm -f -r /boot/system/cache/tmp/ - rm -f -d -r build/test_python* - - cd Lib/test - - # distutils is deprecated, and will be removed on 3.12. - rm -f test_distutils.py - - # The following tests invoke the crash dialog, and unless your configure - # debug_server default action to "kill" or "report", they will hang waiting for - # user input. See comment above TEST(). - rm -f test_asyncio/test_futures.py # Crashes: Exception (Segment violation) - rm -f test_faulthandler.py - rm -f test_subprocess.py # tends to hang. - rm -f test_threading.py # tends to hang. - - # Many of the tests hang/stall. We have two options: - # - # 1- Manually remove the problematic test-cases. - # 2- Set a TIMEOUT. - # - # Option 1: Works, but requires manual identification/mainteinance. - # - # Option 2: Doesn't requires maintaining a list of stalling tests, but: - # - Causes errors at the end of the run: - # "unmounting failed: Device/File/Resource Busy" - # - Leaves dangling threads running when the tests timeout: - # "Warning -- threading_cleanup() failed to cleanup 0 threads (count: 0, dangling: 2)" - # - The time it takes to run the full suite goes from 14 to 30+ minutes, - # - # For Option 2, use: export EXTRATESTOPTS="--timeout=300" - # before calling "make $jobArgs test". - # - # Let's use Option 1, for now at least: - - # These hang reliably. - # You might want then to manually restore them on re-runs, use: - # > git checkout -- Lib/test/ - rm -f test__xxsubinterpreters.py - rm -f test_asynchat.py - rm -f test_concurrent_futures.py - rm -f test_importlib/test_threaded_import.py - rm -f test_interpreters.py - rm -f test_multiprocessing_fork.py - rm -f test_multiprocessing_forkserver.py - rm -f test_multiprocessing_main_handling.py - rm -f test_multiprocessing_spawn.py - rm -f test_multiprocessing.py - rm -f test_socketserver.py - - # "test_asyncio" doesn't seems to runs reliably, even after individually skipping - # all the problematic test-cases that could be identify by running them one by one. - rm -f -r test_asyncio -# rm -f test_asyncio/test_base_events.py -# rm -f test_asyncio/test_buffered_proto.py # Exception on Exception handler. -# rm -f test_asyncio/test_events.py -# rm -f test_asyncio/test_sendfile.py -# rm -f test_asyncio/test_server.py # Exception on Exception handler. -# rm -f test_asyncio/test_sslproto.py # Exception on Exception handler. -# rm -f test_asyncio/test_streams.py - - # These not always hang/stall, but they do it enough to warrant skipping for now. - rm -f test_imaplib.py - rm -f test_signal.py - rm -f test_socket.py - rm -f test_ssl.py - rm -f test_urllib2_localnet.py - - cd ../.. - - # These allows to change what resources tests can use: - # export EXTRATESTOPTS="-uall,-largefile,-audio,-gui,-network,-cpu,-urlfetch,-tzdata" - - # Occasionally, some test fails seemingly due to the racy nature of tempfile.mktemp(). - # Even the help for that function says to NOT use it, but some tests still do. - # - # If you find some strange "æ" suffix on temp dirnames, ej: - # "cwd: /sources/Python-3.10.12/build/test_python_10324æ" - # That's due to usages of os_helper.FS_NONASCII. - make $jobArgs test -} diff --git a/dev-lang/python/python3.9-3.9.19.recipe b/dev-lang/python/python3.9-3.9.19.recipe new file mode 100644 index 000000000..83ed8630c --- /dev/null +++ b/dev-lang/python/python3.9-3.9.19.recipe @@ -0,0 +1,400 @@ +SUMMARY="An interpreted, interactive, object-oriented programming language" +DESCRIPTION="Python is a programming language that lets you work more quickly \ +and integrate your systems more effectively. You can learn to use Python and \ +see almost immediate gains in productivity and lower maintenance costs. + +Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java \ +and .NET virtual machines. + +Python is free to use, even for commercial products, because of its \ +OSI-approved open source license." +HOMEPAGE="https://www.python.org" +LICENSE="Python" +COPYRIGHT="1990-2024 Python Software Foundation" +REVISION="1" +SOURCE_URI="https://www.python.org/ftp/python/$portVersion/Python-$portVersion.tar.xz" +CHECKSUM_SHA256="d4892cd1618f6458cb851208c030df1482779609d0f3939991bd38184f8c679e" +SOURCE_DIR="Python-$portVersion" + +pyShortVer="${portVersion%.*}" +pyVersionCompat="$portVersion compat >= $pyShortVer" + +PATCHES="python$pyShortVer-$portVersion.patchset" + +ARCHITECTURES="all !x86_gcc2" +SECONDARY_ARCHITECTURES="x86" + +# On x86_gcc2 we don't want to install the commands in bin//, but in bin/. +commandSuffix=$secondaryArchSuffix +commandBinDir=$binDir +if [ "$targetArchitecture" = x86_gcc2 ]; then + commandSuffix= + commandBinDir=$prefix/bin +fi + +GLOBAL_WRITABLE_FILES=" + non-packaged/lib/python$pyShortVer/site-packages directory keep-old + " + +# [RECIPE OPTIONS]>>> + +# If this is not intended to be the "default" Python version, set to "false", so "make altinstall" +# is used, and only version-suffixed commands are used in PROVIDES. +installAsDefaultPython=false + +# Set to "true" if we should build the "tkinter" module. +# Disabled for now, as tkinter deadlocks on Haiku. Try again when tk drops undroidwish for xlibe. +enableTkinter=false + +# Set to "true" to package all the tests into a separate "_tests" package (around 30 MB in size). +# Tests are discarded if set to "false". +packageTests=false + +# Set to "false" for faster local/test builds. Around 4 to 5 times faster that way. +optimizedBuild=true + +# Run all tests by default. Set to "true" to make "hp --test" only run then known failing tests. +runOnlyKnownFailingTests=false + +# <<<[RECIPE OPTIONS] + +PROVIDES=" + python$pyShortVer$secondaryArchSuffix = $pyVersionCompat + cmd:2to3_$pyShortVer = $pyVersionCompat + cmd:pydoc$pyShortVer = $pyVersionCompat + cmd:python$pyShortVer = $pyVersionCompat + cmd:python${pyShortVer}_config = $pyVersionCompat + devel:libpython$pyShortVer$secondaryArchSuffix = 1.0 + lib:libpython$pyShortVer$secondaryArchSuffix = 1.0 + " +REQUIRES=" + haiku$secondaryArchSuffix + cmd:file + lib:libbz2$secondaryArchSuffix + lib:libedit$secondaryArchSuffix # Using libedit instead of readline only works on Python >=3.10 + lib:libexpat$secondaryArchSuffix + lib:libffi$secondaryArchSuffix + lib:libintl$secondaryArchSuffix + lib:liblzma$secondaryArchSuffix + lib:libncursesw$secondaryArchSuffix + lib:libsqlite3$secondaryArchSuffix + lib:libssl$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " +REPLACES=" + python39$secondaryArchSuffix + " +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libbz2$secondaryArchSuffix + devel:libedit$secondaryArchSuffix + devel:libexpat$secondaryArchSuffix + devel:libffi$secondaryArchSuffix + devel:liblzma$secondaryArchSuffix + devel:libncursesw$secondaryArchSuffix + devel:libsqlite3$secondaryArchSuffix + devel:libssl$secondaryArchSuffix + devel:libz$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + autoconf_archive + cmd:aclocal + cmd:autoconf + cmd:find + cmd:gcc$secondaryArchSuffix + cmd:ld$secondaryArchSuffix + cmd:libtoolize$secondaryArchSuffix + cmd:make + cmd:pkg_config$secondaryArchSuffix + " + +if $installAsDefaultPython; then + PROVIDES+=" + cmd:2to3 = $portVersion compat >= $pyShortVer + cmd:python3 = $portVersion compat >= $pyShortVer + cmd:pydoc3 = $portVersion compat >= $pyShortVer + cmd:python3_config = $portVersion compat >= $pyShortVer + " +fi + +if $enableTkinter; then + PROVIDES+=" + cmd:idle$pyShortVer = $pyVersionCompat + " + if $installAsDefaultPython; then + PROVIDES+=" + cmd:idle3 = $portVersion compat >= $pyShortVer + " + fi + BUILD_REQUIRES+=" + devel:libtclstub8.6$secondaryArchSuffix + devel:libtk8.6$secondaryArchSuffix + " +fi + +if $packageTests; then + PROVIDES_tests=" + python$pyShortVer${secondaryArchSuffix}_tests = $portVersion + " + REQUIRES_tests=" + python$pyShortVer$secondaryArchSuffix == $portVersion base + " +fi + +BUILD() +{ + autoupdate + autoreconf -fi + + # From ./configure: + # "compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just + # for debug/optimization stuff. BASECFLAGS is for flags that are required + # just to get things to compile and link." + + # If not provided, the Makefile ends up with: + # BASECFLAGS= -Wno-unused-result -Wsign-compare + # OPT= -DNDEBUG -g -fwrapv -O3 -Wall + # -NDEBUG gets added by ./configure unless "--with-assertions" is used. + + export BASECFLAGS="-pipe -D_BSD_SOURCE" + export OPT="-fwrapv -Wall" # remove "-g" until we use "defineDebugInfoPackage". + + if $optimizedBuild; then + export OPT+=" -O3" + maybeEnableOptimizations="--enable-optimizations" + else + export OPT+=" -O0" + maybeEnableOptimizations= + fi + + runConfigure --omit-dirs binDir,includeDir ./configure \ + --bindir=$commandBinDir \ + --includedir=$developDir/headers \ + $maybeEnableOptimizations \ + --enable-shared \ + --with-ensurepip=no \ + --with-system-expat \ + --with-system-ffi + # "configure: WARNING: --with(out)-system-ffi is ignored on this platform" + + # Uncomment when doing repeated builds (for testing different flags/options). + # echo "[.recipe] Cleaning before rebuild:" && make clean && rm -f python + + # NOTE: When using "--enable-optimizations" above, using "make $jobArgs" might be unreliable. + make $jobArgs +} + +INSTALL() +{ + if $installAsDefaultPython; then + make install + else + # altinstall avoids clobbering $prefix/bin/{idle3,pydoc3,python3,python3-config} + make altinstall + fi + + rm $libDir/libpython3.so + + # No point in having this if we don't have a working tkinter. + if ! $enableTkinter; then + rm $prefix/bin/idle$pyShortVer + if $installAsDefaultPython; then + rm -f $prefix/bin/idle3 + fi + fi + + if [ "$targetArchitecture" = x86_gcc2 ]; then + # On x86_gcc2, move lib-dynload to lib/python3.x/ + mv $libDir/python$pyShortVer/lib-dynload $prefix/lib/python$pyShortVer/ + fi + prepareInstalledDevelLib libpython$pyShortVer + fixPkgconfig + if [ "$targetArchitecture" = x86_gcc2 ]; then + # fix pkgconfig to match configure flags + sed -i -e 's,headers/x86,headers,' $developLibDir/pkgconfig/python*.pc + fi + + mkdir -p $prefix/lib/python$pyShortVer/vendor-packages + echo 'This directory contains packaged python modules.' \ + >$prefix/lib/python$pyShortVer/vendor-packages/README + + mkdir -p $prefix/non-packaged/lib/python$pyShortVer + mv $prefix/lib/python$pyShortVer/site-packages $prefix/non-packaged/lib/python$pyShortVer/ + + if $packageTests; then + packageEntries tests \ + $prefix/lib/python$pyShortVer/idlelib/idle_test \ + $prefix/lib/python$pyShortVer/test + else + # drop testsuite altogether + cd $prefix/lib/python$pyShortVer + rm -rf ctypes/test distutils/tests idlelib/idle_test lib2to3/tests sqlite3/test test \ + tkinter/test unittest/test + fi +} + +# Some of the test will crash, invoking the crash dialog, and will hang waiting for +# user's interaction. To avoid that, make sure to configure your system by adding +# the following lines in the file "~/config/settings/system/debug_server/settings": +##--- +# executable_actions { +# /sources/Python-3.*/python kill +# } +##--- + +# For some tests that purposefully crash, it would make sense to add support for +# crash-report suppression (as done for other platforms) on "tests/support/__init__,py"'s +# SuppressCrashReport class. +# But that needs support from Haiku's debug_server, as we can't change settings from +# the recipe's building environment at the moment (https://dev.haiku-os.org/ticket/10301) + +# To see the available test-runs options: +# > hp -E python3.nn +# > LIBRARY_PATH=%A:/boot/system/lib python -m test --help +# or: +# > LD_PRELOAD=./libpython3.nn.so.1.0 python -m test --help +# +# To only execute a particular test (from the $sourceDir): +# +# > LD_PRELOAD=./libpython3.nn.so.1.0 python -m test test_datetime -W +# +# Beware that running tests that way can cause some tests to fail, while they work fine under +# "hp --test"'s chroot. (test_sysconfig.MakefileTests.test_parse_makefile, for example). +# Problem is "os.getcwd()" will return wrong data, causing some file operations to fail. + +# For reference... Tests results on beta4 (x64) in about 20 minutes: +# 352 tests OK. 25 tests failed. 29 tests skipped. +TEST() +{ + # Remove tests data left-overs, if any: + # rm -f -r /boot/system/cache/tmp/ + # rm -f -d -r build/test_python* + make $jobArgs test EXTRATESTOPTS="--cleanup" + + local test_options=( + # Use this to get same test order on different runs (actual value not important). + --randseed 7858065 + + # Print the names of the 10 slowest tests. + --slowest + + # Possibly useful? + # --tempdir=/another_drive/tmp + + # Enable/disable certain tests by "resource" type: + # -uall,-audio,-cpu,-curses,-decimal,-gui,-largefile,-network,-subprocess,-urlfetch + # make test --help says that "-unone" is the default, but the build is doing this: + # "resources: all,-audio,-gui,-largefile" instead. + # + # Let's be explicit to avoid surprises: + -unone,curses,tzdata + ) + + local tests_to_exclude=( + # distutils is deprecated, and will be removed on 3.12. + -x test_distutils + + # The following tests invoke the crash dialog, and unless your configure + # debug_server default action to "kill" or "report", they will hang waiting for + # user input. See comment above TEST(). + -x test_faulthandler + -x test_futures # from test_asyncio. Crashes: Exception (Segment violation) + -x test_subprocess # tends to hang. + -x test_threading # tends to hang. + + # Many of the tests hang/stall. We have two options: + # + # 1- Manually remove the problematic test-cases. + # 2- Set a TIMEOUT. + # + # Option 1: Works, but requires manual identification/mainteinance. + # + # Option 2: Doesn't requires maintaining a list of stalling tests, but: + # - Causes errors at the end of the run: + # "unmounting failed: Device/File/Resource Busy" + # - Leaves dangling threads running when the tests timeout: + # "Warning -- threading_cleanup() failed to cleanup 0 threads (count: 0, dangling: 2)" + # - The time it takes to run the full suite goes from 14 to 30+ minutes, + # + # For Option 2, use: export EXTRATESTOPTS="--timeout=300" + # before calling "make $jobArgs test". + # + # Let's use Option 1, for now at least: + + # These hang reliably. + -x test__xxsubinterpreters + -x test_asynchat + -x test_concurrent_futures + -x test_importlib + -x test_interpreters + -x test_multiprocessing + -x test_multiprocessing_fork + -x test_multiprocessing_forkserver + -x test_multiprocessing_main_handling + -x test_multiprocessing_spawn + -x test_socketserver + -x test_threaded_import # test_importlib/test_threaded_import + + # "test_asyncio" doesn't seems to runs reliably, even after individually skipping + # all the problematic test-cases that could be identify by running them one by one. + -x test_asyncio + # -x test_asyncio/test_base_events + # -x test_asyncio/test_buffered_proto # Exception on Exception handler. + # -x test_asyncio/test_events + # -x test_asyncio/test_sendfile + # -x test_asyncio/test_server # Exception on Exception handler. + # -x test_asyncio/test_sslproto # Exception on Exception handler. + # -x test_asyncio/test_streams + + # These not always hang/stall, but they do it enough to warrant skipping for now. + -x test_imaplib + -x test_signal + -x test_socket + -x test_ssl + -x test_urllib2_localnet + ) + + local tests_that_fail=( + test_asyncore + test_builtin + test_c_locale_coercion + test_compileall + test_datetime + test_eintr + test_fcntl + test_ftplib + test_genericpath + test_json + test_logging + test_mailbox + test_os + test_peg_generator + test_popen + test_posix + test_pty + test_re + test_shutil + test_site + test_sysconfig + test_tarfile + test_time + test_tools + test_utf8_mode + ) + + local -x LOGNAME=buildbot # this skips tests_tools/test_freeze, copied from Gentoo's ebuild + + if $runOnlyKnownFailingTests; then + make $jobArgs test EXTRATESTOPTS="${test_options[*]} ${tests_that_fail[*]}" + else + # Runs the full test suite (minus the tests that we explicitly exclude). + make $jobArgs test EXTRATESTOPTS="${test_options[*]} ${tests_to_exclude[*]}" + fi + + # Occasionally, some test fails seemingly due to the racy nature of tempfile.mktemp(). + # Even the help for that function says to NOT use it, but some tests still do. + # + # If you find some strange "æ" suffix on temp dirnames, ej: + # "cwd: /sources/Python-3.nn.nn/build/test_python_10324æ" + # That's due to usages of os_helper.FS_NONASCII. +}