ExBashkit.Python (ExBashkit v0.1.3)

Copy Markdown View Source

The python builtin: run sandboxed Python inside a bash session, sharing the session's filesystem.

Enabled per session with ExBashkit.Session.new(python: true), which registers python (and python3) as virtual executables. A script can then run python script.py, python -c "…", or pipe a program on stdin, and the Python reads and writes the same virtual filesystem the surrounding bash commands use — so curl … > /data.json followed by python transform.py works the way it would in a real shell.

Requires the optional :ex_monty dependency (the sandboxed Python interpreter); python: true raises if it is not available. Python's filesystem/os operations are routed to the session via ExBashkit.Python.SessionFs; all other effects (network, clocks) are denied.

Limitations (v1)

  • sys.argv is unsupported (a monty limitation, not ours), so argument-parsing scripts can't read their arguments. python -c "…" and stdin work fully, and python script.py runs (it just can't see trailing args).
  • The script path of python path resolves against the shell's working directory, but relative paths used inside the Python (e.g. Path("out.txt")) resolve from the filesystem root, not the shell cwd — use absolute paths in Python.
  • If a script prints and then raises, the partial stdout is not returned (only the error). open() file objects are unsupported; use pathlib.Path I/O.