astral-sh / astral-sh/python-build-standalone
Make ncurses find our own terminfo automatically
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 314
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 27
Description
In 5246d4edc0800a9ab65115d25ee96350334c71ed, and as documented on the quirks page, we ship a copy of the terminfo database with the interpreter, but you have to actually set TERMINFO_DIRS to use it, because ncurses and friends do not know how to find a relocatable/binary-relative terminfo db.
It appears that a `sitecustomize.py` that contains
```python
import sys, os
os.environ["TERMINFO_DIRS"] = sys.prefix + "/share/terminfo"
```
is sufficient to make these libraries work. In particular, I tested by making sure I had no terminfo in the locations that p-b-s would notice (specifically - I am running NixOS, I renamed /etc/terminfo and unset $TERMINFO_DIRS). Without this file, `bin/python3` complains; with this file it works fine.
I am tempted to ship this in the interpreter (as a patch to `site.py` or some C code, to be clear, not `sitecustomize`) and drop the paragraph about this from the quirks doc.
I think it's also probably not too hard to patch ncurses to be able to handle a library-relative terminfo.
(Alternatively, I kind of want to _not_ ship it, or trim it down to plausible terminals in the year 2025, as it is somehow 7 MB.... or somehow ship it in even-more-compiled or compressed format inside libtinfo.a.)
Contributor guide
Assessment
This issue has not been assessed yet.