diff --git a/dev-lang/python/patches/python3.11-3.11.8.patchset b/dev-lang/python/patches/python3.11-3.11.9.patchset similarity index 76% rename from dev-lang/python/patches/python3.11-3.11.8.patchset rename to dev-lang/python/patches/python3.11-3.11.9.patchset index 9afc57d3d..1fb16a907 100644 --- a/dev-lang/python/patches/python3.11-3.11.8.patchset +++ b/dev-lang/python/patches/python3.11-3.11.9.patchset @@ -1,8 +1,18 @@ -From 2f00459cfa8328da1ffc7767a464f91dea7b26f7 Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Thu, 10 Apr 2014 16:03:33 +0000 -Subject: initial Haiku patch +From ecb481e2420b80e832c041b4acf6bb2205808df7 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 b3b8b6f..40d8c2d 100644 @@ -17,130 +27,6 @@ index b3b8b6f..40d8c2d 100644 // Use UTF-8 as the filesystem encoding. // See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(), // Py_DecodeLocale() and Py_EncodeLocale(). -diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py -index 01d5331..b109392 100644 ---- a/Lib/distutils/command/install.py -+++ b/Lib/distutils/command/install.py -@@ -33,13 +33,15 @@ SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') - # alter locations for packages installations in a single place. - # Note that this module is deprecated (PEP 632); all consumers - # of this information should switch to using sysconfig directly. --INSTALL_SCHEMES = {"unix_prefix": {}, "unix_home": {}, "nt": {}} -+INSTALL_SCHEMES = {"unix_prefix": {}, "unix_home": {}, "nt": {}, -+ "haiku": {}, "haiku_vendor": {}, "haiku_home": {}} - - # Copy from sysconfig._INSTALL_SCHEMES - for key in SCHEME_KEYS: - for distutils_scheme_name, sys_scheme_name in ( - ("unix_prefix", "posix_prefix"), ("unix_home", "posix_home"), -- ("nt", "nt")): -+ ("nt", "nt"), ("haiku", "haiku"), ("haiku_vendor", "haiku_vendor"), -+ ("haiku_home", "haiku_home")): - sys_key = key - sys_scheme = sysconfig._INSTALL_SCHEMES[sys_scheme_name] - if key == "headers" and key not in sys_scheme: -@@ -86,6 +88,13 @@ 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', -+ } - - class install(Command): - -@@ -431,10 +440,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: -@@ -450,7 +465,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 03b8558..a7253b6 100644 ---- a/Lib/distutils/sysconfig.py -+++ b/Lib/distutils/sysconfig.py -@@ -287,7 +287,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": - if python_build: - # Include both the include and PC dir to ensure we can find -@@ -322,19 +323,27 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): - prefix = plat_specific and EXEC_PREFIX or PREFIX - - if os.name == "posix": -- if plat_specific or standard_lib: -- # Platform-specific modules (any module from a non-pure-Python -- # module distribution) or standard Python library modules. -- libdir = sys.platlibdir -+ 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: -- # Pure Python -- libdir = "lib" -- libpython = os.path.join(prefix, libdir, -- "python" + get_python_version()) -- if standard_lib: -- return libpython -- else: -- return os.path.join(libpython, "site-packages") -+ if plat_specific or standard_lib: -+ # Platform-specific modules (any module from a non-pure-Python -+ # module distribution) or standard Python library modules. -+ libdir = sys.platlibdir -+ -+ # Pure Python -+ libdir = "lib" -+ libpython = os.path.join(prefix, libdir, -+ "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 @@ -151,74 +37,8 @@ index 0000000..4372ee2 +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 2904e44..8face24 100644 ---- a/Lib/site.py -+++ b/Lib/site.py -@@ -291,6 +291,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") - - -@@ -371,7 +379,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") -@@ -480,8 +495,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 5cc3d4b..6f53287 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) diff --git a/Makefile.pre.in b/Makefile.pre.in -index 4d1921b..bf222f6 100644 +index 81d4d50..7f990cc 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -146,7 +146,7 @@ BINDIR= @bindir@ @@ -369,21 +189,100 @@ index 42123c9..60de40a 100644 PyErr_SetFromErrno(PyExc_OSError); else PyErr_SetString(PyExc_KeyError, "getspnam(): name not found"); +diff --git a/configure.ac b/configure.ac +index 7b4000f..0bb76a1 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1503,6 +1503,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) +@@ -1659,6 +1669,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 +@@ -3264,7 +3275,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" +@@ -3297,7 +3308,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" +@@ -5353,6 +5364,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 ad8fb81..07fd69f 100644 +--- a/setup.py ++++ b/setup.py +@@ -84,6 +84,7 @@ CYGWIN = (HOST_PLATFORM == 'cygwin') + MACOS = (HOST_PLATFORM == 'darwin') + AIX = (HOST_PLATFORM.startswith('aix')) + VXWORKS = ('vxworks' in HOST_PLATFORM) ++HAIKU = (HOST_PLATFORM == 'haiku1') + EMSCRIPTEN = HOST_PLATFORM == 'emscripten-wasm32' + CC = os.environ.get("CC") + if not CC: +@@ -891,6 +892,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'] -- -2.42.1 +2.45.2 -From 9658e361a9cd24dac0c6ee7fc042c9015c8b8b60 Mon Sep 17 00:00:00 2001 +From 22a06664be95c9ecfa7ac25e18e3279e80b2670b 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 3264d9a..829477d 100644 +index 1d17ae3..4461393 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py -@@ -1938,6 +1938,8 @@ class Popen: +@@ -1940,6 +1940,8 @@ class Popen: SubprocessError) if issubclass(child_exception_type, OSError) and hex_errno: errno_num = int(hex_errno, 16) @@ -408,10 +307,10 @@ index d91bf21..cb6c6a2 100644 *--cur = Py_hexdigits[saved_errno % 16]; saved_errno /= 16; -- -2.42.1 +2.45.2 -From ca76437963d002d811e83bb43012c0d5a8a665b7 Mon Sep 17 00:00:00 2001 +From 743c5e7963b4c727ace98177f0f9d44f38245f5e Mon Sep 17 00:00:00 2001 From: Oscar Lesta Date: Sun, 8 Oct 2023 20:06:31 -0300 Subject: Implement CTypes's find_library for Haiku @@ -505,10 +404,10 @@ index c550883..6b23423 100644 print(cdll.LoadLibrary("libm.so")) print(cdll.LoadLibrary("libcrypt.so")) -- -2.42.1 +2.45.2 -From 853be77903433468b699b96170140a7f622d4af8 Mon Sep 17 00:00:00 2001 +From c65144ec38d29d519f74f46fb1c976252cead1a6 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 @@ -531,17 +430,17 @@ index 5d72524..eb0879f 100755 # Prefer X browsers if present if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"): -- -2.42.1 +2.45.2 -From 98361e94e8a22d4e287ba44834bf2ef8d778fe88 Mon Sep 17 00:00:00 2001 +From bd63e313776575f5265a43aae21245f8d3ae1745 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 bcee2ba..46630a4 100644 +index e364419..86f0bcc 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -244,7 +244,7 @@ def _releaseLock(): @@ -554,10 +453,10 @@ index bcee2ba..46630a4 100644 pass # no-op when os.register_at_fork does not exist. else: -- -2.42.1 +2.45.2 -From 2b6afd77361526bcfbd9d981950e29b7906cc8fb Mon Sep 17 00:00:00 2001 +From 509cee2e4c6582c460a57c17f875c6080b17c41d 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() @@ -587,17 +486,17 @@ index f0c9b46..dd9b7da 100644 return PyLong_FromLong((long) res); -- -2.42.1 +2.45.2 -From 30975e468052299321f077b82b3edd524f70db08 Mon Sep 17 00:00:00 2001 +From c57dfbdb4901d05998340609497443b5b480b7d4 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 e70fef5..df55963 100644 +index 6114f61..d025417 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3113,11 +3113,14 @@ static PyObject * @@ -617,157 +516,50 @@ index e70fef5..df55963 100644 if (buffer == NULL) { return PyErr_NoMemory(); -- -2.42.1 +2.45.2 -From 18c302be98981320722703994ec5969906b5fd1c Mon Sep 17 00:00:00 2001 +From 36cce929d8c9202e86efdebc80293f85c1f22bbf Mon Sep 17 00:00:00 2001 From: Oscar Lesta -Date: Wed, 5 Oct 2022 16:09:41 -0300 -Subject: The rest of korli's "initial Haiku patch". +Date: Thu, 25 Jul 2024 17:27:04 -0300 +Subject: Miscellaneous "Lib/test/" fixes for Haiku. -Parts of that original patch did not applied cleanly anymore. -Manually massaged them for 3.11.0rc2. +This combines test_fileio.py changes from the "initial Haiku patch", plus... -diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index ebe3711..63e2742 100644 ---- a/Lib/sysconfig.py -+++ b/Lib/sysconfig.py -@@ -56,6 +56,27 @@ _INSTALL_SCHEMES = { - 'scripts': '{base}/Scripts', - 'data': '{base}', - }, -+ '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}', -+ '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}', -+ 'scripts': '{base}/bin', -+ 'data' : '{base}', -+ }, -+ 'haiku_home': { -+ 'purelib': '{base}/lib/python', -+ 'platlib': '{base}/lib/python', -+ 'headers': '{base}/develop/headers/python/', -+ 'scripts': '{base}/bin', -+ 'data' : '{base}', -+ }, - # Downstream distributors can overwrite the default install scheme. - # This is done to support downstream modifications where distributors change - # the installation layout (eg. different site-packages directory). -diff --git a/configure.ac b/configure.ac -index bbe7f89..a42040f 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1503,6 +1503,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) -@@ -1659,6 +1669,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 -@@ -3264,7 +3275,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" -@@ -3297,7 +3308,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" -@@ -5353,6 +5364,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 ad8fb81..07fd69f 100644 ---- a/setup.py -+++ b/setup.py -@@ -84,6 +84,7 @@ CYGWIN = (HOST_PLATFORM == 'cygwin') - MACOS = (HOST_PLATFORM == 'darwin') - AIX = (HOST_PLATFORM.startswith('aix')) - VXWORKS = ('vxworks' in HOST_PLATFORM) -+HAIKU = (HOST_PLATFORM == 'haiku1') - EMSCRIPTEN = HOST_PLATFORM == 'emscripten-wasm32' - CC = os.environ.get("CC") - if not CC: -@@ -891,6 +892,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'] --- -2.42.1 +"Lib/test: require the "largefile" usage flag for I/O heavy tests.": - -From 7ef67128bb5adca7ade61158660cd0c0c0a15bda Mon Sep 17 00:00:00 2001 -From: Oscar Lesta -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. +The same was done for Windows and MacOSX already. This avoids needing several GBs of storage to run the tests -(unless the "largefile" resource usage flag is enabled). +(unless they "largefile" resource usage flag is enabled). +diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py +index 5cc3d4b..6f53287 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) diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py -index 3dae789..1258c67 100644 +index 537c9fa..7d98e05 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py -@@ -613,7 +613,7 @@ class IOTest(unittest.TestCase): +@@ -634,7 +634,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': ++ 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..c21f001 100644 +index 3b0930f..c793ea1 100644 --- a/Lib/test/test_largefile.py +++ b/Lib/test/test_largefile.py @@ -255,7 +255,7 @@ def setUpModule(): @@ -775,12 +567,12 @@ index 3b0930f..c21f001 100644 # 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': ++ 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 1867e8c..ab52b6a 100644 +index 1867e8c..e4fab02 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1009,7 +1009,7 @@ class LargeMmapTests(unittest.TestCase): @@ -788,69 +580,305 @@ index 1867e8c..ab52b6a 100644 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': ++ 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.1 +2.45.2 -From 6168fba742823ca3ee1d36cb6201abeb33db74ff Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Tue, 7 Mar 2023 18:29:29 +0100 -Subject: default schemes for Haiku +From 650a5127582c73c31d0a700bb3650079322b83f4 Mon Sep 17 00:00:00 2001 +From: Oscar Lesta +Date: Fri, 26 Jul 2024 19:18:56 -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 + +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'. +* Attempt to support the "venv" install scheme (untested). + +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 01d5331..b109392 100644 +--- a/Lib/distutils/command/install.py ++++ b/Lib/distutils/command/install.py +@@ -33,13 +33,15 @@ SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') + # alter locations for packages installations in a single place. + # Note that this module is deprecated (PEP 632); all consumers + # of this information should switch to using sysconfig directly. +-INSTALL_SCHEMES = {"unix_prefix": {}, "unix_home": {}, "nt": {}} ++INSTALL_SCHEMES = {"unix_prefix": {}, "unix_home": {}, "nt": {}, ++ "haiku": {}, "haiku_vendor": {}, "haiku_home": {}} + + # Copy from sysconfig._INSTALL_SCHEMES + for key in SCHEME_KEYS: + for distutils_scheme_name, sys_scheme_name in ( + ("unix_prefix", "posix_prefix"), ("unix_home", "posix_home"), +- ("nt", "nt")): ++ ("nt", "nt"), ("haiku", "haiku"), ("haiku_vendor", "haiku_vendor"), ++ ("haiku_home", "haiku_home")): + sys_key = key + sys_scheme = sysconfig._INSTALL_SCHEMES[sys_scheme_name] + if key == "headers" and key not in sys_scheme: +@@ -86,6 +88,13 @@ 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', ++ } + + class install(Command): + +@@ -431,10 +440,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: +@@ -450,7 +465,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 03b8558..a7253b6 100644 +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -287,7 +287,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": + if python_build: + # Include both the include and PC dir to ensure we can find +@@ -322,19 +323,27 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): + prefix = plat_specific and EXEC_PREFIX or PREFIX + + if os.name == "posix": +- if plat_specific or standard_lib: +- # Platform-specific modules (any module from a non-pure-Python +- # module distribution) or standard Python library modules. +- libdir = sys.platlibdir ++ 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: +- # Pure Python +- libdir = "lib" +- libpython = os.path.join(prefix, libdir, +- "python" + get_python_version()) +- if standard_lib: +- return libpython +- else: +- return os.path.join(libpython, "site-packages") ++ if plat_specific or standard_lib: ++ # Platform-specific modules (any module from a non-pure-Python ++ # module distribution) or standard Python library modules. ++ libdir = sys.platlibdir ++ ++ # Pure Python ++ libdir = "lib" ++ libpython = os.path.join(prefix, libdir, ++ "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/site.py b/Lib/site.py +index 2904e44..935a6ff 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -291,6 +291,14 @@ def _getuserbase(): + return joinuser("~", "Library", sys._framework, + "%d.%d" % sys.version_info[:2]) + ++ if sys.platform.startswith('haiku'): ++ try: ++ import subprocess ++ return subprocess.check_output( ++ ['finddir', 'B_USER_NONPACKAGED_DIRECTORY']).rstrip().decode('utf-8') ++ except: ++ pass ++ + return joinuser("~", ".local") + + +@@ -371,7 +379,31 @@ def getsitepackages(prefixes=None): + continue + seen.add(prefix) + +- if os.sep == '/': ++ if sys.platform.startswith('haiku'): ++ # Locations under /system/ ++ 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")) ++ ++ # 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%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 63e2742..6ba9d18 100644 +index ebe3711..3379435 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py -@@ -57,25 +57,32 @@ _INSTALL_SCHEMES = { +@@ -46,6 +46,36 @@ _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/lib/python{py_version_short}/site-packages', -- 'headers': '{base}/non-packaged/develop/headers/python{py_version_short}', -+ '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', -- 'headers': '{base}/develop/headers/python{py_version_short}', -+ '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', -- 'headers': '{base}/develop/headers/python/', -+ 'include': '{installed_base}/develop/headers/python', -+ 'platinclude': '{installed_base}/develop/headers/python', - 'scripts': '{base}/bin', -- 'data' : '{base}', ++ 'haiku': { ++ '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/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}/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': '{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}/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}', ++ }, + 'nt': { + 'stdlib': '{installed_base}/Lib', + 'platstdlib': '{base}/Lib', +@@ -85,6 +115,16 @@ _INSTALL_SCHEMES = { + 'scripts': '{base}/bin', + 'data': '{base}', }, - # Downstream distributors can overwrite the default install scheme. - # This is done to support downstream modifications where distributors change -@@ -172,6 +179,15 @@ if _HAS_USER_BASE: ++ 'haiku_venv': { ++ '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/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', ++ }, + 'nt_venv': { + 'stdlib': '{installed_base}/Lib', + 'platstdlib': '{base}/Lib', +@@ -100,6 +140,8 @@ _INSTALL_SCHEMES = { + # For the OS-native venv scheme, we essentially provide an alias: + if os.name == 'nt': + _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['nt_venv'] ++elif sys.platform.startswith('haiku'): ++ _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['haiku_venv'] + else: + _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv'] + +@@ -126,6 +168,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.check_output( ++ ['finddir', 'B_USER_NONPACKAGED_DIRECTORY']).rstrip().decode('utf-8') ++ except: ++ pass ++ + return joinuser("~", ".local") + + _HAS_USER_BASE = (_getuserbase() is not None) +@@ -151,6 +201,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}', ++ 'stdlib': '{userbase}/lib/python{py_version_short}', ++ 'platstdlib': '{userbase}/lib/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}', @@ -860,7 +888,7 @@ index 63e2742..6ba9d18 100644 'osx_framework_user': { 'stdlib': '{userbase}/lib/python', 'platstdlib': '{userbase}/lib/python', -@@ -298,6 +314,18 @@ def _expand_vars(scheme, vars): +@@ -277,6 +336,18 @@ def _expand_vars(scheme, vars): def _get_preferred_schemes(): @@ -879,40 +907,65 @@ index 63e2742..6ba9d18 100644 if os.name == 'nt': return { 'prefix': 'nt', +diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py +index d3bb0d2..7fb3a41 100644 +--- a/Lib/test/test_sysconfig.py ++++ b/Lib/test/test_sysconfig.py +@@ -345,9 +345,10 @@ class TestSysConfig(unittest.TestCase): + self.assertTrue(os.path.isfile(config_h), config_h) + + def test_get_scheme_names(self): +- wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv'] ++ wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv', 'haiku', ++ 'haiku_home', 'haiku_vendor'] + if HAS_USER_BASE: +- wanted.extend(['nt_user', 'osx_framework_user', 'posix_user']) ++ wanted.extend(['nt_user', 'osx_framework_user', 'posix_user', 'haiku_user']) + self.assertEqual(get_scheme_names(), tuple(sorted(wanted))) + + @skip_unless_symlink -- -2.42.1 +2.45.2 -From 136a1494cf17d93146990f04b5679abaeae9fb31 Mon Sep 17 00:00:00 2001 +From 7d9932e4293a4d6ec9390e19be0d49fdb85873ea Mon Sep 17 00:00:00 2001 From: Oscar Lesta -Date: Fri, 10 Mar 2023 20:15:14 -0300 -Subject: syncronize both _getuserbase() copies on site.py and sysconfig.py. +Date: Thu, 25 Jul 2024 17:27:28 -0300 +Subject: Fix location of REPL's history file. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Originally from "initial Haiku patch" by Jérôme Duval. -diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index 6ba9d18..c3e8dbc 100644 ---- a/Lib/sysconfig.py -+++ b/Lib/sysconfig.py -@@ -154,6 +154,14 @@ def _getuserbase(): - return joinuser("~", "Library", sys._framework, - f"{sys.version_info[0]}.{sys.version_info[1]}") - -+ if sys.platform.startswith('haiku'): -+ try: +diff --git a/Lib/site.py b/Lib/site.py +index 935a6ff..7e83f70 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -512,8 +512,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 -+ 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) ++ 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.42.1 +2.45.2 -From 5a9d80c3b931b0101523081a548fecfa64b8b0de Mon Sep 17 00:00:00 2001 +From ab832b12aef9538caeb421d404679c5c3f838b30 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. @@ -975,5 +1028,35 @@ index 8210269..5750d2c 100644 /* NETDEV filter flags */ -- -2.42.1 +2.45.2 + + +From 93c7ff25df708035b36739186ef01ad3fcf2aecc 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/python3.11-3.11.8.recipe b/dev-lang/python/python3.11-3.11.9.recipe similarity index 68% rename from dev-lang/python/python3.11-3.11.8.recipe rename to dev-lang/python/python3.11-3.11.9.recipe index 92e1e551d..95e1c0eda 100644 --- a/dev-lang/python/python3.11-3.11.8.recipe +++ b/dev-lang/python/python3.11-3.11.9.recipe @@ -10,10 +10,10 @@ 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" +COPYRIGHT="1990-2024 Python Software Foundation" REVISION="1" SOURCE_URI="https://www.python.org/ftp/python/$portVersion/Python-$portVersion.tar.xz" -CHECKSUM_SHA256="9e06008c8901924395bc1da303eac567a729ae012baa182ab39269f650383bb3" +CHECKSUM_SHA256="9b1e896523fc510691126c864406d9360a3d1e986acbda59cda57b5abda45b87" SOURCE_DIR="Python-$portVersion" pyShortVer="${portVersion%.*}" @@ -36,14 +36,34 @@ 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:idle$pyShortVer = $pyVersionCompat cmd:pydoc$pyShortVer = $pyVersionCompat cmd:python$pyShortVer = $pyVersionCompat cmd:python${pyShortVer}_config = $pyVersionCompat - cmd:pyvenv_$pyShortVer = $pyVersionCompat devel:libpython$pyShortVer$secondaryArchSuffix = 1.0 lib:libpython$pyShortVer$secondaryArchSuffix = 1.0 " @@ -57,7 +77,7 @@ REQUIRES=" lib:libffi$secondaryArchSuffix lib:libintl$secondaryArchSuffix lib:liblzma$secondaryArchSuffix - lib:libncurses$secondaryArchSuffix + lib:libncursesw$secondaryArchSuffix lib:libsqlite3$secondaryArchSuffix lib:libssl$secondaryArchSuffix lib:libz$secondaryArchSuffix @@ -69,11 +89,9 @@ BUILD_REQUIRES=" devel:libexpat$secondaryArchSuffix devel:libffi$secondaryArchSuffix devel:liblzma$secondaryArchSuffix - devel:libncurses$secondaryArchSuffix + devel:libncursesw$secondaryArchSuffix devel:libsqlite3$secondaryArchSuffix devel:libssl$secondaryArchSuffix - devel:libtclstub8.6$secondaryArchSuffix - devel:libtk8.6$secondaryArchSuffix devel:libz$secondaryArchSuffix " BUILD_PREREQUIRES=" @@ -88,15 +106,31 @@ BUILD_PREREQUIRES=" cmd:pkg_config$secondaryArchSuffix " -# For some reason, test_zoneinfo fails to find it when running the tests inside the chroot, -# but works when calling the test with an installed Python 3.nn -TEST_REQUIRES=" - timezone_data - " +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 set to "yes", the resulting "_tests" package is around 30 MB in size. -packageTests="no" -if [ "$packageTests" = "yes" ]; then +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 " @@ -105,6 +139,12 @@ if [ "$packageTests" = "yes" ]; then " fi +# For some reason, test_zoneinfo fails to find it when running the tests inside the chroot, +# but works when calling the test with an installed Python 3.nn +TEST_REQUIRES=" + timezone_data + " + BUILD() { autoreconf -fi @@ -113,23 +153,34 @@ BUILD() # "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" + # If not provided, the Makefile ends up with: + # BASECFLAGS= -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 \ - --enable-optimizations \ + $maybeEnableOptimizations \ --enable-shared \ --with-ensurepip=no \ --with-readline=editline \ --with-system-expat \ --with-tzpath=$dataDir/zoneinfo \ --without-static-libpython - # --with-lto # this one is too CPU/RAM intensive. + # --with-lto # this one makes build times at least 2.5x slower. # Uncomment when doing repeated builds (for testing different flags/options). # echo "[.recipe] Cleaning before rebuild:" && make clean && rm -f python @@ -145,18 +196,33 @@ BUILD() # "Parser/parser.c:38718:1: error: corrupted profile info: invalid time profile" # # Not using multiple jobs for make solves both the warnings and the possible error. - # make $jobArgs - make -j 1 + + if $optimizedBuild; then + make -j 1 + else + make $jobArgs + fi } INSTALL() { - # altinstall avoids clobbering $prefix/bin/{2to3,idle3,pydoc3,python3,python3-config} - make altinstall + if $installAsDefaultPython; then + make install + else + # altinstall avoids clobbering $prefix/bin/{idle3,pydoc3,python3,python3-config} + make altinstall + fi - # Remove this one for "make altinstall" Python versions on Haiku. 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/ @@ -168,11 +234,6 @@ INSTALL() sed -i -e 's,headers/x86,headers,' $developLibDir/pkgconfig/python*.pc fi - ## Provide symlink to libpython3.nn.so - # Having `libpython3.nn.so` can help software like CudaText (via python4delphi), for example, - # to detect the different Python versions available for runtime loading. - ln -sr $libDir/libpython${pyShortVer}.so.1.0 $libDir/libpython${pyShortVer}.so - mkdir -p $prefix/lib/python$pyShortVer/vendor-packages echo 'This directory contains packaged python modules.' \ >$prefix/lib/python$pyShortVer/vendor-packages/README @@ -180,7 +241,7 @@ INSTALL() mkdir -p $prefix/non-packaged/lib/python$pyShortVer mv $prefix/lib/python$pyShortVer/site-packages $prefix/non-packaged/lib/python$pyShortVer/ - if [ "$packageTests" = "yes" ]; then + if $packageTests; then packageEntries tests \ $prefix/lib/python$pyShortVer/idlelib/idle_test \ $prefix/lib/python$pyShortVer/test @@ -209,17 +270,22 @@ INSTALL() # To see the available test-runs options: # > hp -E python3.nn -# > LIBRARY_PATH=/sources/Python-3.nn.n:%A/lib:/boot/home/config/non-packaged/lib:/boot/home/config/lib:/boot/system/non-packaged/lib:/boot/system/lib python -m test --help -# or just: +# > 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, results on hrev57581 (64 bits): -# Total duration: 4 min 47 sec -# Total test files: run=429/410 failed=27 skipped=18 resource_denied=9 rerun=28 +# For reference, results on hrev56578+96 (64 bits, VBox): +#Total duration: 11 min 33 sec +#Total tests: run=31,919 failures=292 skipped=1,134 +#Total test files: run=429/410 failed=25 skipped=26 resource_denied=6 rerun=25 TEST() { # Remove tests data left-overs, if any: @@ -231,7 +297,7 @@ TEST() # Use this to get same test order on different runs (actual value not important). --randseed 7858065 - # Print the names of the 10 slowest tests. + # Print the names of the 10 slowest tests. --slowest # Possibly useful? @@ -244,7 +310,9 @@ TEST() # # 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 @@ -253,8 +321,8 @@ TEST() # 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. + -x test_subprocess # tends to hang. + -x test_threading # tends to hang. # Many of the tests hang/stall. We have two options: # @@ -262,6 +330,7 @@ TEST() # 2- Set a TIMEOUT (eg: --timeout=300). # # Option 1: Works, but requires manual identification/mainteinance. + # # Option 2: Doesn't requires maintaining a list of stalling tests, but: # at the end of the test run it causes: # - "unmounting failed: Device/File/Resource Busy" errors, as there are @@ -275,11 +344,11 @@ TEST() -x test_asynchat -x test_concurrent_futures -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_multiprocessing -x test_socketserver -x test_threaded_import # test_importlib/test_threaded_import @@ -323,6 +392,46 @@ TEST() -x test_ftplib ) + local tests_that_fail=( + test_asyncore + test_c_locale_coercion + test_compileall + test_datetime + test_embed + test_fcntl + test_genericpath + test_json + test_mailbox + test_os test_pathlib + test_popen + test_posix + test_pty + test_re + test_readline + test_shutil + test_site + test_sysconfig + test_tarfile + test_termios + test_time + test_tools + test_utf8_mode + test_zipfile + ) + local -x LOGNAME=buildbot # this skips tests_tools/test_freeze, copied from Gentoo's ebuild - make $jobArgs test EXTRATESTOPTS="${test_options[*]}" + + 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. }