Skip to main content

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

  • Contract is the unknown-field-rejecting pydantic base for generated models.
  • Library locates and calls an ABI 3 Rust cdylib.
  • BridgeError, RspytsPanicError, and StaleHandleError are 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

rspyts-0.3.2.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rspyts-0.3.2-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

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

Hashes for rspyts-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e6f0f8a58200bdec2cd6c554f0596fbf5b17845210b49c326c48bcb344551d01
MD5 8ab4096293e13248dc8e3d549b23b504
BLAKE2b-256 1173b2ca63fee7eb2218f0136803d1f93ae96420aebd2b7fe27edf5b31309b5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rspyts-0.3.2.tar.gz:

Publisher: deploy.yml on 2xf-org/rspyts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for rspyts-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2cfca055367bc4a7f8258a131c273d9b3856e258a4b764e66a30f6d1acb6bbb1
MD5 ad8cf82dac14c90895e341815041225e
BLAKE2b-256 5fb931bae110d1240b19f7d2a452ff4e5a0fabfd13b2e148b48ad34ea803f8a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rspyts-0.3.2-py3-none-any.whl:

Publisher: deploy.yml on 2xf-org/rspyts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page