pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/lang/python314



Module Name:    pkgsrc
Committed By:   wiz
Date:           Mon May 18 21:23:27 UTC 2026

Modified Files:
        pkgsrc/lang/python314: Makefile distinfo
Added Files:
        pkgsrc/lang/python314/patches: patch-Lib___pyrepl_terminfo.py

Log Message:
python314: fix terminfo support in REPL

Bump PKGREVISION.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 pkgsrc/lang/python314/Makefile
cvs rdiff -u -r1.9 -r1.10 pkgsrc/lang/python314/distinfo
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/lang/python314/patches/patch-Lib___pyrepl_terminfo.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/lang/python314/Makefile
diff -u pkgsrc/lang/python314/Makefile:1.13 pkgsrc/lang/python314/Makefile:1.14
--- pkgsrc/lang/python314/Makefile:1.13 Wed Mar 25 22:52:08 2026
+++ pkgsrc/lang/python314/Makefile      Mon May 18 21:23:27 2026
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.13 2026/03/25 22:52:08 wiz Exp $
+# $NetBSD: Makefile,v 1.14 2026/05/18 21:23:27 wiz Exp $
 
 .include "dist.mk"
 
 PKGNAME=       python314-${PY_DISTVERSION}
+PKGREVISION=   1
 CATEGORIES=    lang python
 
 MAINTAINER=    pkgsrc-users%NetBSD.org@localhost

Index: pkgsrc/lang/python314/distinfo
diff -u pkgsrc/lang/python314/distinfo:1.9 pkgsrc/lang/python314/distinfo:1.10
--- pkgsrc/lang/python314/distinfo:1.9  Mon May 11 11:53:45 2026
+++ pkgsrc/lang/python314/distinfo      Mon May 18 21:23:27 2026
@@ -1,10 +1,11 @@
-$NetBSD: distinfo,v 1.9 2026/05/11 11:53:45 adam Exp $
+$NetBSD: distinfo,v 1.10 2026/05/18 21:23:27 wiz Exp $
 
 BLAKE2s (Python-3.14.5.tar.xz) = daa101f9c2a21050c6dcf9cb4a61d147d92e7ab9fb698d79d2b4d7e70311bca8
 SHA512 (Python-3.14.5.tar.xz) = efbaf629703cd004f6b7bc75fb16df794185589adaf8807cd45928f212271045a399df3cd9573e47c8708fb5c5002f9d4efe4e41dde4313b81a3e9d73158769f
 Size (Python-3.14.5.tar.xz) = 23903332 bytes
 SHA1 (patch-Include_pymacro.h) = 7611315fefc305a48b4965f2f2b9bee53ae3d987
-SHA1 (patch-Lib_ctypes_util.py) = 3dec1b6b7a36e46cbfa0dfcd71c5e7fac9f60764
+SHA1 (patch-Lib___pyrepl_terminfo.py) = 905a1b281afa0a97302db22b55a9d6b7880c73ad
+SHA1 (patch-Lib_ctypes_util.py) = 671f4fcccb738ec96c4ba8ad62b66ea016172651
 SHA1 (patch-Lib_sysconfig_____init____.py) = 76a35b78b098978209f9bcc0e5357d439f281c6b
 SHA1 (patch-Makefile.pre.in) = 620fa538eaebdf4e374eff0ed475a87775fb0a29
 SHA1 (patch-Modules_faulthandler.c) = ca59c378d25bfc0769a7f5da887369d8c913e70c

Added files:

Index: pkgsrc/lang/python314/patches/patch-Lib___pyrepl_terminfo.py
diff -u /dev/null pkgsrc/lang/python314/patches/patch-Lib___pyrepl_terminfo.py:1.1
--- /dev/null   Mon May 18 21:23:27 2026
+++ pkgsrc/lang/python314/patches/patch-Lib___pyrepl_terminfo.py        Mon May 18 21:23:27 2026
@@ -0,0 +1,97 @@
+$NetBSD: patch-Lib___pyrepl_terminfo.py,v 1.1 2026/05/18 21:23:27 wiz Exp $
+
+Use C interface for getting information out of libterminfo on NetBSD.
+Fall back to ansi for tmux-direct.
+https://github.com/python/cpython/issues/140296
+
+--- Lib/_pyrepl/terminfo.py.orig       2026-05-10 10:21:34.000000000 +0000
++++ Lib/_pyrepl/terminfo.py
+@@ -1,6 +1,8 @@ from dataclasses import dataclass, field
+ """Pure Python curses-like terminal capability queries."""
+ 
+ from dataclasses import dataclass, field
++import ctypes
++import ctypes.util
+ import errno
+ import os
+ from pathlib import Path
+@@ -130,6 +132,47 @@ def _validate_terminal_name_or_raise(terminal_name: st
+         raise ValueError("`terminal_name` cannot contain path separators")
+ 
+ 
++def _load_from_system_terminfo(terminal_name: str) -> dict[str, bytes] | None:
++    """Try to load terminal capabilities via the system terminfo(3) library.
++
++    Returns None if the library is unavailable or the terminal is unknown.
++    """
++    for libname in ("terminfo", "tinfo", "curses", "ncurses"):
++        soname = ctypes.util.find_library(libname)
++        if soname is None:
++            continue
++        try:
++            lib = ctypes.CDLL(soname)
++        except OSError:
++            continue
++        try:
++            lib.setupterm.restype = ctypes.c_int
++            lib.setupterm.argtypes = [
++                ctypes.c_char_p, ctypes.c_int, ctypes.POINTER(ctypes.c_int)
++            ]
++            # Use c_void_p to avoid auto-dereferencing (char*)-1
++            # that tigetstr returns for invalid capabilities.
++            lib.tigetstr.restype = ctypes.c_void_p
++            lib.tigetstr.argtypes = [ctypes.c_char_p]
++        except AttributeError:
++            continue
++        errret = ctypes.c_int(0)
++        ret = lib.setupterm(
++            terminal_name.encode(), 1, ctypes.byref(errret)
++        )
++        if ret != 0 or errret.value != 1:
++            return None
++        capabilities: dict[str, bytes] = {}
++        invalid = ctypes.c_void_p(-1).value
++        for cap in _STRING_NAMES:
++            addr = lib.tigetstr(cap.encode())
++            if addr is None or addr == invalid:
++                continue
++            capabilities[cap] = ctypes.string_at(addr)
++        return capabilities
++    return None
++
++
+ def _read_terminfo_file(terminal_name: str) -> bytes:
+     """Find and read terminfo file for given terminal name.
+ 
+@@ -307,6 +350,7 @@ _TERM_ALIASES = {
+     "screen-256color": "ansi",
+     "tmux": "ansi",
+     "tmux-256color": "ansi",
++    "tmux-direct": "ansi",
+     "vt100": "ansi",
+     "vt220": "ansi",
+     "rxvt": "ansi",
+@@ -331,8 +375,9 @@ class TermInfo:
+         - ncurses/tinfo/lib_setup.c:TINFO_SETUP_TERM()
+ 
+         This version first attempts to read terminfo database files like ncurses,
+-        then, if `fallback` is True, falls back to hardcoded capabilities for
+-        common terminal types.
++        then tries finding information from terminfo via ctypes, and finally, if
++        `fallback` is True, falls back to hardcoded capabilities for common terminal
++        types.
+         """
+         # If termstr is None or empty, try to get from environment
+         if not self.terminal_name:
+@@ -344,6 +389,11 @@ class TermInfo:
+         try:
+             self._parse_terminfo_file(self.terminal_name)
+         except (OSError, ValueError):
++            caps = _load_from_system_terminfo(self.terminal_name)
++            if caps is not None:
++                self._capabilities = caps
++                return
++
+             if not self.fallback:
+                 raise
+ 



Home | Main Index | Thread Index | Old Index