diff --git a/docs/concepts/telltale-detection.md b/docs/concepts/telltale-detection.md index bb69ac7..b02e5c7 100644 --- a/docs/concepts/telltale-detection.md +++ b/docs/concepts/telltale-detection.md @@ -18,6 +18,7 @@ Each [`ModuleBuilder`](/architecture/module-builder.md) subclass declares `m_tel class Openssl(ModuleBuilder): m_telltale = "{include}/openssl/ssl.h" + class Sqlite(ModuleBuilder): m_telltale = ["{include}/sqlite3.h"] ``` diff --git a/docs/guides/add-an-external-module.md b/docs/guides/add-an-external-module.md index 69ae7c2..ac0aa39 100644 --- a/docs/guides/add-an-external-module.md +++ b/docs/guides/add-an-external-module.md @@ -18,8 +18,8 @@ To statically link a new C library into CPython, add a [`ModuleBuilder`](/archit class Mylib(ModuleBuilder): """See https://docs.python.org/3/library/mymodule.html""" - m_telltale = "{include}/mylib.h" # marker if system already has it - m_debian = "+libmylib-dev" # Linux build constraint (see telltale detection) + m_telltale = "{include}/mylib.h" # marker if system already has it + m_debian = "+libmylib-dev" # Linux build constraint (see telltale detection) @property def url(self): diff --git a/pyproject.toml b/pyproject.toml index ae8b1c1..7959146 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,9 +82,8 @@ line-length = 140 src = ["src", "tests"] [tool.ruff.lint] -extend-select = [ +select = [ "A", # flake8-builtins -# "ARG", # flake8-unused-arguments "B", # flake8-bugbear "C4", # flake8-comprehensions "C90", # mccabe @@ -108,13 +107,11 @@ extend-select = [ "RET", # flake8-return "RUF", # ruff-specific "S", # flake8-bandit -# "SIM", # flake8-simplify "SLF", # flake8-self "SLOT", # flake8-slots "T10", # flake8-debugger "TID", # flake8-tidy-imports "TCH", # flake8-type-checking -# "TD", # flake8-todos "TRY", # tryceratops "W", # pycodestyle warnings ] diff --git a/scripts/check_okf.py b/scripts/check_okf.py index b889b87..8de9daa 100755 --- a/scripts/check_okf.py +++ b/scripts/check_okf.py @@ -24,7 +24,7 @@ # Matches markdown links ending in .md, with an optional #anchor (external http(s)/mailto links are skipped below) LINK_RE = re.compile(r"\]\((?P[^)\s#]+\.md)(?:#[^)]*)?\)") -TYPE_RE = re.compile(r"^type:\s*(?P\S.*)$", re.M) +TYPE_RE = re.compile(r"^type:\s*(?P\S.*)$", re.MULTILINE) def frontmatter(text): diff --git a/src/portable_python/__init__.py b/src/portable_python/__init__.py index e4b5439..89eb30a 100644 --- a/src/portable_python/__init__.py +++ b/src/portable_python/__init__.py @@ -16,7 +16,7 @@ import pathlib import re from string import Template -from typing import ClassVar, List +from typing import ClassVar import runez from runez.http import RestClient @@ -301,9 +301,9 @@ def compile(self): class ModuleCollection: """Models a collection of sub-modules, with auto-detection and reporting as to what is active and why""" - candidates: List["ModuleBuilder"] = None + candidates: list["ModuleBuilder"] = None desired: str = None - selected: List["ModuleBuilder"] = None + selected: list["ModuleBuilder"] = None def __init__(self, parent_module: "ModuleBuilder", desired=None): self.selected = [] diff --git a/src/portable_python/cpython.py b/src/portable_python/cpython.py index d6a83f6..e1e2057 100644 --- a/src/portable_python/cpython.py +++ b/src/portable_python/cpython.py @@ -199,6 +199,21 @@ def xenv_LIBMPDEC_LIBS(self): if self.version >= "3.14" and PPG.target.is_macos: yield f"{self.deps_lib_dir}/libmpdec.a" + def xenv_LIBREADLINE_LIBS(self): + if self.version >= "3.12" and self.active_module(Readline): + # Since 3.12 (gh-90005), ./configure asks pkg-config how to link the readline module, + # and no longer probes for the termcap library that readline needs. It states: + # "We now assume that libreadline or readline.pc provide correct linker information". + # Our readline is static, and its readline.pc mentions ncurses in 'Requires.private', + # which `pkg-config --libs` does not report (only `--libs --static` does). readline + # then gets linked without ncurses: it compiles, but fails to import at the end of + # the build with "undefined symbol: UP". So state the full static link line ourselves + # (same as `pkg-config --static --libs readline`), ./configure honors _LIBS for + # exactly this purpose (gh-94801). + yield f"-L{self.deps_lib_dir}" + yield "-lreadline" + yield "-lncursesw" + @runez.cached_property def prefix_lib_folder(self): """Path to /lib/pythonM.m folder""" diff --git a/src/portable_python/inspector.py b/src/portable_python/inspector.py index ca926a7..55b52b7 100644 --- a/src/portable_python/inspector.py +++ b/src/portable_python/inspector.py @@ -233,8 +233,7 @@ def short_name(self): short_name = self.basename if not short_name.startswith("libpython"): - if short_name.startswith("lib"): - short_name = short_name[3:] + short_name = short_name.removeprefix("lib") short_name = short_name.partition(".")[0]