pythonrs 0.1.15

Python as a fusevm frontend: lexer, parser, and compiler to fusevm::Chunk on a PyHost heap — the first compiled standalone Python runtime
Documentation
[package]
name = "pythonrs"
version = "0.1.15"
edition = "2021"
rust-version = "1.80"
authors = ["MenkeTechnologies <linux.dev25@gmail.com>"]
description = "Python as a fusevm frontend: lexer, parser, and compiler to fusevm::Chunk on a PyHost heap — the first compiled standalone Python runtime"
license = "MIT"
repository = "https://github.com/MenkeTechnologies/pythonrs"
homepage = "https://menketechnologies.github.io/pythonrs/"
documentation = "https://docs.rs/pythonrs"
readme = "README.md"
keywords = ["python", "interpreter", "compiler", "jit", "fusevm"]
categories = ["command-line-utilities", "compilers"]
publish = true
# Dev-only artifacts kept out of the published crate. Consumers get src + the
# `python`/gen-docs/parity bins, the man page, and shell completions — not the
# HUD site, CI config, integration-test corpus, self-test .py examples, or the
# bug tracker. None are referenced at compile time (no include_str! into them),
# so the packaged crate still builds and its bins run.
# `pylib/` is NOT excluded — it is the vendored pure-Python stdlib the `python`
# bin loads at runtime.
exclude = [
    "/.github/",
    "/tests/",
    "/examples/",
    "/docs/",
    "/scripts/",
    "/BUGS.md",
    "/CHECKLIST.md",
    "/FFI_STDLIB.md",
]

# pythonrs is a standalone crate, not a workspace member. An explicit empty
# `[workspace]` stops cargo walking up to the MenkeTechnologiesMeta parent.
[workspace]

[lib]
name = "pythonrs"
path = "src/lib.rs"
# staticlib so an AOT object can be linked against the pythonrs runtime (the
# extension-op dispatch + the fusevm AOT runtime) into a standalone native
# executable via `python --build`.
crate-type = ["rlib", "staticlib"]

[[bin]]
name = "python"
path = "src/main.rs"

# Offline generator for docs/reference.html — renders the builtin/method
# reference (src/lsp.rs corpus) as a static page. Run before pushing Pages.
[[bin]]
name = "gen-docs"
path = "src/bin/gen_docs.rs"

# Differential parity harness: runs the corpus through pythonrs and the reference
# `python3`, diffing stdout. Development tool — needs `python3` on PATH, so CI
# never runs it. There is no frozen-output replay: this comment used to point at
# tests/data/parity_expected.txt and tests/parity.rs, neither of which exists, so
# nothing here runs without a `python3`.
[[bin]]
name = "parity"
path = "src/bin/parity.rs"

# Differential parity FUZZER: generates thousands of deterministic-output Python
# snippets (biased toward float repr, int //-/%- sign rules, bignum, slices, the
# format mini-language, string methods) and diffs `python -c` against the
# reference `python3 -c`, delta-debugging every divergence to a minimal repro.
# Subprocess-only (never links the lib); std-only (no `rand`). Dev tool — needs
# `python3` on PATH, so CI never runs it.
[[bin]]
name = "parity-fuzz"
path = "src/bin/parity_fuzz.rs"

[dependencies]
# Python executes on fusevm. pythonrs is a pure frontend: it lowers Python to
# fusevm bytecode (src/compiler.rs) and hosts the Python object heap
# (src/host.rs, reached from fusevm's extension handler). Object/str/list/dict
# cells ride through the VM as `Value::Obj(u32)` handles into that heap.
#
# `jit-disk-cache` turns on fusevm's three-tier Cranelift JIT *and* its
# persistent on-disk cache of compiled native code (keyed by chunk hash), so hot
# Python loops trace-compile and warm runs skip recompilation. `aot` enables the
# ahead-of-time object emitter behind `python --build`.
fusevm = { version = "0.26.10", features = ["jit", "jit-disk-cache", "aot", "ffi"] }

clap = { version = "4.5", features = ["derive", "cargo"] }
thiserror = "2.0"
rustc-hash = "2.1"
foldhash = "0.2"
# Python dict preserves insertion order (guaranteed since 3.7, observable in
# iteration/repr).
indexmap = "2"

# rkyv-backed bytecode cache at ~/.pythonrs/scripts.rkyv (mirrors zshrs/rubylang):
# the outer shard is a zero-copy rkyv archive; the inner per-script fusevm::Chunk
# is bincode (fusevm::Chunk is serde-owned, not rkyv::Archive). Versioned from
# day one so a cached .py that worked never breaks (compat floor).
rkyv = { version = "0.7", features = ["validation", "archive_le", "size_32"] }
bincode = "1.3"
memmap2 = "0.9"
dirs = "5"
once_cell = "1"

# LSP (`python --lsp`) + DAP (`python --dap`) over stdio. libc gives the DAP
# server a pipe + dup2 to capture the debuggee's stdout (print) so program output
# streams as `output` events instead of corrupting the JSON-RPC channel.
lsp-server = "0.7.9"
lsp-types = "0.97.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
libc = "0.2"

# Interactive REPL (`python --repl` / TTY fallthrough): reedline line editor,
# nu-ansi-term for the banner/status colors, sysinfo for the live stats box.
reedline = "0.47.0"
nu-ansi-term = "0.50"
sysinfo = { version = "0.38", default-features = false, features = ["system"] }
toml = "0.8"

# Hash algorithms behind `hashlib`'s `_md5`/`_sha1`/`_sha2`/`_sha3`/`_blake2`.
# A hash is defined by its test vectors; these are audited implementations of the
# same FIPS/RFC specifications CPython links OpenSSL for. See `src/stdlib/pyhash.rs`.
digest = "0.10"
md-5 = "0.10"
sha1 = "0.10"
sha2 = "0.10"
sha3 = "0.10"
blake2 = "0.10"

# Regex engines backing the `re` module: `regex` for the linear-time majority,
# `fancy-regex` for the patterns it cannot express (look-around, backreferences)
# — `_pydecimal` and `fractions` both need lookahead. See `src/regexpr.rs`.
regex = "1"
fancy-regex = "0.18"
glob = "0.3"

# Stackful same-thread coroutines backing Python generators (yield) and the
# async event loop. Switches the native stack on the SAME OS thread, so the
# thread_local! PyHost object heap is shared across a generator suspend/resume.
corosensei = "0.3"

# Arbitrary-precision integers: Python `int` is unbounded, so values that fit
# stay `i64` and only the overflow path allocates a `BigInt` heap object.
num-bigint = "0.4"
num-integer = "0.1"
num-traits = "0.2"
# Pure-Rust libm for the special functions Rust std lacks (`lgamma`/`gamma`/`erf`/
# `erfc`) — part of the self-contained `math` surface, no C libm dependency.
libm = "0.2"
# Exact rationals backing `fractions.Fraction` and complex support.
num-rational = "0.4"
num-complex = "0.4"

# CPython stdlib FFI bridge (feature `stdlib-ffi`, ON by default — see [features]).
# `import <stdlib>` delegates to an embedded libpython over pyo3 instead of a
# hand-rolled shadow — the real CPython stdlib (pure `.py` + C accelerators).
# Disable with `--no-default-features` for a pyo3-free, libpython-free build.
# `abi3-py39` links one binary against any CPython >= 3.9 via the stable ABI.
# 3.9 is the floor because it is the oldest the limited API can express what
# `src/ffi.rs` needs — `#[pyclass(dict)]` is rejected below it — not a taste for
# old CPython. A higher floor is not free: `abi3-py313` made `cargo install
# pythonrs` fail outright wherever the host CPython was older ("cannot set a
# minimum Python version 3.13 higher than the interpreter version 3.12" on
# Fedora 40), and, being pyo3 0.24's own ceiling, it also demanded
# `PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1` on 3.14 hosts. At 3.9 neither end
# fires: 3.9 through 3.14 build with no extra env.
pyo3 = { version = "0.29", features = ["abi3-py39", "auto-initialize"], optional = true }
unicode_names2 = "3.1.0"
unicode-general-category = "1.1.0"
# PEP 3131 NFKC identifier normalization in the lexer (CPython folds every
# non-ASCII identifier with `unicodedata.normalize("NFKC", …)`).
unicode-normalization = "0.1"

[features]
# stdlib-ffi is ON by default so `import os` (and the rest of the CPython stdlib)
# works out of the box. It needs a CPython >= 3.9 at build time (pyo3 links it);
# no extra env is required at any version through 3.14. `--no-default-features`
# drops pyo3/libpython for a native-only build (only pythonrs's built-in
# modules) — that is what the release binaries ship.
default = ["stdlib-ffi"]
stdlib-ffi = ["dep:pyo3"]

[dev-dependencies]
tempfile = "3"
# For `strerror(ERANGE)`: the float-overflow message is the C library's own
# and is worded differently by Apple libc and glibc, so the test derives it
# rather than hardcoding either spelling.
libc = "0.2"