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, not at package top level. Each generated package owns a private _codecs.py, calls _internal.require_emitter_api(3), 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 an emitter/runtime contract, not an 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.0"]
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.0.tar.gz (36.3 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.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file rspyts-0.3.0.tar.gz.

File metadata

  • Download URL: rspyts-0.3.0.tar.gz
  • Upload date:
  • Size: 36.3 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.0.tar.gz
Algorithm Hash digest
SHA256 9246191a73ccbb9d031ee3e8ac4f6d16ac4124116f73d91e6464a267badd1813
MD5 7a222a193d4a630def4badcf895cee1e
BLAKE2b-256 2ff8bbac3429e7a36c2d765319bc03767bace8165ba6a8bfddc02f90d7b0bbaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for rspyts-0.3.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: rspyts-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccf82358d3576da0e7745ebf458256d289825e70b7c0464bb811076892d2cde1
MD5 32e1ef4b828758326f349bb8fff213fe
BLAKE2b-256 352011da5dd52ce71c1a6d9d9d3dd419f569843d1d0518249f55f1d839b9d929

See more details on using hashes here.

Provenance

The following attestation bundles were made for rspyts-0.3.0-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