erplibre/script/todo
Mathieu Benoit 5d6a262489 [IMP] todo: offer to install textual instead of just naming it
« Installez textual pour le TUI (pip) » left the user to work out which pip,
which interpreter, which package — and it was printed from eight different
places. Every TUI screen now asks:

  ⚠  Textual est nécessaire pour cet écran.
  L'installer maintenant ? (O/n, défaut : oui)

The command targets sys.executable, the interpreter that will have to import
it — installing a distribution package would land somewhere the venv never
looks. Outside a venv it adds --user, which is also what gets past the refusal
of distributions whose environment is externally managed (PEP 668).

Two details that decide whether this works at all:

  · importlib.invalidate_caches() after installing. A failed import is
    remembered, so without it textual stays « missing » for the rest of the
    session despite having just been installed.
  · a pip that exits non-zero never reports success. The check is « is it
    importable NOW », not « did pip return 0 », and the failure suggests the
    distribution package by name.

It lives in its own module rather than as a TODO method: todo_upgrade needs it
too and is imported BY todo, so putting it there would close a cycle.

One call site is deliberately NOT converted. The statistics screen only reads
files; it never touches Textual, and its old message claimed otherwise. An
import failure there is a real module problem and now says so.

Verified: already-present asks nothing and runs nothing; refusal installs
nothing; pip failing returns False and points at python3-textual; pip
succeeding returns True; prompt=False reports without asking. Then each of the
four TUI entries — telemetry, deploy form, deploy progress, migration resume —
offers and falls back cleanly on refusal, while the statistics screen stays
silent.

Also caught by those tests: « import importlib » alone does not expose
importlib.util, so availability could not be checked at all.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-03 02:42:52 -04:00
..
database_manager.py [IMP] todo: add erase-database menu command 2026-06-25 02:37:22 -04:00
kdbx_manager.py [IMP] script: update copyright year to 2026 2026-03-11 23:16:05 -04:00
logo_ascii.txt [IMP] bot assistant TODO 2025-04-27 02:40:20 -04:00
migration_form.py [ADD] migration: a TUI resume screen, same first question as the prompt 2026-08-01 06:38:31 -04:00
migration_stats.py [ADD] migration: a read-only statistics screen, and a way out 2026-08-02 03:16:50 -04:00
qemu_deploy_form.py [FIX] qemu form: tick nothing in the catalog by default 2026-08-01 06:27:25 -04:00
qemu_install_monitor.py [ADD] qemu: statistics screen, with reset — and record failures too 2026-08-01 05:16:27 -04:00
README.base.md [ADD] Multilingual translation of all documentation (EN/FR) 2026-03-04 22:23:52 -05:00
README.fr.md [ADD] Multilingual translation of all documentation (EN/FR) 2026-03-04 22:23:52 -05:00
README.md [ADD] Multilingual translation of all documentation (EN/FR) 2026-03-04 22:23:52 -05:00
source_todo.sh [UPD] TODO: auto installation 2025-10-31 01:33:34 -04:00
textual_setup.py [IMP] todo: offer to install textual instead of just naming it 2026-08-03 02:42:52 -04:00
todo.json [IMP] script todo: add QEMU/KVM VM deploy menu 2026-07-15 11:48:12 +00:00
todo.py [IMP] todo: offer to install textual instead of just naming it 2026-08-03 02:42:52 -04:00
todo_example.json [UPD] TODO: simplify code by reusing method and support same command 2025-04-28 00:35:27 -04:00
todo_file_browser.py [IMP] script: update copyright year to 2026 2026-03-11 23:16:05 -04:00
todo_i18n.py [IMP] todo: offer to install textual instead of just naming it 2026-08-03 02:42:52 -04:00
todo_prefs.py [ADD] migration: a TUI resume screen, same first question as the prompt 2026-08-01 06:38:31 -04:00
todo_telemetry.py [FIX] télémétrie navigation : extraire les commandes des menus « choices » 2026-07-30 23:24:40 -04:00
todo_upgrade.py [IMP] todo: offer to install textual instead of just naming it 2026-08-03 02:42:52 -04:00
version_manager.py [IMP] script: update copyright year to 2026 2026-03-11 23:16:05 -04:00

TODO is an assistant robot to use ERPLibre Execute it with ./script/todo/todo.py or make todo.

For a new project, copy todo_example.json to private/todo/todo_override.json | private/todo/todo_override_private.json and edit it.