Skip to content

Add optional workbook Python macro projects to the plugin host - #4

Open
derechopiano wants to merge 1 commit into
sirmmo:feat/plugin-hostfrom
derechopiano:feat/python-macros-plugin
Open

derechopiano wants to merge 1 commit into
sirmmo:feat/plugin-hostfrom
derechopiano:feat/python-macros-plugin

Conversation

@derechopiano

Copy link
Copy Markdown

Adds optional, workbook-owned Python projects to the shared macro host: bounded multi-module source, XLSX persistence, Python templates/settings in the existing Developer editor, and cancellable native execution with one undo step and rollback on error/Stop/timeout.

Dependency and scope: this PR targets feat/plugin-host at 3e325c1, the branch behind storytold#1123. It contains only the additions to that host. It implements the desktop project portion of storytold#1566 and leaves that issue open. Form controls, Pyodide, language tooling and rich output remain follow-ups.

The companion provider, sirmmo/craft-python#1, extends craft-python 0.3.0 through its existing App/Channel, preserving Run Script, Console, Run File, PY.EVAL and WordCraft/DeckCraft support. The optional role uses a separate identity so ordinary PY.* formulas remain callable during a macro. It does not implement the Python-in-cells work in storytold#469.

  • Adds pythonProjects/engineCommands capabilities while preserving protocol 2.2 and existing VBA/Office.js behavior. Only Python UI runs opt into the new absolute deadline; VBA retains its existing synchronous Run path.
  • Keeps Session work on the owner thread; bounded background transport supports absolute deadlines and Stop/Escape. Conflicting edits/saves are blocked and asynchronous execution refuses live collaboration.
  • Keeps Python/uv optional. Preparation is offline unless the user approves the exact PEP 723 metadata for this document session; approval is never saved in the workbook. Trusted Python has normal user permissions, not an OS sandbox.

Validation:

  • Full local cargo xtask ci: all eight gates passed on Windows, using the real companion provider.
  • Native provider tests cover inert discovery, source/workbook isolation, warm reuse, literal writes, ordinary PY.TWICE recalculation, one-step undo and failure/Stop rollback.
  • Transport tests cover initialization, deadlines, output flooding, late replies and cancellation; automated UI tests exercise Run/Stop/Escape and settings in light/dark themes, with rendered screenshots inspected. A UI regression verifies existing VBA Run remains synchronous.
  • Companion craft-python suite: 68 applicable tests passed on Windows/Python 3.11 and on Linux/Python 3.8 and 3.12, including native process-tree lifetime checks on each platform (three checks for the other platform are inapplicable). Linux CI evidence. FreeBSD CI provisions uv/Python through the existing full workspace test job; native FreeBSD execution remains unverified locally. Linux host CI uses the minimal host-protocol fixture unless the external provider is explicitly selected.

See docs/python-macro-integration.md for installation, APIs and limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant