Skip to main content

Python SDK for the Sail sandbox platform

Project description

sail-sdk

Python SDK for the Sail sandbox platform.

Install

pip install sail-sdk
uv add sail-sdk

Sailbox exec

import sail

app = sail.App.find(name="example-app", mint_if_missing=True)
sb = sail.Sailbox.create(
    image=sail.Image.debian_amd64,
    app=app,
    name="sandbox-1",
)
result = sb.exec("echo hi", timeout=5).wait()

print(result.stdout)
print(result.stderr)
print(result.returncode)

# Detached background launch. wait() waits for the launcher shell, not for the
# long-lived background process to exit.
sb.exec("python3 -m http.server 3000", background=True).wait()

# Omitting timeout means Sail will not terminate the exec automatically.
sb.exec("sleep 600").wait()

Sailbox networking

import sail

app = sail.App.find(name="example-app", mint_if_missing=True)
sb = sail.Sailbox.create(
    image=sail.Image.debian_amd64,
    app=app,
    name="sandbox-net",
    timeout=300,
    ingress_ports=[3000],
)

listener = sb.listener(3000)
print(listener.url)

req = sb.request(
    "POST",
    "https://example.com/api",
    json={"hello": "world"},
    idempotency_key="example-1",
)
print(req.id, req.status)

completed = req.wait()
print(completed.status)
print(completed.response.status_code)
print(completed.response.text)

Explicit base images:

amd64_image = sail.Image.debian_amd64
amd_image = sail.Image.debian_amd
arm64_image = sail.Image.debian_arm64
arm_image = sail.Image.debian_arm

Examples

  • examples/sailbox_smoke.py: start a sailbox from the amd64 Debian image.
  • examples/sailbox_custom_image.py: build a custom image with apt_install, pip_install, run_commands, and env, then launch a sailbox from it.

Publishing

Build a distributable package locally from the repo root:

just python-sdk-build

Publish from a developer machine with a PyPI token:

export UV_PUBLISH_TOKEN=pypi-...
just python-sdk-publish

The repository also includes a GitHub Actions release workflow at .github/workflows/python-sdk-publish.yml. It publishes when you push a tag like python-sdk-v0.1.0, after verifying that the tag version matches sail.__version__.

Recommended setup:

  1. Create the sail-sdk project on PyPI.
  2. Configure PyPI Trusted Publishing for this GitHub repository and the python-sdk-publish.yml workflow.
  3. Bump sdk/python/src/sail/__about__.py.
  4. Push a matching tag: git tag python-sdk-v0.1.0 && git push origin python-sdk-v0.1.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sail_sdk-0.1.0.tar.gz (40.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sail_sdk-0.1.0-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file sail_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: sail_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 40.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sail_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a015548a089ee38afe6b124d7edaf38b0bfbd1bbb9315c79499dac3d91c1668e
MD5 f5f3ee9ce0caa969fd7c3bdc3c8a81dc
BLAKE2b-256 f7e631b42bf4517382ab8384aaa713e8549cdef75cf9ca7337954916ef06b317

See more details on using hashes here.

File details

Details for the file sail_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sail_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sail_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7d47a748795d1465c93fce0fe89f72ad6bcef75fbc91d39f4d6a898bcc53295
MD5 8ea36ad2b2fb1ca3aefaa792721d5bfd
BLAKE2b-256 b62af8f7f5245c6d695d040b16d51c4f1a77341d1be2a3142020d549f1827697

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page