mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-10 13:50:08 +02:00
python3.12: add recipe for Python version 3.12.0. (#9602)
This commit is contained in:
835
dev-lang/python/patches/python3.12-3.12.0.patchset
Normal file
835
dev-lang/python/patches/python3.12-3.12.0.patchset
Normal file
@@ -0,0 +1,835 @@
|
||||
From df5c54613613970c62e0bb947915137a4cba20dc Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 01:02:25 -0300
|
||||
Subject: initial Haiku patch
|
||||
|
||||
Based on the patch from Jerome Duval, modified to make it apply cleanly
|
||||
over 3.12's sources.
|
||||
|
||||
Parts of that original patch were split into specific commit/patches.
|
||||
|
||||
diff --git a/Include/pyport.h b/Include/pyport.h
|
||||
index 35eca72..7dd2f84 100644
|
||||
--- a/Include/pyport.h
|
||||
+++ b/Include/pyport.h
|
||||
@@ -691,7 +691,7 @@ extern char * _getpty(int *, int, mode_t, int);
|
||||
# define _Py_FORCE_UTF8_LOCALE
|
||||
#endif
|
||||
|
||||
-#if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__)
|
||||
+#if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__) || defined(__HAIKU__)
|
||||
// Use UTF-8 as the filesystem encoding.
|
||||
// See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(),
|
||||
// Py_DecodeLocale() and Py_EncodeLocale().
|
||||
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 09ceccd..921668a 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -147,7 +147,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 3c89468..3ea22bf 100644
|
||||
--- a/Modules/resource.c
|
||||
+++ b/Modules/resource.c
|
||||
@@ -124,6 +124,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));
|
||||
@@ -138,7 +139,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;
|
||||
@@ -387,19 +403,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
|
||||
|
||||
@@ -411,31 +427,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.h b/Modules/socketmodule.h
|
||||
index f5ca004..1ed1819 100644
|
||||
--- a/Modules/socketmodule.h
|
||||
+++ b/Modules/socketmodule.h
|
||||
@@ -111,6 +111,10 @@ typedef int socklen_t;
|
||||
# undef AF_QIPCRTR
|
||||
#endif
|
||||
|
||||
+#if defined(__HAIKU__)
|
||||
+#undef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
+#endif
|
||||
+
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/rfcomm.h>
|
||||
diff --git a/Modules/spwdmodule.c b/Modules/spwdmodule.c
|
||||
index 13f1115..45f477c 100644
|
||||
--- a/Modules/spwdmodule.c
|
||||
+++ b/Modules/spwdmodule.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifdef HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
+#include <errno.h>
|
||||
|
||||
#include "clinic/spwdmodule.c.h"
|
||||
|
||||
@@ -148,7 +149,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 ba768ae..7d4c2a2 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1519,6 +1519,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)
|
||||
@@ -1664,6 +1674,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
|
||||
@@ -3405,7 +3416,7 @@ then
|
||||
else CCSHARED="+z";
|
||||
fi;;
|
||||
Linux-android*) ;;
|
||||
- Linux*|GNU*) CCSHARED="-fPIC";;
|
||||
+ Linux*|GNU*|Haiku*) CCSHARED="-fPIC";;
|
||||
Emscripten*|WASI*)
|
||||
AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
|
||||
CCSHARED="-fPIC"
|
||||
@@ -3438,7 +3449,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"
|
||||
@@ -5585,6 +5596,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])
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From 8060168bd8aad149b472d7df7eea26de9c762b6b Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
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 6df5dd5..39dde15 100644
|
||||
--- a/Lib/subprocess.py
|
||||
+++ b/Lib/subprocess.py
|
||||
@@ -1938,6 +1938,8 @@ class Popen:
|
||||
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 2d88f5e..4f4107d 100644
|
||||
--- a/Modules/_posixsubprocess.c
|
||||
+++ b/Modules/_posixsubprocess.c
|
||||
@@ -749,6 +749,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.42.0
|
||||
|
||||
|
||||
From 4612cb6c4e15103be299909cd0e70307e9040e2f Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 20:06:31 -0300
|
||||
Subject: Implement CTypes's find_library for Haiku
|
||||
|
||||
This combines:
|
||||
- the original patch by Philippe Houdoin <philippe.houdoin@gmail.com>
|
||||
- A slight variation of Adrien Destugues' fix for x86_gcc2.
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 0c2510e..6912890 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.42.0
|
||||
|
||||
|
||||
From 8ee1d200626134a91f104725bb98855c5b233156 Mon Sep 17 00:00:00 2001
|
||||
From: Philipp Wolfer <phil@parolu.io>
|
||||
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 e0170af..8567cdd 100755
|
||||
--- a/Lib/webbrowser.py
|
||||
+++ b/Lib/webbrowser.py
|
||||
@@ -477,6 +477,12 @@ def register_standard_browsers():
|
||||
# SerenityOS webbrowser, simply called "Browser".
|
||||
register("Browser", None, BackgroundBrowser("Browser"))
|
||||
|
||||
+ if 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"))
|
||||
+
|
||||
if sys.platform[:3] == "win":
|
||||
# First try to use the default Windows browser
|
||||
register("windows-default", WindowsDefault)
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From 14eb288ddca79c42e4d8ab2edaba990a04e3dc7e Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
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 056380f..4836719 100644
|
||||
--- a/Lib/logging/__init__.py
|
||||
+++ b/Lib/logging/__init__.py
|
||||
@@ -250,7 +250,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.42.0
|
||||
|
||||
|
||||
From 607f0a89afcf78f21a9341a861ff392bf86c9dd4 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
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 4ec68e2..ce5940a 100644
|
||||
--- a/Modules/socketmodule.c
|
||||
+++ b/Modules/socketmodule.c
|
||||
@@ -3489,7 +3489,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;
|
||||
@@ -3520,7 +3520,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.42.0
|
||||
|
||||
|
||||
From 959d4fd2ff3ebe73727ad275c2a48018bab26f11 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
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 b9ca286..8badc69 100644
|
||||
--- a/Modules/posixmodule.c
|
||||
+++ b/Modules/posixmodule.c
|
||||
@@ -3150,11 +3150,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.42.0
|
||||
|
||||
|
||||
From 2b11dd68750848d57c2d29e9d03905664989f826 Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Mon, 24 Oct 2022 20:04:10 -0300
|
||||
Subject: Lib/test: require the "largefile" usage flag for I/O heavy tests.
|
||||
|
||||
The same is done for Windows and macOS already.
|
||||
|
||||
This avoids needing several GBs of storage to run the tests
|
||||
(unless the "largefile" resource usage flag is enabled).
|
||||
|
||||
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
|
||||
index e032325..ffff694 100644
|
||||
--- a/Lib/test/test_io.py
|
||||
+++ b/Lib/test/test_io.py
|
||||
@@ -609,7 +609,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[:5] == 'haiku':
|
||||
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 3b0930f..c793ea1 100644
|
||||
--- a/Lib/test/test_largefile.py
|
||||
+++ b/Lib/test/test_largefile.py
|
||||
@@ -255,7 +255,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[:5] == 'haiku':
|
||||
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 dfcf303..886d3af 100644
|
||||
--- a/Lib/test/test_mmap.py
|
||||
+++ b/Lib/test/test_mmap.py
|
||||
@@ -1007,7 +1007,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[:5] == 'haiku':
|
||||
requires('largefile',
|
||||
'test requires %s bytes and a long time to run' % str(0x180000000))
|
||||
f = open(TESTFN, 'w+b')
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From e2bd114cfa56d90620bccd2985e87c51ee8d34cb Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 01:04:42 -0300
|
||||
Subject: default schemes for Haiku
|
||||
|
||||
Based on previous patches by Jerome Duval.
|
||||
|
||||
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
||||
index 122d441..a27fa57 100644
|
||||
--- a/Lib/sysconfig.py
|
||||
+++ b/Lib/sysconfig.py
|
||||
@@ -47,6 +47,34 @@ _INSTALL_SCHEMES = {
|
||||
'scripts': '{base}/bin',
|
||||
'data': '{base}',
|
||||
},
|
||||
+ 'haiku': {
|
||||
+ 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}',
|
||||
+ 'platstdlib': '{platbase}/{platlibdir}/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}',
|
||||
+ '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}',
|
||||
+ '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}',
|
||||
+ 'scripts': '{base}/bin',
|
||||
+ 'data' : '{base}',
|
||||
+ },
|
||||
+ 'haiku_home': {
|
||||
+ 'stdlib': '{installed_base}/lib/python',
|
||||
+ 'platstdlib': '{base}/lib/python',
|
||||
+ 'purelib': '{base}/lib/python',
|
||||
+ 'platlib': '{base}/lib/python',
|
||||
+ 'include': '{installed_base}/develop/headers/python',
|
||||
+ 'platinclude': '{installed_base}/develop/headers/python',
|
||||
+ 'scripts': '{base}/bin',
|
||||
+ 'data': '{base}',
|
||||
+ },
|
||||
'nt': {
|
||||
'stdlib': '{installed_base}/Lib',
|
||||
'platstdlib': '{base}/Lib',
|
||||
@@ -152,6 +180,15 @@ if _HAS_USER_BASE:
|
||||
'scripts': '{userbase}/bin',
|
||||
'data': '{userbase}',
|
||||
},
|
||||
+ 'haiku_user': {
|
||||
+ 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}',
|
||||
+ 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}',
|
||||
+ 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
|
||||
+ 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
|
||||
+ 'include': '{userbase}/develop/headers/python{py_version_short}',
|
||||
+ 'scripts': '{userbase}/bin',
|
||||
+ 'data': '{userbase}',
|
||||
+ },
|
||||
'osx_framework_user': {
|
||||
'stdlib': '{userbase}/lib/python',
|
||||
'platstdlib': '{userbase}/lib/python',
|
||||
@@ -282,6 +319,18 @@ def _expand_vars(scheme, vars):
|
||||
|
||||
|
||||
def _get_preferred_schemes():
|
||||
+ if sys.platform.startswith('haiku'):
|
||||
+ if os.environ.get('HAIKU_USE_VENDOR_DIRECTORIES') == '1':
|
||||
+ return {
|
||||
+ 'prefix': 'haiku_vendor',
|
||||
+ 'home': 'haiku_home',
|
||||
+ 'user': 'haiku_user',
|
||||
+ }
|
||||
+ return {
|
||||
+ 'prefix': 'haiku',
|
||||
+ 'home': 'haiku_home',
|
||||
+ 'user': 'haiku_user',
|
||||
+ }
|
||||
if os.name == 'nt':
|
||||
return {
|
||||
'prefix': 'nt',
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From 3e16846d599f86dc1060af64ee270aaf450d628a Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 01:05:12 -0300
|
||||
Subject: Fix _getuserbase() and getsizepackages() for Haiku.
|
||||
|
||||
Based on previous patches by Jerome Duval and me.
|
||||
|
||||
diff --git a/Lib/site.py b/Lib/site.py
|
||||
index 672fa7b..e783664 100644
|
||||
--- a/Lib/site.py
|
||||
+++ b/Lib/site.py
|
||||
@@ -281,6 +281,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')
|
||||
+ except:
|
||||
+ pass
|
||||
+
|
||||
return joinuser("~", ".local")
|
||||
|
||||
|
||||
@@ -361,7 +369,14 @@ def getsitepackages(prefixes=None):
|
||||
continue
|
||||
seen.add(prefix)
|
||||
|
||||
- if os.sep == '/':
|
||||
+ if sys.platform.startswith('haiku'):
|
||||
+ sitepackages.append(os.path.join(prefix, "non-packaged", "lib",
|
||||
+ "python%d.%d" % sys.version_info[:2],
|
||||
+ "site-packages"))
|
||||
+ sitepackages.append(os.path.join(prefix, "lib",
|
||||
+ "python%d.%d" % sys.version_info[:2],
|
||||
+ "vendor-packages"))
|
||||
+ elif os.sep == '/':
|
||||
libdirs = [sys.platlibdir]
|
||||
if sys.platlibdir != "lib":
|
||||
libdirs.append("lib")
|
||||
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
|
||||
index a27fa57..80e1c3f 100644
|
||||
--- a/Lib/sysconfig.py
|
||||
+++ b/Lib/sysconfig.py
|
||||
@@ -155,6 +155,14 @@ def _getuserbase():
|
||||
return joinuser("~", "Library", sys._framework,
|
||||
f"{sys.version_info[0]}.{sys.version_info[1]}")
|
||||
|
||||
+ 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')
|
||||
+ except:
|
||||
+ pass
|
||||
+
|
||||
return joinuser("~", ".local")
|
||||
|
||||
_HAS_USER_BASE = (_getuserbase() is not None)
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From 374f9308fed872a638ea31a041ff2e476bc95220 Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 01:05:31 -0300
|
||||
Subject: Fix location of REPL's history file.
|
||||
|
||||
From "initial Haiku patch" by Jerome Duval.
|
||||
|
||||
diff --git a/Lib/site.py b/Lib/site.py
|
||||
index e783664..da965d6 100644
|
||||
--- a/Lib/site.py
|
||||
+++ b/Lib/site.py
|
||||
@@ -480,8 +480,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:
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From a4920c9e12d2225ec24df04ef1686a6ad63adb31 Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 02:17:22 -0300
|
||||
Subject: Miscellaneous "Lib/test/" fixes for Haiku.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
test_fileio.py fix from "initial Haiku patch" by Jérôme Duval.
|
||||
|
||||
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
|
||||
index 55e0619..24a811e 100644
|
||||
--- a/Lib/test/datetimetester.py
|
||||
+++ b/Lib/test/datetimetester.py
|
||||
@@ -5917,6 +5917,9 @@ def pairs(iterable):
|
||||
|
||||
class ZoneInfo(tzinfo):
|
||||
zoneroot = '/usr/share/zoneinfo'
|
||||
+ if sys.platform.startswith('haiku'):
|
||||
+ zoneroot = '/system/data/zoneinfo'
|
||||
+
|
||||
def __init__(self, ut, ti):
|
||||
"""
|
||||
|
||||
diff --git a/Lib/test/test_email/test_utils.py b/Lib/test/test_email/test_utils.py
|
||||
index 25fa48c..ee46514 100644
|
||||
--- a/Lib/test/test_email/test_utils.py
|
||||
+++ b/Lib/test/test_email/test_utils.py
|
||||
@@ -145,7 +145,8 @@ class LocaltimeTests(unittest.TestCase):
|
||||
# XXX: Need a more robust test for Olson's tzdata
|
||||
@unittest.skipIf(sys.platform.startswith('win'),
|
||||
"Windows does not use Olson's TZ database")
|
||||
- @unittest.skipUnless(os.path.exists('/usr/share/zoneinfo') or
|
||||
+ @unittest.skipUnless(os.path.exists('/system/data/zoneinfo') or
|
||||
+ os.path.exists('/usr/share/zoneinfo') or
|
||||
os.path.exists('/usr/lib/zoneinfo'),
|
||||
"Can't find the Olson's TZ database")
|
||||
@test.support.run_with_tz('Europe/Kiev')
|
||||
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
|
||||
index ebfcffd..0517b87 100644
|
||||
--- a/Lib/test/test_fileio.py
|
||||
+++ b/Lib/test/test_fileio.py
|
||||
@@ -391,6 +391,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)
|
||||
--
|
||||
2.42.0
|
||||
|
||||
|
||||
From b12c15d58f31c69459b41bf652e9f271e0a1604f Mon Sep 17 00:00:00 2001
|
||||
From: Oscar Lesta <oscar.lesta@gmail.com>
|
||||
Date: Sun, 8 Oct 2023 17:02:19 -0300
|
||||
Subject: Use spawn instead of fork for multiprocessing.
|
||||
|
||||
Without this change, we get:
|
||||
|
||||
```
|
||||
Fatal Python error: PyOS_AfterFork_Child:
|
||||
the function must be called with the GIL held, after Python initialization
|
||||
and before Python finalization, but the GIL is released (the current Python
|
||||
thread state is NULL)
|
||||
```
|
||||
|
||||
when running "test_re.py" (as part of the "--with-optimizations" build) without
|
||||
using spawn instead of fork in multiprocessing/context.py.
|
||||
|
||||
and also:
|
||||
|
||||
```
|
||||
Traceback (most recent call last):
|
||||
File "<string>", line 1, in <module>
|
||||
File "/sources/Python-3.12.0/Lib/multiprocessing/forkserver.py", line 202, in main
|
||||
signal.set_wakeup_fd(sig_w)
|
||||
ValueError: the fd 6 must be in non-blocking mode
|
||||
```
|
||||
|
||||
when running the "compileall" step of "make install".
|
||||
|
||||
From:
|
||||
https://docs.python.org/3.12/library/multiprocessing.html#contexts-and-start-methods
|
||||
|
||||
"The default start method will change away from fork in Python 3.14."
|
||||
|
||||
So, we might be in the clear switching to "spawn" now.
|
||||
|
||||
diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py
|
||||
index de8a264..02a301e 100644
|
||||
--- a/Lib/multiprocessing/context.py
|
||||
+++ b/Lib/multiprocessing/context.py
|
||||
@@ -320,7 +320,7 @@ if sys.platform != 'win32':
|
||||
'spawn': SpawnContext(),
|
||||
'forkserver': ForkServerContext(),
|
||||
}
|
||||
- if sys.platform == 'darwin':
|
||||
+ if sys.platform == 'darwin' or sys.platform[:5] == 'haiku':
|
||||
# bpo-33725: running arbitrary code after fork() is no longer reliable
|
||||
# on macOS since macOS 10.14 (Mojave). Use spawn by default instead.
|
||||
_default_context = DefaultContext(_concrete_contexts['spawn'])
|
||||
--
|
||||
2.42.0
|
||||
|
||||
Reference in New Issue
Block a user