Python runtime for rspyts: pydantic contracts and a ctypes loader for Rust cdylibs bridged with the rspyts ABI.
Project description
rspyts (Python runtime)
The pure-Python runtime used by packages generated with rspyts generate.
It provides pydantic contracts, typed bridge errors, and the native Library
loader/caller. Python 3.11 through 3.14 is
supported; numpy and pydantic v2 are its only runtime dependencies.
Application API
Contractis the unknown-field-rejecting pydantic base for generated models.Librarylocates and calls an ABI 3 Rustcdylib.BridgeError,RspytsPanicError, andStaleHandleErrorare the public exception hierarchy.
Generated APIs use ordinary Python int for Rust i64/u64 and
typing.Any for Rust serde_json::Value. Exact range and JSON portability
checks live at the generated wire boundary rather than in public wrapper
types.
Generated packages pass call-scoped error mappings. There is no mutable global error registry, so independent generated packages cannot collide on codes.
Library checks a library-specific override such as
RSPYTS_LIBRARY_DEMO_CRATE before explicit and packaged paths. ABI 3
libraries must export rspyts_contract_fingerprint. The loader always validates
that export and generated packages pass expected_contract_fingerprint to fail
before the first call if the Python bindings and native module differ.
Generated-code contract
Low-level codec primitives live in rspyts.internal. Each generated package
owns codecs.py, calls internal.require_emitter_api(4), uses the single
Library.call() path, and passes its internal.Response through every
schema-directed decoder. A
response explicitly owns both value and tail; container decoders return
child Response values carrying the same tail.
ABI 3 serde_json::Value is transparent on the wire. json_to_wire validates
and returns the JSON value unchanged, while json_from_wire stops traversal at
the schema-declared JSON position. Objects whose keys look like attachment
metadata therefore remain ordinary JSON.
This internal surface is the explicit emitter/runtime contract rather than
the ordinary application API. EMITTER_API_VERSION changes whenever generated
code must migrate.
Native wheels with Hatch
Rust-backed packages can use the build hook shipped by this distribution instead of maintaining a project-specific packaging script:
[build-system]
requires = ["hatchling", "rspyts[hatch]==0.3.2"]
build-backend = "hatchling.build"
[tool.hatch.build.hooks.rspyts]
config = "../rspyts.toml"
config is the hook's only setting and is relative to the Python project.
The matching rspyts CLI must be on PATH; the hook rejects a CLI whose
version differs from the Python runtime. Standard builds first run the
read-only binding check, then build one locked release host cdylib in a
temporary directory. The resulting wheel is tagged py3-none-<platform> and
contains the library under the generated package's fixed lib directory.
Editable builds use the same check and atomically stage a locked development
cdylib directly into <python.out>/lib. Add that directory to .gitignore.
Source distributions are rejected because they cannot contain the built native
library. Platform tags are deliberately host-only: macOS uses the Mach-O slice
deployment target and a verified @rpath install name, Linux requires the
interpreter's matching manylinux or musllinux policy, and Windows requires the
matching architecture and .dll artifact. Standard wheel builds fail closed
if the cdylib depends on a non-system shared library: statically link or bundle
that library, or use auditwheel, delocate, or delvewheel in a dedicated
packaging pipeline. Editable builds remain local and do not impose distribution
portability policy. rspyts does not reimplement those wheel-repair tools.
License
This project is licensed under the MIT license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rspyts-0.3.2.tar.gz.
File metadata
- Download URL: rspyts-0.3.2.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6f0f8a58200bdec2cd6c554f0596fbf5b17845210b49c326c48bcb344551d01
|
|
| MD5 |
8ab4096293e13248dc8e3d549b23b504
|
|
| BLAKE2b-256 |
1173b2ca63fee7eb2218f0136803d1f93ae96420aebd2b7fe27edf5b31309b5c
|
Provenance
The following attestation bundles were made for rspyts-0.3.2.tar.gz:
Publisher:
deploy.yml on 2xf-org/rspyts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rspyts-0.3.2.tar.gz -
Subject digest:
e6f0f8a58200bdec2cd6c554f0596fbf5b17845210b49c326c48bcb344551d01 - Sigstore transparency entry: 2176166972
- Sigstore integration time:
-
Permalink:
2xf-org/rspyts@528d970f28201a42be65372335608040ced9d209 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/2xf-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@528d970f28201a42be65372335608040ced9d209 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rspyts-0.3.2-py3-none-any.whl.
File metadata
- Download URL: rspyts-0.3.2-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cfca055367bc4a7f8258a131c273d9b3856e258a4b764e66a30f6d1acb6bbb1
|
|
| MD5 |
ad8cf82dac14c90895e341815041225e
|
|
| BLAKE2b-256 |
5fb931bae110d1240b19f7d2a452ff4e5a0fabfd13b2e148b48ad34ea803f8a5
|
Provenance
The following attestation bundles were made for rspyts-0.3.2-py3-none-any.whl:
Publisher:
deploy.yml on 2xf-org/rspyts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rspyts-0.3.2-py3-none-any.whl -
Subject digest:
2cfca055367bc4a7f8258a131c273d9b3856e258a4b764e66a30f6d1acb6bbb1 - Sigstore transparency entry: 2176166986
- Sigstore integration time:
-
Permalink:
2xf-org/rspyts@528d970f28201a42be65372335608040ced9d209 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/2xf-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@528d970f28201a42be65372335608040ced9d209 -
Trigger Event:
push
-
Statement type: