-
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
Open
subssn21
wants to merge
2
commits into
anomalyco:dev
Choose a base branch
from
subssn21:python-sdk-pypi-pr
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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')" | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,74 @@ | ||
| # 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 | ||
| ``` | ||
|
|
||
| ## 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) | ||
| - [Python Examples](https://github.com/anomalyco/sst/tree/dev/examples/aws-python) | ||
| - [GitHub](https://github.com/anomalyco/sst) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.