Skip to main content

Python bindings for the Go implementation of Starlark

Project description

python-starlark-go

PyPI Tests Documentation Status action-bumpr supported

Introduction

This module provides Python bindings for the Starlark programming language.

Starlark is a dialect of Python designed for hermetic execution and deterministic evaluation. That means you can run Starlark code you don't trust without worrying about it being able access any data you did not explicitly supply to it, and that you can count on the same code to always produce the same value when used with the same input data. Starlark was orginally created for the Bazel build system. There are now several implementations of Starlark; this module is built on starlark-go.

This module was originally forked from Kevin Chung's pystarlark.

The version of starlark-go that is currently embedded in this module is v0.0.0-20230122040757-066229b0515d.

Features

  • Evalutes Starlark code from Python
  • Translates Starlark exceptions to Python exceptions
  • Converts Starlark values to Python values
  • Converts Python values to Starlark values
  • No runtime dependencies - cgo is used to bundle starlark-go into a Python extension

Installation

pip install starlark-go

Usage

from starlark_go import Starlark

s = Starlark()
fibonacci = """
def fibonacci(n=10):
   res = list(range(n))
   for i in res[2:]:
       res[i] = res[i-2] + res[i-1]
   return res
"""
s.exec(fibonacci)
s.eval("fibonacci(5)")  # [0, 1, 1, 2, 3]

s.set(x=5)
s.eval("x") # 5
s.eval("fibonacci(x)")  # [0, 1, 1, 2, 3]

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

starlark-go-1.0.0.tar.gz (37.7 kB view hashes)

Uploaded Source

Built Distributions

starlark_go-1.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

starlark_go-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

starlark_go-1.0.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

starlark_go-1.0.0-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

starlark_go-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

starlark_go-1.0.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (998.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

starlark_go-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

starlark_go-1.0.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

starlark_go-1.0.0-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

starlark_go-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

starlark_go-1.0.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (998.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

starlark_go-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

starlark_go-1.0.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

starlark_go-1.0.0-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

starlark_go-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

starlark_go-1.0.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (998.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

starlark_go-1.0.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

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

starlark_go-1.0.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

starlark_go-1.0.0-cp38-cp38-macosx_11_0_arm64.whl (1.0 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

starlark_go-1.0.0-cp38-cp38-macosx_10_9_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

starlark_go-1.0.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

starlark_go-1.0.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view hashes)

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

starlark_go-1.0.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

starlark_go-1.0.0-cp37-cp37m-macosx_10_9_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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