python: bump versions.

This commit is contained in:
Jerome Duval
2019-10-24 11:28:24 +02:00
parent 26539ec2f2
commit c7fcfd657c
6 changed files with 5 additions and 5 deletions

View File

@@ -0,0 +1,683 @@
From 86342bd79fd31f85bfb8df30d0b8bf1cc66cbd75 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 10 Apr 2014 16:03:33 +0000
Subject: initial Haiku patch
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index 0258d3d..aaec6e6 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -43,6 +43,27 @@ INSTALL_SCHEMES = {
'data' : '$base',
},
'nt': WINDOWS_SCHEME,
+ 'haiku': {
+ 'purelib': '$base/non-packaged/lib/python$py_version_short/site-packages',
+ 'platlib': '$platbase/non-packaged/lib/python$py_version_short/site-packages',
+ 'headers': '$base/non-packaged/develop/headers/python$py_version_short/$dist_name',
+ 'scripts': '$base/non-packaged/bin',
+ 'data' : '$base/non-packaged',
+ },
+ 'haiku_vendor': {
+ 'purelib': '$base/lib/python$py_version_short/vendor-packages',
+ 'platlib': '$platbase/lib/python$py_version_short/vendor-packages',
+ 'headers': '$base/develop/headers/python$py_version_short/$dist_name',
+ 'scripts': '$base/bin',
+ 'data' : '$base',
+ },
+ 'haiku_home': {
+ 'purelib': '$base/lib/python',
+ 'platlib': '$base/lib/python',
+ 'headers': '$base/develop/headers/python/$dist_name',
+ 'scripts': '$base/bin',
+ 'data' : '$base',
+ },
}
# user site schemes
@@ -64,6 +85,14 @@ if HAS_USER_SITE:
'data' : '$userbase',
}
+ INSTALL_SCHEMES['haiku_user'] = {
+ 'purelib': '$usersite',
+ 'platlib': '$usersite',
+ 'headers': '$userbase/develop/headers/python$py_version_short/$dist_name',
+ 'scripts': '$userbase/bin',
+ 'data' : '$userbase',
+ }
+
# The keys to an installation scheme; if any new types of files are to be
# installed, be sure to add an entry to every installation scheme above,
# and to SCHEME_KEYS here.
@@ -408,10 +437,16 @@ class install(Command):
raise DistutilsPlatformError(
"User base directory is not specified")
self.install_base = self.install_platbase = self.install_userbase
- self.select_scheme("unix_user")
+ if sys.platform.startswith('haiku'):
+ self.select_scheme("haiku_user")
+ else:
+ self.select_scheme("unix_user")
elif self.home is not None:
self.install_base = self.install_platbase = self.home
- self.select_scheme("unix_home")
+ if sys.platform.startswith('haiku'):
+ self.select_scheme("haiku_home")
+ else:
+ self.select_scheme("unix_home")
else:
if self.prefix is None:
if self.exec_prefix is not None:
@@ -427,7 +462,13 @@ class install(Command):
self.install_base = self.prefix
self.install_platbase = self.exec_prefix
- self.select_scheme("unix_prefix")
+ if sys.platform.startswith('haiku'):
+ if os.environ.get('HAIKU_USE_VENDOR_DIRECTORIES') == '1':
+ self.select_scheme("haiku_vendor")
+ else:
+ self.select_scheme("haiku")
+ else:
+ self.select_scheme("unix_prefix")
def finalize_other(self):
"""Finalizes options for non-posix platforms"""
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 2bcd1dd..8d8ff39 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -99,7 +99,8 @@ def get_python_inc(plat_specific=0, prefix=None):
incdir = os.path.join(get_config_var('srcdir'), 'Include')
return os.path.normpath(incdir)
python_dir = 'python' + get_python_version() + build_flags
- return os.path.join(prefix, "include", python_dir)
+ inc_dir = "include" if sys.platform != "haiku1" else "develop/headers"
+ return os.path.join(prefix, inc_dir, python_dir)
elif os.name == "nt":
return os.path.join(prefix, "include")
else:
@@ -129,12 +130,20 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
prefix = plat_specific and EXEC_PREFIX or PREFIX
if os.name == "posix":
- libpython = os.path.join(prefix,
- "lib", "python" + get_python_version())
- if standard_lib:
- return libpython
+ if sys.platform.startswith('haiku'):
+ if standard_lib:
+ return os.path.join(prefix,
+ "lib", "python" + get_python_version())
+ return os.path.join(prefix, "non-packaged",
+ "lib", "python" + get_python_version(),
+ "site-packages")
else:
- return os.path.join(libpython, "site-packages")
+ libpython = os.path.join(prefix,
+ "lib", "python" + get_python_version())
+ if standard_lib:
+ return libpython
+ else:
+ return os.path.join(libpython, "site-packages")
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 86ca2db..368d90e 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -303,7 +303,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" + sys.version[:3],
+ "site-packages"))
+ sitepackages.append(os.path.join(prefix, "lib",
+ "python" + sys.version[:3],
+ "vendor-packages"))
+ elif os.sep == '/':
sitepackages.append(os.path.join(prefix, "lib",
"python%d.%d" % sys.version_info[:2],
"site-packages"))
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 57a0265..ea316a7 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -384,6 +384,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 d912a19..4829a67 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -132,7 +132,7 @@ BINDIR= @bindir@
LIBDIR= @libdir@
MANDIR= @mandir@
INCLUDEDIR= @includedir@
-CONFINCLUDEDIR= $(exec_prefix)/include
+CONFINCLUDEDIR= $(INCLUDEDIR)
SCRIPTDIR= $(prefix)/lib
ABIFLAGS= @ABIFLAGS@
diff --git a/Modules/resource.c b/Modules/resource.c
index 113ad5c..b9de0ab 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -83,6 +83,7 @@ resource_getrusage(PyObject *self, PyObject *args)
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));
@@ -97,7 +98,22 @@ resource_getrusage(PyObject *self, PyObject *args)
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;
@@ -330,19 +346,19 @@ PyInit_resource(void)
(PyObject*) &StructRUsageType);
/* insert constants */
-#ifdef RLIMIT_CPU
+#if !defined(__HAIKU__) && defined(RLIMIT_CPU)
PyModule_AddIntMacro(m, RLIMIT_CPU);
#endif
-#ifdef RLIMIT_FSIZE
+#if !defined(__HAIKU__) && defined(RLIMIT_FSIZE)
PyModule_AddIntMacro(m, RLIMIT_FSIZE);
#endif
-#ifdef RLIMIT_DATA
+#if !defined(__HAIKU__) && defined(RLIMIT_DATA)
PyModule_AddIntMacro(m, RLIMIT_DATA);
#endif
-#ifdef RLIMIT_STACK
+#if !defined(__HAIKU__) && defined(RLIMIT_STACK)
PyModule_AddIntMacro(m, RLIMIT_STACK);
#endif
@@ -354,31 +370,31 @@ PyInit_resource(void)
PyModule_AddIntMacro(m, RLIMIT_NOFILE);
#endif
-#ifdef RLIMIT_OFILE
+#if !defined(__HAIKU__) && defined(RLIMIT_OFILE)
PyModule_AddIntMacro(m, RLIMIT_OFILE);
#endif
-#ifdef RLIMIT_VMEM
+#if !defined(__HAIKU__) && defined(RLIMIT_VMEM)
PyModule_AddIntMacro(m, RLIMIT_VMEM);
#endif
-#ifdef RLIMIT_AS
+#if !defined(__HAIKU__) && defined(RLIMIT_AS)
PyModule_AddIntMacro(m, RLIMIT_AS);
#endif
-#ifdef RLIMIT_RSS
+#if !defined(__HAIKU__) && defined(RLIMIT_RSS)
PyModule_AddIntMacro(m, RLIMIT_RSS);
#endif
-#ifdef RLIMIT_NPROC
+#if !defined(__HAIKU__) && defined(RLIMIT_NPROC)
PyModule_AddIntMacro(m, RLIMIT_NPROC);
#endif
-#ifdef RLIMIT_MEMLOCK
+#if !defined(__HAIKU__) && defined(RLIMIT_MEMLOCK)
PyModule_AddIntMacro(m, RLIMIT_MEMLOCK);
#endif
-#ifdef RLIMIT_SBSIZE
+#if !defined(__HAIKU__) && defined(RLIMIT_SBSIZE)
PyModule_AddIntMacro(m, RLIMIT_SBSIZE);
#endif
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index ed31667..e1c163e 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -6903,7 +6903,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 af7c36a..ca5a873 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -54,6 +54,10 @@ typedef int socklen_t;
# undef AF_NETLINK
#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 1601ec0..a4211be 100644
--- a/Modules/spwdmodule.c
+++ b/Modules/spwdmodule.c
@@ -87,7 +87,9 @@ static PyObject *mkspent(struct spwd *p)
SETS(setIndex++, p->sp_namp);
SETS(setIndex++, p->sp_pwdp);
+#ifndef __HAIKU__
SETI(setIndex++, p->sp_lstchg);
+#endif
SETI(setIndex++, p->sp_min);
SETI(setIndex++, p->sp_max);
SETI(setIndex++, p->sp_warn);
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index d7b0bbd..ee9bebc 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -21,7 +21,7 @@
Don't forget to modify PyUnicode_DecodeFSDefault() if you touch any of the
values for Py_FileSystemDefaultEncoding!
*/
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__HAIKU__)
const char *Py_FileSystemDefaultEncoding = "utf-8";
int Py_HasFileSystemDefaultEncoding = 1;
#elif defined(MS_WINDOWS)
diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py
index 4363c0c..40994b0 100755
--- a/Tools/scripts/h2py.py
+++ b/Tools/scripts/h2py.py
@@ -49,12 +49,15 @@ except KeyError:
try:
searchdirs=os.environ['INCLUDE'].split(';')
except KeyError:
- searchdirs=['/usr/include']
- try:
- searchdirs.insert(0, os.path.join('/usr/include',
+ if sys.platform.find("beos") == 0 or sys.platform.find("haiku1") == 0:
+ searchdirs=os.environ['BEINCLUDES'].split(';')
+ else:
+ searchdirs=['/usr/include']
+ try:
+ searchdirs.insert(0, os.path.join('/usr/include',
os.environ['MULTIARCH']))
- except KeyError:
- pass
+ except KeyError:
+ pass
def main():
global filedict
diff --git a/configure.ac b/configure.ac
index 3f2459a..62bc0c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1157,6 +1157,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)
@@ -1233,6 +1243,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
@@ -2560,7 +2571,7 @@ then
BLDSHARED="$LDSHARED"
fi
;;
- Linux*|GNU*|QNX*)
+ Linux*|GNU*|QNX*|Haiku*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
BSD/OS*/4*)
@@ -2630,7 +2641,7 @@ then
else CCSHARED="+z";
fi;;
Linux-android*) ;;
- Linux*|GNU*) CCSHARED="-fPIC";;
+ Linux*|GNU*|Haiku*) CCSHARED="-fPIC";;
BSD/OS*/4*) CCSHARED="-fpic";;
FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
OpenUNIX*|UnixWare*)
@@ -2662,7 +2673,7 @@ then
# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
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"
@@ -2843,6 +2854,12 @@ LDFLAGS="-fsanitize=address $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]),
@@ -4253,6 +4270,7 @@ fi],
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 49193f6..6aca04b 100644
--- a/setup.py
+++ b/setup.py
@@ -505,8 +505,8 @@ class PyBuildExt(build_ext):
os.unlink(tmpfile)
def detect_math_libs(self):
- # Check for MacOS X, which doesn't need libm.a at all
- if host_platform == 'darwin':
+ # Check for MacOS X and Haiku, which doesn't need libm.a at all
+ if host_platform in ['darwin','haiku1']:
return []
else:
return ['m']
@@ -594,6 +594,12 @@ class PyBuildExt(build_ext):
config_h_vars = sysconfig.parse_config_h(file)
srcdir = sysconfig.get_config_var('srcdir')
+
+ # Haiku-specific library locations
+ if host_platform == 'haiku1':
+ inc_dirs += ['/boot/develop/headers/posix',
+ '/boot/system/develop/headers']
+ 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']:
@@ -845,15 +851,22 @@ class PyBuildExt(build_ext):
'/usr/local/ssl/include',
'/usr/contrib/ssl/include/'
]
- ssl_incs = find_file('openssl/ssl.h', inc_dirs,
+ ssl_incs = find_file('openssl/ssl.h', [],
+ inc_dirs + search_for_ssl_incs_in
+ )
+ ssl_incs_to_add = find_file('openssl/ssl.h', inc_dirs,
search_for_ssl_incs_in
)
if ssl_incs is not None:
krb5_h = find_file('krb5.h', inc_dirs,
['/usr/kerberos/include'])
if krb5_h:
- ssl_incs += krb5_h
- ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
+ ssl_incs_to_add += krb5_h
+ ssl_libs = find_library_file(self.compiler, 'ssl', [],
+ lib_dirs + ['/usr/local/ssl/lib',
+ '/usr/contrib/ssl/lib/'
+ ] )
+ ssl_libs_to_add = find_library_file(self.compiler, 'ssl', lib_dirs,
['/usr/local/ssl/lib',
'/usr/contrib/ssl/lib/'
] )
@@ -861,8 +874,8 @@ class PyBuildExt(build_ext):
if (ssl_incs is not None and
ssl_libs is not None):
exts.append( Extension('_ssl', ['_ssl.c'],
- include_dirs = ssl_incs,
- library_dirs = ssl_libs,
+ include_dirs = ssl_incs_to_add,
+ library_dirs = ssl_libs_to_add,
libraries = ['ssl', 'crypto'],
depends = ['socketmodule.h']), )
else:
@@ -902,8 +915,8 @@ class PyBuildExt(build_ext):
# of hash functions from the OpenSSL library.
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
depends = ['hashlib.h'],
- include_dirs = ssl_incs,
- library_dirs = ssl_libs,
+ include_dirs = ssl_incs_to_add,
+ library_dirs = ssl_libs_to_add,
libraries = ['ssl', 'crypto']) )
else:
print("warning: openssl 0x%08x is too old for _hashlib" %
@@ -2217,7 +2230,7 @@ class PyBuildExt(build_ext):
return ext
def _detect_nis(self, inc_dirs, lib_dirs):
- if host_platform in {'win32', 'cygwin', 'qnx6'}:
+ if host_platform in {'win32', 'cygwin', 'qnx6', 'haiku1'}:
return None
libs = []
--
2.19.1
From d9e7a5386b6668d9bf46b1ade6356322ea11fa41 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 290ae44..95ec9d3 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1330,6 +1330,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 fe0e554..d2a0d52 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -527,6 +527,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.19.1
From f9408c3d0f3242fa21cb06278ded8b684eafd805 Mon Sep 17 00:00:00 2001
From: Philippe Houdoin <philippe.houdoin@gmail.com>
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 339ae8a..d537963 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -243,6 +243,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):
@@ -328,6 +378,12 @@ def test():
print(cdll.LoadLibrary("libcrypto.dylib"))
print(cdll.LoadLibrary("libSystem.dylib"))
print(cdll.LoadLibrary("System.framework/System"))
+ 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.19.1
From 4e03cd18f7d7305f8c3adb4e308f68af1959d5db Mon Sep 17 00:00:00 2001
From: Philipp Wolfer <phil@parolu.io>
Date: Mon, 23 Sep 2019 09:53:39 +0200
Subject: [PATCH] webbrowser: Support for default browsers on Haiku
---
Lib/webbrowser.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 1a553f0e65..074898b62d 100755
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -614,6 +614,16 @@ if sys.platform == 'darwin':
register("chrome", None, MacOSXOSAScript('chrome'), -1)
register("MacOSX", None, MacOSXOSAScript('default'), -1)
+#
+# Platform support for Haiku
+#
+
+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"))
+
# OK, now that we know what the default preference orders for each
# platform are, allow user to override them with the BROWSER variable.
--
2.23.0