Python with Elide

Run Python 3.13 with elide python: CPython-style arguments, the bundled stdlib, and JS interop

Python support is experimental in 1.6.0.

Elide runs Python 3.13 with its standard library; no CPython install is needed. Python is an optional component:

elide setup python

--channel=release or --channel=nightly picks the channel, and --force reinstalls. apt and RPM installs cannot add it; Installation lists the methods that can. Without the component, a Python command prints Python support is not installed. Run 'elide setup python' to add it. and exits 2.

Run Python

elide python takes the same arguments as python:

elide python app.py --name Elide --count 2   # sys.argv: ['app.py', '--name', 'Elide', '--count', '2']
elide python -c 'import sys; print(sys.version)'
elide python -m json.tool input.json
echo 'print("from stdin")' | elide python -

Every token after the script, -c CMD, or -m MODULE is a program argument. Bare elide python starts the REPL in a terminal and reads standard input otherwise.

Running a Python program with command-line arguments in Elide

The general commands also run .py files, with the same sys.argv:

elide app.py
elide run app.py
elide -l python -s 'print(1 + 1)'

Interpreter options

These go before the script, -c, or -m. elide --help-all lists them under “Python interpreter options”.

FlagEffect
-c CMDRun CMD as the program; trailing tokens become sys.argv[1:].
-m MODULERun a library module as __main__.
-sDon’t add the user site directory to sys.path.
-IIsolated mode.
-EIgnore PYTHON* environment variables.
-SDon’t import site on startup.
-PDon’t prepend a potentially unsafe path to sys.path.
-BDon’t write bytecode files.
-uUnbuffered standard output and error.
-OOptimization level; repeat for -OO.
-bWarn on bytes/str comparisons; repeat to raise errors.
-W ARGWarning control; repeatable.
-xAccepted for compatibility; no effect.

Standard library

The Python 3.13 standard library is included, among it json, pathlib, sqlite3, ssl, zlib, and ctypes. bz2 and lzma need no system libbz2 or liblzma.

JavaScript interop

With --interop, Python evaluates JavaScript through the built-in elide module:

# sum.py
from elide import js

print(js("[1, 2, 3].reduce((a, b) => a + b, 0)"))
elide --interop python sum.py

JavaScript and TypeScript import a Python module’s default export:

// main.mjs
import mod from "./mod.py";
console.log(mod.hello());
elide --interop run main.mjs

Without --interop, these calls fail. See Languages and Interop.

Third-party packages

Elide does not install PyPI packages: elide install skips dependencies.pypi, and elide install --ecosystems=pypi exits 2. Packages in a Python 3.13 virtual environment load when VIRTUAL_ENV points at it:

export VIRTUAL_ENV=/path/to/venv
elide python app.py

Elide reads the environment’s lib/python3.13/site-packages.

Known limitations

  • C extensions: some C extension modules do not load.
  • macOS: native module isolation is not available.
  • WebAssembly SIMD: installing Python disables it; see WebAssembly with Elide.
  • CPython differences: some edge cases behave differently from CPython 3.13; see the Compatibility Matrix.