This release is a pre-release and may not be stable for production use.
open-sandboxes
open-sandboxes is an open-source, python-native and self-hosted-first alternative implementation of Cloudflare Sandbox SDK.
The only pre-requisite for running open-sandboxes is to have a cloud environment with Docker installed: whenever you want to execute python code remotely, you will simply leverage a Sandbox object which will create an ephemeral Docker container (based on ghcr.io/astral-sh/uv:alpine) on your remote machine, on which all the dependencies will be installed and the code will run.
Installation
You can install open-sandboxes via pip:
pip install open-sandboxes
Or you can build it from source code:
git clone https://github.com/AstraBert/open-sandboxes
cd open-sandboxes
pip install [-e] . # use the -e option for editable installations
Usage
To create a Sandbox instance, you need an SSH remote connection and a pyproject.toml file with all your dependencies listed. This can be provided:
- With the path to the
pyproject.tomlfile and aSSHConnectionobject:
from open_sandboxes import Sandbox
from open_sandboxes.ssh_connection import SSHConnection
conn = SSHConnection(
host="your-host.com",
username="user",
password="my-password", # you can also use a passphrase with a private key file
port=22,
)
sandbox = Sandbox(
name="sandbox-1",
remote_connection=conn,
pyproject_file_path="pyproject.toml",
)
- With a
PyprojectConfiginstance:
from open_sandboxes import Sandbox
from open_sandboxes.ssh_connection import SSHConnection
from open_sandboxes.uv_config import PyprojectConfig
conn = SSHConnection(
host="your-host.com",
username="user",
password="my-password", # you can also use a passphrase with a private key file
port=22,
)
config = PyprojectConfig(
dependencies=[{"name": "httpx", "version_constraints": "<1"}],
title="http-server",
min_python_version="3.10", # included (>=3.10)
max_python_version="3.13", # excluded (<3.13)
)
sandbox = Sandbox(name="sandbox-1", remote_connection=conn, config=config)
- Using the
from_connection_argsclass method:
sandbox = Sandbox.from_connection_args(
name="sandbox-1",
username="user",
passphrase="secret-passhprase",
key_file=".ssh/key_file",
host="your-host.com",
port=22,
pyproject_file_path="pyproject.toml",
)
Once you created a Sandbox instance, use the run_code method to run whatever code you want:
code = """
import httpx
import asyncio
async def main():
async with httpx.AsyncClient() as client:
res = await client.get("https://uselessfacts.jsph.pl/api/v2/facts/random")
res.raise_for_status()
return res.json().get("text", "no text")
if __name__ == "__main__":
result = asyncio.run(main())
print(f"A random fact is: {result}")
"""
res = sandbox.run_code(code=code)
print("Code output:", res["output"])
print("Captured stderr logs:", res["error"])
You can configure run_code to:
- Export specific environment variables (passing a dictionary under the
environmentparameter) - Enforce resource consumption limits to CPU, memory, number of processes and read/write rates.
Contributing
Contributions are always welcome! Please read the contributing guide to get to know more about the contribution process.
License
This project is provided under an MIT License
Metadata
Release files for open-sandboxes 0.2.1a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| open_sandboxes-0.2.1a0.tar.gz | 50.7 kB | Without provenance | Details for open_sandboxes-0.2.1a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| open_sandboxes-0.2.1a0-py3-none-any.whl | Python 3 | none | any | Details for open_sandboxes-0.2.1a0-py3-none-any.whl |
Total release size: 59.1 kB
Release files / open_sandboxes-0.2.1a0.tar.gz
| Download URL | open_sandboxes-0.2.1a0.tar.gz |
|---|---|
| Size | 50.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fd0048f178fe9ab282f8f196de8b48548d9e81c357188d88e280e19fabefcbb
|
|
BLAKE2b-256 checksum How to use checksums |
f3b7c0d01799f2501384706bdd1d446206af64dbaf31d0615488974ee8b4b618
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / open_sandboxes-0.2.1a0-py3-none-any.whl
| Download URL | open_sandboxes-0.2.1a0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5bbde1aa6d183e523589226a5bd960d363de9835dcc7676592b1553468e92305
|
|
BLAKE2b-256 checksum How to use checksums |
5327fb2e0fd258530429a7b593367f081ad0b0137dcfc1c6d6b72725639c7fc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Security for open-sandboxes 0.2.1a0
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.