ports: Add python3 port

This commit is contained in:
Bananymous 2025-07-22 13:54:18 +03:00
parent e2eb555ca0
commit 05affda20c
8 changed files with 189 additions and 0 deletions

25
ports/python3/build.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash ../install.sh
NAME='python'
VERSION='3.13.3'
DOWNLOAD_URL="https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz#40f868bcbdeb8149a3149580bb9bfd407b3321cd48f0be631af955ac92c0e041"
TAR_CONTENT="Python-$VERSION"
DEPENDENCIES=('ncurses' 'zlib' 'openssl')
CONFIG_SUB=('config.sub')
CONFIGURE_OPTIONS=(
"--build=$(uname -m)-pc-linux-gnu"
"--with-build-python=python3.13"
'--without-ensurepip'
'--disable-ipv6'
'--disable-test-modules'
'--enable-shared'
'ac_cv_file__dev_ptmx=no'
'ac_cv_file__dev_ptc=no'
)
pre_configure() {
if ! command -v python3.13 &>/dev/null ; then
echo "You need to have python3.13 installed on your host machine" >&2
exit 1
fi
}

View File

@ -0,0 +1,60 @@
diff -ruN Python-3.13.3/configure Python-3.13.3-banan_os/configure
--- Python-3.13.3/configure 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/configure 2025-04-19 04:25:20.860260051 +0300
@@ -4052,6 +4052,9 @@
*-*-linux*)
ac_sys_system=Linux
;;
+ *-*-banan_os*)
+ ac_sys_system=banan_os
+ ;;
*-*-cygwin*)
ac_sys_system=Cygwin
;;
@@ -4500,6 +4503,9 @@
_host_ident=$host_cpu
esac
;;
+ *-*-banan_os*)
+ _host_ident=$host_cpu
+ ;;
*-*-cygwin*)
_host_ident=
;;
@@ -7603,6 +7609,11 @@
PY3LIBRARY=libpython3.so
fi
;;
+ banan_os*)
+ LDLIBRARY='libpython$(LDVERSION).so'
+ BLDLIBRARY='-L. -lpython$(LDVERSION)'
+ RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
+ ;;
hp*|HP*)
case `uname -m` in
ia64)
@@ -12983,7 +12994,7 @@
Emscripten*|WASI*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
- Linux*|GNU*|QNX*|VxWorks*|Haiku*)
+ Linux*|GNU*|QNX*|VxWorks*|Haiku*|banan_os*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
FreeBSD*)
@@ -13069,6 +13080,7 @@
else CCSHARED="+z";
fi;;
Linux*|GNU*) CCSHARED="-fPIC";;
+ banan_os*) CCSHARED="-fPIC";;
Emscripten*|WASI*)
if test "x$enable_wasm_dynamic_linking" = xyes
then :
@@ -23609,6 +23621,7 @@
case $ac_sys_system in
Darwin) ;;
+banan_os) ;;
*) LIBM=-lm
esac
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-libm=STRING" >&5

View File

@ -0,0 +1,19 @@
diff -ruN Python-3.13.3/Objects/mimalloc/prim/unix/prim.c Python-3.13.3-banan_os/Objects/mimalloc/prim/unix/prim.c
--- Python-3.13.3/Objects/mimalloc/prim/unix/prim.c 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/Objects/mimalloc/prim/unix/prim.c 2025-04-19 02:14:12.417811656 +0300
@@ -608,10 +608,13 @@
getrusage(RUSAGE_SELF, &rusage);
pinfo->utime = timeval_secs(&rusage.ru_utime);
pinfo->stime = timeval_secs(&rusage.ru_stime);
-#if !defined(__HAIKU__)
+#if !defined(__HAIKU__) && !defined(__banan_os__)
pinfo->page_faults = rusage.ru_majflt;
#endif
-#if defined(__HAIKU__)
+#if defined(__banan_os__)
+ pinfo->page_faults = 0;
+ pinfo->peak_rss = 0;
+#elif defined(__HAIKU__)
// Haiku does not have (yet?) a way to
// get these stats per process
thread_info tid;

View File

@ -0,0 +1,13 @@
diff -ruN Python-3.13.3/Include/internal/pycore_time.h Python-3.13.3-banan_os/Include/internal/pycore_time.h
--- Python-3.13.3/Include/internal/pycore_time.h 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/Include/internal/pycore_time.h 2025-04-19 02:27:02.327447295 +0300
@@ -58,9 +58,7 @@
#endif
-#ifdef __clang__
struct timeval;
-#endif
#define _SIZEOF_PYTIME_T 8

View File

@ -0,0 +1,19 @@
diff -ruN Python-3.13.3/Modules/resource.c Python-3.13.3-banan_os/Modules/resource.c
--- Python-3.13.3/Modules/resource.c 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/Modules/resource.c 2025-04-19 02:36:06.945810525 +0300
@@ -126,6 +126,7 @@
PyFloat_FromDouble(doubletime(ru.ru_utime)));
PyStructSequence_SetItem(result, 1,
PyFloat_FromDouble(doubletime(ru.ru_stime)));
+#if !defined(__banan_os__)
PyStructSequence_SetItem(result, 2, PyLong_FromLong(ru.ru_maxrss));
PyStructSequence_SetItem(result, 3, PyLong_FromLong(ru.ru_ixrss));
PyStructSequence_SetItem(result, 4, PyLong_FromLong(ru.ru_idrss));
@@ -140,6 +141,7 @@
PyStructSequence_SetItem(result, 13, PyLong_FromLong(ru.ru_nsignals));
PyStructSequence_SetItem(result, 14, PyLong_FromLong(ru.ru_nvcsw));
PyStructSequence_SetItem(result, 15, PyLong_FromLong(ru.ru_nivcsw));
+#endif
if (PyErr_Occurred()) {
Py_DECREF(result);

View File

@ -0,0 +1,17 @@
diff -ruN Python-3.13.3/Modules/grpmodule.c Python-3.13.3-banan_os/Modules/grpmodule.c
--- Python-3.13.3/Modules/grpmodule.c 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/Modules/grpmodule.c 2025-04-19 02:40:57.658713753 +0300
@@ -91,9 +91,12 @@
#define SET(i,val) PyStructSequence_SetItem(v, i, val)
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_name));
+#if !defined(__banan_os__)
if (p->gr_passwd)
SET(setIndex++, PyUnicode_DecodeFSDefault(p->gr_passwd));
- else {
+ else
+#endif
+ {
SET(setIndex++, Py_None);
Py_INCREF(Py_None);
}

View File

@ -0,0 +1,14 @@
diff -ruN Python-3.13.3/Modules/selectmodule.c Python-3.13.3-banan_os/Modules/selectmodule.c
--- Python-3.13.3/Modules/selectmodule.c 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/Modules/selectmodule.c 2025-04-19 02:55:44.944860340 +0300
@@ -54,6 +54,10 @@
#include <sys/poll.h>
#endif
+#if defined(__banan_os__)
+#include <sys/select.h>
+#endif
+
#ifdef __sgi
/* This is missing from unistd.h */
extern void bzero(void *, int);

View File

@ -0,0 +1,22 @@
diff -ruN Python-3.13.3/Modules/socketmodule.c Python-3.13.3-banan_os/Modules/socketmodule.c
--- Python-3.13.3/Modules/socketmodule.c 2025-04-08 16:54:08.000000000 +0300
+++ Python-3.13.3-banan_os/Modules/socketmodule.c 2025-04-19 03:09:49.117436782 +0300
@@ -1676,10 +1676,17 @@
default:
/* If we don't know the address family, don't raise an
exception -- return it as an (int, bytes) tuple. */
+#if defined(__banan_os__)
return Py_BuildValue("iy#",
addr->sa_family,
addr->sa_data,
- sizeof(addr->sa_data));
+ sizeof(((struct sockaddr_storage){}).ss_storage));
+#else
+ return Py_BuildValue("iy#",
+ addr->sa_family,
+ addr->sa_data,
+ sizeof(addr->sa_data));
+#endif
}
}