# Deploy from Python (/docs/cloud/deploy-python)

<Component />

Python projects write a deployment bundle with the Python SDK, then release and submit it with the TypeScript
hypequery CLI (`npx hypequery`). The [Python CLI](/docs/python/cli) scaffolds and serves projects locally; cloud
releases go through the Node.js CLI.

## 1. Write a deployment bundle [#1-write-a-deployment-bundle]

<CodeBlock>
```python
# analytics/cloud.py
from hypequery.datasets import create_dataset_registry, write_dataset_bundle

from .orders import orders

write_dataset_bundle(
    "analytics/hypequery-deployment",
    create_dataset_registry(orders),
    endpoints={
        "orders": {
            "access": {"kind": "authenticated", "roles": ["analyst"], "scopes": []},
            "tenant": {"kind": "not-required"},
            "path": "/api/analytics/datasets/orders/query",
        },
    },
)
```
</CodeBlock>

Each entry in `endpoints` publishes one dataset with its access policy, tenant requirement, and path.

To publish [business context](/docs/agents/business-context) in the same release, pass
`business_context=define_business_context(...)` (from `hypequery.datasets`). The bundle then carries
`business-context.json`, with the bytes and identity `hypequery deploy` gives the same context.

## 2. Log in, release, and submit [#2-log-in-release-and-submit]

<CodeBlock>
```bash
python -m analytics.cloud
npx hypequery login
npx hypequery deployment:release analytics/hypequery-deployment
npx hypequery deployment:submit analytics/hypequery-deployment \
  --release analytics/hypequery-deployment.release.json
```
</CodeBlock>

- `deployment:release` binds the bundle to your project and environment and writes the release beside the bundle.
- `deployment:submit` uploads both. Once cloud accepts the release, check where it is served with
  `npx hypequery deployment:status`.

A one-step `publish_to_cloud` helper for Python, matching TypeScript's `publishToCloud`, is planned.