-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Publish Python SDK to PyPI as sst-sdk #6858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,3 +66,5 @@ jobs: | |
|
|
||
| - name: Build docs | ||
| run: cd www && bun run build | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Publishing sst-sdk to PyPI | ||
|
|
||
| The Python SDK publishes automatically as part of the SST release workflow | ||
| (`.github/workflows/release.yml`), alongside the JS and Rust SDKs. It triggers | ||
| on every version tag push. | ||
|
|
||
| ## One-time setup | ||
|
|
||
| ### 1. Configure trusted publishing on PyPI | ||
|
|
||
| Go to https://pypi.org/manage/account/publishing/ and create a new pending publisher: | ||
|
|
||
| - **PyPI project name**: `sst-sdk` | ||
| - **Owner**: `sst` (the GitHub org) | ||
| - **Repository**: `sst` | ||
| - **Workflow name**: `release.yml` | ||
| - **Environment name**: (leave blank — the release job doesn't use a named environment) | ||
|
|
||
| This configures OIDC trusted publishing — no API tokens needed. | ||
|
|
||
| ### 2. Verify permissions | ||
|
|
||
| The release workflow already has `id-token: write` permission, which is all | ||
| `pypa/gh-action-pypi-publish` needs. | ||
|
|
||
| ## How it works | ||
|
|
||
| When a tag is pushed: | ||
|
|
||
| 1. The release workflow runs `goreleaser` to build the CLI | ||
| 2. Publishes the JS SDK to npm | ||
| 3. Publishes the Rust SDK to crates.io | ||
| 4. **Publishes the Python SDK to PyPI**: | ||
| - Reads the version from `dist/metadata.json` (same source as other SDKs) | ||
| - Updates `pyproject.toml` with that version | ||
| - Builds with `uv build` | ||
| - Publishes via `pypa/gh-action-pypi-publish` | ||
| 5. Announces on Discord | ||
|
|
||
| The Python SDK version stays in sync with the CLI and other SDKs automatically. | ||
|
|
||
| ## Testing locally | ||
|
|
||
| Build the package without publishing: | ||
|
|
||
| ```bash | ||
| cd sdk/python | ||
| uv build | ||
| ``` | ||
|
|
||
| This creates `dist/sst_sdk-{version}.tar.gz` and `dist/sst_sdk-{version}-py3-none-any.whl`. | ||
|
|
||
| Test the install: | ||
|
|
||
| ```bash | ||
| pip install dist/sst_sdk-*.whl | ||
| python -c "from sst import Resource; print('OK')" | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,76 @@ | ||
| # SST SDK | ||
| # SST Python SDK | ||
|
|
||
| Similar the to the JS SDK, the Python SDK provides a way to access resources in your app. | ||
| The Python SDK for [SST](https://sst.dev) lets you access linked resources in your Python Lambda functions. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install sst-sdk | ||
| ``` | ||
|
|
||
| Or with uv: | ||
|
|
||
| ```bash | ||
| uv add sst-sdk | ||
| ``` | ||
|
|
||
| > **Note**: When deploying with SST, the SDK is automatically included — you don't need to install it manually. This package is for local development and testing. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this true? i don't see any changes made to the function or python runtime
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also if this is the case, why would people need to do |
||
|
|
||
| ## Migrating from the Git dependency | ||
|
|
||
| If you were previously installing the SDK from GitHub: | ||
|
|
||
| ```toml | ||
| # Before | ||
| [project] | ||
| dependencies = ["sst"] | ||
|
|
||
| [tool.uv.sources] | ||
| sst = { git = "https://github.com/sst/sst", subdirectory = "sdk/python" } | ||
| ``` | ||
|
|
||
| Update your `pyproject.toml` to use the PyPI package instead: | ||
|
|
||
| ```toml | ||
| # After | ||
| [project] | ||
| dependencies = ["sst-sdk"] | ||
| ``` | ||
|
|
||
| That's it — remove the `[tool.uv.sources]` entry for `sst` and replace the dependency name. No code changes needed; `from sst import Resource` works the same way. | ||
|
|
||
| ## Usage | ||
|
|
||
| Use `Resource` to access any resource linked to your function in `sst.config.ts`: | ||
|
|
||
| ```python | ||
| from sst import Resource | ||
|
|
||
| print(Resource.MyBucket.name) | ||
| # Access linked resources by name | ||
| bucket_name = Resource.MyBucket.name | ||
| table_name = Resource.MyTable.name | ||
| ``` | ||
|
|
||
| Resources are defined and linked in your `sst.config.ts`: | ||
|
|
||
| ```ts | ||
| const bucket = new sst.aws.Bucket("MyBucket"); | ||
|
|
||
| new sst.aws.Function("MyFunction", { | ||
| handler: "handler.main", | ||
| link: [bucket], | ||
| }); | ||
| ``` | ||
|
|
||
| The SDK reads resource bindings from encrypted environment variables set by SST at deploy time. In `sst dev`, resources are available automatically through the local development bridge. | ||
|
|
||
| ## Supported Python Versions | ||
|
|
||
| - Python 3.9+ | ||
|
|
||
| ## Links | ||
|
|
||
| - [SST Documentation](https://sst.dev/docs/) | ||
| - [SDK Reference](https://sst.dev/docs/reference/sdk/) | ||
| - [Python on SST](https://sst.dev/docs/examples/#aws-lambda-python) | ||
| - [GitHub](https://github.com/sst/sst) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing here with the URLs |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,41 @@ | ||
| [project] | ||
| name = "sst" | ||
| name = "sst-sdk" | ||
| version = "0.2.0" | ||
| description = "SST SDK" | ||
| description = "Python SDK for SST — access linked resources in your SST app" | ||
| readme = "README.md" | ||
| license = "MIT" | ||
| requires-python = ">=3.9" | ||
| keywords = ["sst", "serverless", "aws", "lambda", "infrastructure"] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: MIT License", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Topic :: Software Development :: Libraries", | ||
| ] | ||
| dependencies = ["pycryptodomex==3.20.0"] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://sst.dev" | ||
| Documentation = "https://sst.dev/docs/reference/sdk/" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can add here sdk#python so it links directly? |
||
| Repository = "https://github.com/sst/sst" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should update this URLs to use anomalyco in the org name |
||
| Issues = "https://github.com/sst/sst/issues" | ||
|
|
||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["src/sst"] | ||
|
|
||
| [tool.hatch.build.targets.sdist] | ||
| include = ["src/sst", "pyproject.toml", "README.md"] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "pytest>=8.4.2", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "Release" here correct? aren't we building the sdk? not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really building as there's nothing to compile or anything. It's just bundling the files and pushing it to pypi. Don't think it matters, whichever you want.