Skip to main content

Python bindings for hale — a compiled DSL for consuming HTTP APIs (Rust core)

Project description

hale (Python bindings)

Call the hale compiler and runtime from Python. The heavy lifting (lexer, type checker, optimizer, async runtime) is the same Rust code as the CLI — exposed through PyO3 as an abi3 extension module, so one wheel works on CPython 3.8+.

Install / build

pip install maturin
cd crates/hale-py
maturin develop        # builds the Rust extension and installs `hale` into your venv
# or: maturin build --release   # produces a wheel in target/wheels/

Use

import hale

hale.is_valid(src)            # -> bool: does it type-check?
hale.check(src)               # -> list[str]: diagnostic messages (empty == ok)
hale.explain(src)             # -> str: the parallel plan + request cost
hale.run(src)                 # -> str | None: run the script (raises on error)
hale.inspect(json_text, name) # -> str: infer hale type/contract declarations
hale.json_schema(src, title)  # -> str | None: export types as JSON Schema

See python/example.py.

The functions are thin wrappers over hale_compiler / hale_runtime. run spins a Tokio runtime internally, so the same parallel-inference / dedup / dead-request elimination apply when you execute a program from Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

hale-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

File details

Details for the file hale-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hale-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6229d5ba73b2d3a46c3df99ed7eaa75219b5f87f5ee77ee286f641468d1c4e4e
MD5 d876396c4aba41d4a61c01d674bff5e3
BLAKE2b-256 5eb61168c4fa5b66da587d898649b58b7879fe97181312756b03b5bd696269b6

See more details on using hashes here.

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