Skip to content

inducer/starlark-pyo3

Repository files navigation

Starlark-PyO3: Python bindings for starlark-rust

Github Build Status Python Package Index Release Page

This package provides a sandboxed/restricted Python-like environment by exposing the starlark-rust interpreter for the Starlark Python-like language to Python via PyO3.

Starlark claims the following design principles:

  • Deterministic evaluation. Executing the same code twice will give the same results.
  • Hermetic execution. Execution cannot access the file system, network, system clock. It is safe to execute untrusted code.
  • Parallel evaluation. Modules can be loaded in parallel. To guarantee a thread-safe execution, shared data becomes immutable.
  • Simplicity. We try to limit the number of concepts needed to understand the code. Users should be able to quickly read and write code, even if they are not expert. The language should avoid pitfalls as much as possible.
  • Focus on tooling. We recognize that the source code will be read, analyzed, modified, by both humans and tools.
  • Python-like. Python is a widely used language. Keeping the language similar to Python can reduce the learning curve and make the semantics more obvious to users.

Status: This is reasonably complete and usable.

Links

Installation

To install, say:

pip install starlark-pyo3

Binary wheels are available for all major platforms. The module is importable as starlark.

Installation for Development

To use this, make sure you have nightly rust available:

curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs \| sh rustup
default nightly

Then, to install into the current Python virtual environment:

pip install maturin
maturin develop