This is the official Python SDK for Deno Sandboxes (deno-sandbox on PyPI). It provides programmatic access to create and manage sandboxes, execute code, manage filesystems, volumes, apps, and deployments.
- Async-first: All I/O is implemented as async code first. The sync API wraps it via
AsyncBridge(inbridge.py), which runs a separate event loop in a background thread. - Class naming: Async classes are prefixed with
Async(e.g.,AsyncDenoDeploy,AsyncSandbox,AsyncSandboxFs). Sync wrappers drop the prefix (DenoDeploy,Sandbox,SandboxFs). - Data models: Use
TypedDictfor all data models. Do NOT use dataclasses or Pydantic. - HTTP: Uses
httpx.AsyncClient. Do NOT introducerequestsoraiohttp. - WebSocket: Uses
websockets. Do NOT introduce other WS libraries. - Source code:
src/deno_sandbox/ - Public exports:
src/deno_sandbox/__init__.py
bridge.py—AsyncBridgethat powers the sync APIsandbox.py— Sandbox creation and managementfs.py— Filesystem operationsprocess.py— Child process managementrpc.py— JSON-RPC 2.0 over WebSocketconsole.py— HTTP client for Console APIapps.py— App managementrevisions.py— Deployment revisionserrors.py— Custom exception classesoptions.py— Configuration
- MUST design pythonic APIs: snake_case, keyword arguments, no unnecessary classes.
- MUST be consistent with the existing API in this codebase. When unsure, read existing code first and ask the user.
- MUST NOT make breaking changes. If a breaking change would improve consistency, ask the user for permission first.
- MUST add tests for every bug fix and new feature. Place tests in
tests/test_<module>.py. - MUST implement every new feature for the async API first, then ensure the sync wrapper exposes it too. MUST add tests for both sync and async variants.
- MUST use
uvfor all Python tooling (running scripts, installing packages, building, etc.). Do NOT usepip,poetry,pipx, or barepython. - Tests hit the real Deno API (not mocked). Requires
DENO_DEPLOY_TOKENin.env. - Python 3.10+.
uv run --env-file .env pytestRun a specific test:
uv run --env-file .env pytest tests/test_revisions.py::test_revisions_get_async -xvs- Async tests:
test_<name>_async, decorated with@pytest.mark.asyncio(loop_scope="session") - Sync tests:
test_<name>_sync - Shared fixtures in
conftest.py:async_shared_sandbox,shared_sandbox
IMPORTANT: Before finishing any task, MUST run both of these:
uv run ruff format
uv run ty checkVersion is in pyproject.toml. Pushing a git tag v<version> triggers the publish workflow to PyPI.