Files
e2b-dev--e2b/packages/python-sdk/pyproject.toml
T
Mish Ushakov 4a2a6c7051 Add Templates SDK (#871)
### Merge Templates SDK into E2B SDK.

This PR merges code from Templates SDK to E2B SDK.

**Changelog**

- Added new error classes: BuildError, FileUploadError.
- Added template API endpoints to API Client generation (Python).
- Updated API Clients error handling to throw BuildError in addition to
SandboxError.
- Exported Template and TemplateAsync classes.
- Moved `getRuntime` utility method from api to utils.
- Browser is supported except file operations (COPY). Incompatible
modules are not bundled, using dynamic imports (tar, glob) in supported
environments (Node, Deno, Bun) instead.
- Basic tests were added, subject to expansion in a follow-up PR.
- Breaking: Before, 401 error was raising `SandboxError`, which was
incorrect, now it will raise `AuthenticationError`. I have also changed
the `AuthenticationError` to extend Error class, not `SandboxError`
anymore as it's now thrown by both Sandbox and Template.

**Usage**

JavaScript

```js
import { Template } from 'e2b';

const template = Template()
  .fromImage('ubuntu:22.04')
  .copy('folder/*.txt', 'folder', { forceUpload: true })
  .setEnvs({
    ENV_1: 'value1',
    ENV_2: 'value2',
  })
  .runCmd('cat folder/test.txt')
  .setWorkdir('/app')
  .setStartCmd('echo "Hello, world!"', Template.waitForTimeout('10s'))

await Template.build(template, {
  alias: 'test-template',
  cpuCount: 1,
  memoryMB: 1024,
  onBuildLogs: (logEntry) => console.log(logEntry.toString()),
})

```

Python

```py
from e2b import Template

template = (
    Template()
    .from_image("ubuntu:22.04")
    .copy("folder/*.txt", "folder", force_upload=True)
    .set_envs(
        {
            "ENV_1": "value1",
            "ENV_2": "value2",
        }
    )
    .run_cmd("cat folder/test.txt")
    .set_workdir("/app")
    .set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)

Template.build(
    template,
    alias="test-template",
    cpu_count=1,
    memory_mb=1024,
    on_build_logs=lambda log_entry: print(log_entry),
)
```

Python Async

```py
from e2b import AsyncTemplate

template = (
    AsyncTemplate()
    .from_image("ubuntu:22.04")
    .copy("folder/*.txt", "folder", force_upload=True)
    .set_envs(
        {
            "ENV_1": "value1",
            "ENV_2": "value2",
        }
    )
    .run_cmd("cat folder/test.txt")
    .set_workdir("/app")
    .set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)

await AsyncTemplate.build(
    template,
    alias="test-template",
    cpu_count=1,
    memory_mb=1024,
    on_build_logs=lambda log_entry: print(log_entry),
)
```

---

Merge progress

- [x] JavaScript SDK
- [x] Python SDK
- [x] Tests
- [x] Split files for review
2025-09-05 22:00:22 +02:00

43 lines
1016 B
TOML

[tool.poetry]
name = "e2b"
version = "2.0.2"
description = "E2B SDK that give agents cloud environments"
authors = ["e2b <hello@e2b.dev>"]
license = "MIT"
readme = "README.md"
homepage = "https://e2b.dev/"
repository = "https://github.com/e2b-dev/e2b/tree/main/packages/python-sdk"
packages = [{ include = "e2b" }, { include = "e2b_connect" }]
[tool.poetry.dependencies]
python = "^3.9"
python-dateutil = ">=2.8.2"
protobuf = ">=4.21.0"
httpcore = "^1.0.5"
httpx = ">=0.27.0, <1.0.0"
attrs = ">=23.2.0"
packaging = ">=24.1"
typing-extensions = ">=4.1.0"
dockerfile-parse = "^2.0.1"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pytest-xdist = "^3.3.1"
python-dotenv = "^1.0.0"
pytest-dotenv = "^0.5.2"
pytest-asyncio = "^0.23.7"
pydoc-markdown = "^4.8.2"
ruff = "^0.11.12"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/e2b-dev/e2b/issues"
[tool.ruff]
exclude = [
"e2b/envd/filesystem/filesystem_pb2.py"
]