Metadata-Version: 2.4
Name: withruntime
Version: 0.3.0
Summary: Runtime Cloud: one client (sync and async) for every Runtime product. Sandboxes first.
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# Runtime Cloud Python SDK

One client for every Runtime Cloud product, sync and async. Python 3.10 or
later, standard library only.

```bash no-run
pip install withruntime
```

The client uses `RUNTIME_API_KEY` when it is set, and otherwise the connection
this machine saved when `npx withruntime login` connected it (one browser
approval, no key to copy). On a server, set `RUNTIME_API_KEY` from your secret
manager (create a key at https://withruntime.com/account/keys). Never put a key
in source code, a URL or a command-line argument.

```python
from withruntime import Sandbox

with Sandbox.create() as sbx:
    result = sbx.exec("python3 -c 'print(6 * 7)'")
    print(result.exit_code, result.stdout)
```

`Sandbox.create()` needs no arguments and returns once the sandbox is running;
leaving the `with` block stops it. `AsyncRuntime` is the same client for
asyncio, method for method:

```python
import asyncio
from withruntime import AsyncRuntime


async def main():
    async with AsyncRuntime() as runtime:
        async with await runtime.sandboxes.create() as sbx:
            print((await sbx.exec("uname -a")).stdout)


asyncio.run(main())
```

A sandbox has `exec`, `exec_stream`, `spawn`, `terminal`, `files` (read, write,
list, glob, stat, move, remove, upload and download directories), `pause`,
`wake`, `extend`, `fork` and `snapshot`, and the `interpreter`, `network`,
`previews` and `desktop` products. The client has `sandboxes`, `images`,
`volumes`, `snapshots`, `feedback` and `support`. Every write carries an
idempotency key, so retries never do anything twice; errors are typed and carry
`code`, `hint` and `request_id`.

Docs: https://withruntime.com/docs/python.

The package was called `withruntime-cloud`, imported as `runtime_cloud`, until
0.3.0. Both names still work: `withruntime-cloud` installs this package and
`import runtime_cloud` gives you the same classes.
