Execution Modes
Edit this pageHow PYRS runs code in REPL, stdin, module, script, command, and bytecode modes.
PYRS supports CPython-style execution entry points for interactive use, one-shot commands,
module mode, script execution, stdin, and .pyc execution.
Mode Overview
| Invocation | Behavior |
|---|---|
pyrs | Starts interactive REPL when stdin/stdout are terminals. |
pyrs (with piped stdin) | Runs non-interactive stdin script input. |
pyrs path/to/script.py | Runs source file and sets main.file. |
pyrs path/to/module.pyc | Executes CPython bytecode file through the VM bytecode path. |
pyrs -m package.module | Resolves a library module from the current working directory/import path and runs it as a script. |
pyrs -c ”…” | Executes inline command string with CPython-shaped command mode semantics. |
sys.argv Semantics
| Mode | sys.argv shape |
|---|---|
| Script mode | [script_path, …script_args] |
-c mode | [“-c”, …args] |
-m mode | [resolved_module_origin, …module_args] |
| REPL/stdin mode | [""] |
Startup Controls
| Control | Effect |
|---|---|
-S, —no-site | Skips automatic site import at startup. |
-I, -E | Accepted CPython compatibility flags; currently suppress only PYTHONWARNINGS ingest. |
PYRS_CPYTHON_LIB | Sets explicit CPython stdlib root and enables strict startup-site import behavior. |
PYTHONPATH | Additional module search entries are appended to the VM import path. |
VIRTUAL_ENV | Detected virtualenv site-packages paths are appended when present. |
Practical Examples
Shell
$ pyrs -c "import sys; print(sys.argv)" one two $ pyrs -m http.server 8000 $ pyrs path/to/script.py arg1 arg2 $ pyrs -S path/to/script.py $ echo 'print(40 + 2)' | pyrs $ pyrs path/to/module.pyc