{"library":"starlark-pyo3","title":"Starlark-pyo3","type":"library","description":"Starlark-pyo3 is a Python wrapper for the `starlark-rust` interpreter, bringing Google's Starlark language (a dialect of Python used in Bazel) to Python applications. It enables executing Starlark scripts, evaluating expressions, and integrating with Python objects. The library is currently at version 2025.2.5 and follows a rapid release cadence, often tied to updates in its underlying Rust dependencies.","language":"python","status":"active","last_verified":"Thu May 21","install":{"commands":["pip install starlark-pyo3"],"cli":null},"imports":["from starlark_pyo3 import Starlark","from starlark_pyo3 import init_once"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/inducer/starlark-pyo3","docs":"https://documen.tician.de/starlark-pyo3/","changelog":null,"pypi":"https://pypi.org/project/starlark-pyo3/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"from starlark_pyo3 import Starlark, init_once\nimport os\n\n# Initialize the Starlark interpreter (safe to call multiple times)\ninit_once()\n\n# Define a simple Starlark script\nstarlark_script = '''\nload('foo.star', 'my_func')\ndef greet(name):\n    return f\"Hello, {name}!\"\n\nmy_value = greet(\"Starlark\")\n'''\n\n# Define a load function for external Starlark files\ndef load_func(name):\n    if name == 'foo.star':\n        return \"def my_func(x): return x * 2\"\n    raise ValueError(f\"Unknown module: {name}\")\n\n# Create a Starlark instance with custom globals and a load function\nstarlark_interpreter = Starlark(globals={'MAGIC_NUMBER': 42}, load_func=load_func)\n\n# Evaluate the script\nresult_globals = starlark_interpreter.eval(starlark_script)\n\n# Access a variable from the evaluated script\nprint(f\"Result from Starlark: {result_globals['my_value']}\")\n\n# Call a function directly from the evaluated module\nprint(f\"Calling greet: {result_globals['greet']('World')}\")\n\n# Verify a global was passed\nprint(f\"Magic number: {result_globals['MAGIC_NUMBER']}\")\n\n# Evaluate an expression directly\nexpression_result = starlark_interpreter.eval('10 * MAGIC_NUMBER')\nprint(f\"Expression result: {expression_result}\")","lang":"python","description":"This quickstart demonstrates how to initialize the Starlark interpreter, define a load function for importing other Starlark files, evaluate a Starlark script, and access global variables and functions from the evaluated context. It also shows how to pass Python objects as globals into the Starlark environment.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-21","installed_version":"2026.1","pypi_latest":"2026.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":25,"avg_install_s":2.1,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"30M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"32M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.3,"import_time_s":null,"mem_mb":null,"disk_size":"24M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"24M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.4,"import_time_s":null,"mem_mb":null,"disk_size":"30M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"starlark-pyo3","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}