PythSol
Write Solana programs in typed Python, compiled to native SBF bytecode — no Rust on your machine.
Status: compiler through SPL token CPI, plus the local CLI.
pythsol checktype-checks a typed Python subset.pythsol buildcompiles it to a native SBF.so, an Anchor-style IDL, and a solders client. A second build of the same C printscache hit (skipped clang).pythsol testruns pytest against LiteSVM. The counter and ledger examples run there, and so do a one-byte@enumgate, a fixed-widthOption[u64]note, aFixedString[8]label, a till whose fee is an inlined helper, a spot account whosePointis packed inline, a vault whose PDA seed, has-one, address, owner, and close are checked by the program, a bell thatemits a fixed-width event, a pay instruction whosesystem_transfermoves lamports, and a token move whosetoken_transfer,token2022_transfer, andata_createCPIs run against the programs LiteSVM already loads. A program may split across sibling modules (from acct import Counter); those files are parsed and are never imported or executed.pythsol servecan also compile that program to a.soon your machine when the SBF tools are installed.Vec[T, N]is a fixed-capacity list. A data enum is a tag plus one reserved scalar (Fill: u64), so later fields stay put. Asystem_transferfrom a program PDA moves lamports directly. Still ahead: unboundedVec[T], in-browser SBF compile, and translated docs. Host the static site fromweb/docs/distafternpm run build. Host the full playground (check + emit + compile) with Docker — seedocs/guides/hosting.md(also/v1/compilebehind--allow-compile). Without that flag a public server checks and emits only. The checklist isdocs/STATUS.md. This tree is version 0.1.0 and is not a release.
Source of truth: docs/spec/PRD.md (scope) + docs/spec/TRD.md (how).
When possible ADRs under docs/decisions/ record every assumption that was validated.
from pythsol import (
Init, Mut, ProgramError, Pubkey, Signer, account, error, instruction, require, u64, u8,
)
@account
class Counter:
authority: Pubkey
count: u64
bump: u8
@error
class CounterError(ProgramError):
Unauthorized = 100
Overflow = 101
@instruction
def increment(authority: Signer, counter: Mut[Counter], by: u64) -> None:
require(counter.authority == authority.key, CounterError.Unauthorized)
counter.count += by # overflow-checked
Install
pip install -e ".[test]" # developer install, with pytest and solders
pip install pythsol # compiler and CLI only (when published)
pythsol test needs the test extra. Until you reinstall the editable package,
the pytest plugin is not on the entry-point list. pythsol test still loads it
with PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 and -p pythsol.testing.plugin.
CLI
pythsol doctor # check toolchain, Python, RPC
pythsol init app --template counter # or ledger, vault, escrow
pythsol check counter.py # full front-end type check; exit 1 with PSxxxx diagnostics
pythsol check --json counter.py
pythsol idl counter.py # Anchor-style IDL, no SBF toolchain
pythsol build counter.py # native SBF .so + IDL + client + manifest
pythsol test # build, then pytest on LiteSVM
pythsol client counter.py -o client.py
pythsol cpi counter.py -o cpi.py # off-chain builders; not an on-chain invoke
pythsol port idl.json -o sketch.py # skeleton with pass bodies
pythsol deploy --dry-run --so prog.so # prints solana program deploy; mainnet needs --yes
pythsol faucet --amount 1 # devnet only, at most 5 SOL
pythsol wallet new --outfile id.json # secret stays off the terminal unless --show-secret
pythsol verify --left a.so --right b.so # exit 0 match, exit 3 mismatch
pythsol profile --logs run.log # reads "consumed N of" lines already in the log
pythsol idl-publish --address <ID> --dry-run
pythsol serve # loopback playground, 127.0.0.1:8765
pythsol docs # offline command list
pysol doctor # `pysol` is the spec-draft alias of the same CLI
Build
pythsol build programs/counter.py emits target/pythsol/counter/:
| file | contents |
|---|---|
counter.c |
auditable C generated from your program (never hand-edited) |
counter.so |
the SBF ELF deployed on-chain |
counter.json |
Anchor-style legacy IDL |
counter_client.py |
solders Instruction builders and account decoders |
manifest.json |
sha256 of c/idl/so/client, toolchain info, and cache (hit, miss, or off) |
On-chain guarantees: require() failures log (file:line) and return
6000 + index; integer arithmetic never wraps (checked ops abort with 1009/1010);
Init accounts are PDAs created through a System-program CPI with your seeds.
The binary ABI conventions are pinned in
ADR-0010.
Phases
| Phase | Deliverable | Status |
|---|---|---|
| 0 | monorepo skeleton, ADRs, CI, license, name spike | done |
| 1 | SBF toolchain locator + doctor, C→SBF spike, LiteSVM spike | done |
| 2 | parse/subset/type-check front-end, pythsol check, 40+ negative fixtures |
done |
| 3 | ProgramModel, IDL, C runtime/emitter, pythsol build, LiteSVM acceptance |
done |
| 4 | if/while/for, casts, full integer widths, FixedArray, checked expressions |
done |
| 5 | Python client (*_client.py, solders) |
done |
| 6 | pythsol test, pytest plugin, build cache, wallet, faucet, deploy, pysol.toml |
done |
| 7 | Starlight scaffold and light tokens (web/docs, web/shared-tokens) |
done (live at /docs; no Lighthouse run) |
| 8 | pythsol serve loopback check, emit, and compile |
live check/emit (hosted compile pending Render) |
| 9 | gallery of the six examples, pythsol port, migration and contributor notes |
partial (six examples, not twenty) |
| 10 | verify, profile, idl-publish, cpi, VS Code diagnostics |
partial (no audit, no CU gate) |
| 11 | docs translations, a second IR, in-browser SBF | not scheduled |
| … | unit enums (@enum, match) |
done |
| … | fixed-width Option[T] (tag + reserved value) |
done |
| … | fixed-width FixedString[N] (u32 length + reserved bytes) |
done |
| … | plain helpers (inlined, not instructions) | done |
| … | nested @struct (fixed width, inline, no discriminator) |
done |
| … | constraints Seeds / HasOne / Address / Owner / CloseTo |
done |
| … | alias refusal peels constraint wrappers | done |
| … | @event and emit (fixed-width log) |
done |
| … | system_transfer (System program CPI) |
done |
| … | SPL Token, Token-2022, and ATA CPIs | done |
| … | multi-file programs (sibling modules, parsed not executed) | done |
| … | Vec[T, N], fixed-width data enums, PDA lamport move |
done |
| … | hosted playground deploy configs (Docker/Fly/Render, --allow-compile) |
done |
| … | browser-side devnet deploy button | later |
| … | unbounded Vec[T], in-browser WASM clang |
later |
License
Apache-2.0. See LICENSE and docs/decisions/ADR-0002.
Metadata
Release files for pythsol 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pythsol-0.1.0.tar.gz | 685.6 kB | Without provenance | Details for pythsol-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pythsol-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pythsol-0.1.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / pythsol-0.1.0.tar.gz
| Download URL | pythsol-0.1.0.tar.gz |
|---|---|
| Size | 685.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c66497fb1e29c36ddd10319af532d679694f5bb99ba4994cd956ab888c17ad7
|
|
BLAKE2b-256 checksum How to use checksums |
07cb5716375c730439d0f4a50aabfef2d4f86f4c6829ad381f998e5864d47903
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / pythsol-0.1.0-py3-none-any.whl
| Download URL | pythsol-0.1.0-py3-none-any.whl |
|---|---|
| Size | 459.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0884033808eef992a6a715cf11d3d6e35f1cc940b83cbb7a7d34139997266cd3
|
|
BLAKE2b-256 checksum How to use checksums |
a84c436ff702b5e0de2a67b8385812fe94c52955892a304059917e54a040efe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for pythsol 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.