Skip to main content

exec-python

Minimal engine to execute python code generated by LLMs, with a lot of customisation options.

Requirements

  • Python 3.13+
  • uv (for development & testing)

Installation

pip install exec-python 

Running the tests

uv run test_engine.py

Usage

Quick Start

from exec_python import execute_python_code

def pair_sum(x: list[int], y: list[int]) -> list[int]:
    assert isinstance(x, list)
    assert isinstance(y, list)
    assert len(x) == len(y)
    return [x[i] + y[i] for i in range(len(x))]

code = """
x = [1, 2]
y = [2, 3]
z = pair_sum(x, y)
k = pair_sum(z, z)
"""

results = execute_python_code(
    code = code,
    functions=[pair_sum]
)
print(results)

Running the above code will output:

{
  "function_results": {
    "pair_sum": ["z","k"]
  },
  "variables": {
    "x": [1,2],
    "y": [2,3],
    "z": [3,5],
    "k": [6,10]
  },
  "errors": []
}

Metadata

Release files for exec-python 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exec-python 0.1.6
File Size Uploaded Provenance Actions
exec_python-0.1.6.tar.gz 15.1 kB Without provenance Details for exec_python-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exec-python 0.1.6
File Interpreter ABI Platform Actions
exec_python-0.1.6-py3-none-any.whl Python 3 none any Details for exec_python-0.1.6-py3-none-any.whl

Total release size: 20.1 kB

Release files / exec_python-0.1.6.tar.gz

Download URL exec_python-0.1.6.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
03e6b96aee7031620d1e12e4aeb1bc87a762b61df42adb14ca5274b05a762962
BLAKE2b-256 checksum
How to use checksums
0bce9d265a3924861e3630a25cf257ddb989b91f20778d26dda18cad00205f04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.15

Release files / exec_python-0.1.6-py3-none-any.whl

Download URL exec_python-0.1.6-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e18bfad02704f8fcb47a97576802eeb4ee41f1407b81d2682573c16af137209a
BLAKE2b-256 checksum
How to use checksums
f5a46b0ec8d4ae9c211bc8c19500ee29a0082961375221e5d4a0d36851003ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.15

Security for exec-python 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page