Skip to main content

Python bindings to Rust jrsonnet crate

Project description

rjsonnet-py

CI PyPI

Python bindings to Rust jrsonnet crates (Rust implementation of Jsonnet language).

Installation

pip install rjsonnet

Usage

This module provides two functions:

  1. def evaluate_file(filename: str) -> str: ...
  2. def evaluate_snippet(filename: str, src: str) -> str: ...

In the latter case, the parameter filename is used in stack traces, because all errors are given with the "filename" containing the code.

Keyword arguments to these functions are used to control the virtual machine. They are:

  • max_stack (number)
  • gc_min_objects (number, ignored)
  • gc_growth_trigger (number, ignored)
  • ext_vars (dict: string to string)
  • ext_codes (dict string to string)
  • tla_vars (dict string to string)
  • tla_codes (dict string to string)
  • max_trace (number)
  • import_callback (see example in tests/)
  • native_callbacks (see example in tests/)

The argument import_callback can be used to pass a callable, to trap the Jsonnet import and importstr constructs. This allows, e.g., reading files out of archives or implementing library search paths.

The argument native_callbacks is used to allow execution of arbitrary Python code via std.native(...). This is useful so Jsonnet code can access pure functions in the Python ecosystem, such as compression, encryption, encoding, etc.

If an error is raised during the evaluation of the Jsonnet code, it is formed into a stack trace and thrown as a python RuntimeError.

import rjsonnet

# evaluate a jsonnet file
rjsonnet.evaluate_file("filename.jsonnet")

# evalute a jsonnet code snippet
rjsonnet.evaluate_snippet('filename', 'jsonnet code snippet')

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

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

rjsonnet-0.5.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distributions

rjsonnet-0.5.0-cp37-abi3-win_amd64.whl (889.5 kB view details)

Uploaded CPython 3.7+ Windows x86-64

rjsonnet-0.5.0-cp37-abi3-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ x86-64

rjsonnet-0.5.0-cp37-abi3-musllinux_1_2_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

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

rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.6 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.6 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

rjsonnet-0.5.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.2 MB view details)

Uploaded CPython 3.7+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

rjsonnet-0.5.0-cp37-abi3-macosx_10_7_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

File details

Details for the file rjsonnet-0.5.0.tar.gz.

File metadata

  • Download URL: rjsonnet-0.5.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for rjsonnet-0.5.0.tar.gz
Algorithm Hash digest
SHA256 887cae7d0fc165af06f094033700bd5d793c78e27acb4c416f9bcc34a3adfa26
MD5 8aa570a2952c8f9a31d901e991b71a3e
BLAKE2b-256 d963957b9337e25fff716622b41c3d7e6c82bf11ff4b9a193459a995ce0b6921

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: rjsonnet-0.5.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 889.5 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8765351ea40a29ef2ac883d691cec47c8214e619b4910612855a89d124c1c092
MD5 6d498922577224d1c9a622dbeca2f375
BLAKE2b-256 ced8c97e7ba31821e36c106ff8b41ad426b82246f1250802393ae4192d84892f

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f756be04ebf3a58c07a272f7fcb4b87c5a1ba4b0b354babfca0ff5a0b18abd9d
MD5 13b98c143d6ab9aa40c8f03f3efdcd3f
BLAKE2b-256 0e663f4068d2c8158a2e2415f5b3520025038e60feea0bf7e64c31726c207c3f

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d3c9bfbb9a34caf6241cd1fb7c9938e0a79c2c48d19b6254e6c77f546e1ba353
MD5 72f9f4216056ff772fa6c642b7306567
BLAKE2b-256 9c03bdfea7f9abd64515ab39b7574102ec7f39074cc6977050a231d1a991d1a2

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03ca4c8f084e53948caa45db4f076e0d605e6ab3d948ec44bbdbba83d958b0ff
MD5 70f3aebd1c40c13610d5e1fc753629fd
BLAKE2b-256 372222a93eb158e016d75a1f099390333ac676251d5ad81f4cbf50a719658beb

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 bb68ada70074ed51fcf124493999ede14300a017e4869da9e9934f3cb90e129c
MD5 aba85492b78a6d675de818e1995ae556
BLAKE2b-256 c440d7dce29773b5f5f77128d2c582752b03ebfbe147d026d69550226e75ef08

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 babbeea6e99a08915618bff0d6e2184e979d73336f5d7e87e0a12674047d20d4
MD5 bea0e305b4aac48e1815ecbc387d6779
BLAKE2b-256 dc206cf200dde272f910f9e59fd190dbb582e48ab5204a2bba184ad1cdf4a0ab

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5b31cc19e2feaff5d334ace669856010bfc1c55f573a3abfcf1694b7ef182150
MD5 c8a448752a36ef230e93c84738f16d9f
BLAKE2b-256 096648b1344c8a31e2fa1d6430927b281897bd05793b66e2cf750b8432cb885b

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1a7fa1e92b6958ead371b0ff0b5c1ede1f0c59ba09bd0148caecf95ddeefcaf2
MD5 06cc07414ac25517cda9983a4a4914f3
BLAKE2b-256 ba72c25cd82d8f245ccb596ab50f7b611cdf9bb2fa7784c9db1d3c16af49c1be

See more details on using hashes here.

File details

Details for the file rjsonnet-0.5.0-cp37-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for rjsonnet-0.5.0-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 11398b54a3eef083a604712bd3d2d4af711ff5751dcc86af652ce6f1fde4fa02
MD5 7bc1b0872b886c3539b4bedb8c3d151d
BLAKE2b-256 b8ddfe1531d6f96083e01f37244e3bdefe9a0f36b9c1694858b29ee539cb9dea

See more details on using hashes here.

Supported by

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