The Python SDK is published to the public PyPI index as minimax-code-sdk by the
Python SDK release workflow (.github/workflows/python-sdk-release.yml) using PyPI Trusted
Publishing. No PyPI token is stored in the repository or in GitHub secrets. It is versioned
independently of the CLI and of @minimax-ai/code-sdk.
- Publish only from a commit on
mainthat went through a reviewed pull request. The workflow rejects a tag whose commit is not contained inorigin/main. - A published version is immutable. PyPI never accepts the same file name twice, even after a release is deleted. Fix problems in a new version; prefer yanking a broken release over deleting it.
- Versions are stable
X.Y.Zor PEP 440 pre-releasesX.Y.ZaN,X.Y.ZbNandX.Y.ZrcN(for example0.1.0b1), written in canonical form. Never use npm-style0.1.0-beta.1. See Pre-releases. - Release tags are
code-sdk-python-v<version>, for examplecode-sdk-python-v0.1.0b1. They are separate from CLI tags (vX.Y.Z) and TypeScript SDK tags (code-sdk-vX.Y.Z). Never move or delete a pushed release tag. - Do not upload from a workstation. If the workflow is unavailable, fix the workflow.
-
The PyPI project
minimax-code-sdkbelongs to theminimax-aiPyPI organization. Every owner and maintainer account uses two-factor authentication. -
On PyPI, add a Trusted Publisher (a pending publisher before the first upload) with:
Field Value PyPI project name minimax-code-sdkOwner MiniMax-AIRepository minimax-codeWorkflow python-sdk-release.ymlEnvironment pypi -
For rehearsals, add the same publisher on TestPyPI with environment
testpypi. TestPyPI accounts and projects are separate from PyPI. -
In the GitHub repository settings, create the environments
pypiandtestpypi. Givepypirequired reviewers and restrict its deployment refs tocode-sdk-python-v*tags.
-
Update
versioninpackages/code-sdk-python/pyproject.tomland__version__insrc/minimax_code/__init__.py. -
Add a section at the top of
CHANGELOG.md:## X.Y.Z · YYYY-MM-DDwith the user-visible changes. -
If the minimum supported CLI, the Python range or the event
schemaVersionchanges, update the README andMIN_CLI_VERSIONinsrc/minimax_code/_cli.py. -
Run the local checks:
cd packages/code-sdk-python uv sync --locked uv run ruff check . && uv run ruff format --check . && uv run mypy && uv run pytest -W error uv run python scripts/release_check.py metadata --index pypi
-
Merge the pull request into
mainafter the usual review and checks.
Run the Python SDK release workflow manually with repository: testpypi. It runs every
check below and uploads to TestPyPI. Each version can be uploaded to TestPyPI only once, so
rehearse only versions you intend to release. A manual run with repository: none builds and
checks without uploading anywhere.
git switch main
git pull --ff-only
git tag -a code-sdk-python-vX.Y.Z -m "minimax-code-sdk X.Y.Z"
git push origin code-sdk-python-vX.Y.ZThe tag push starts the workflow. Its build job:
- checks that the tag matches
pyproject.toml,__version__and the first CHANGELOG heading, that the tagged commit is onorigin/main, and that the version is not on PyPI yet; - runs ruff, mypy and the test suite;
- builds the wheel and sdist with
uv buildand runstwine check --strict; - runs
scripts/release_check.py dist, which rejects unexpected wheel entries, local or generated files and unsafe paths in the sdist, and prints the sha256 of both files; - scans the extracted archives with the repository's public text policy
(
scripts/lib/public-text-policy.mjs) and Gitleaks; - installs the wheel into an empty virtual environment and checks
minimax_code.__version__.
The publish-pypi job then waits for approval on the pypi environment and uploads exactly the
checked files with pypa/gh-action-pypi-publish, which also attaches PyPI attestations.
Pre-releases go to the real PyPI index through the same workflow and checks; only the version
differs. Installers skip them unless the user passes --pre (pip), --prerelease=allow (uv) or
pins the exact version, so pip install minimax-code-sdk keeps resolving to the newest stable
release once one exists. Keep the README install instructions in line with the latest release.
- Fix a broken pre-release with the next number (
0.1.0b2), not by reusing a version. - Promote by releasing
0.1.0with its own CHANGELOG section; earlier pre-releases stay in the history and need no cleanup. - When the first stable release ships, drop
--prefrom the README install instructions and replaceDevelopment Status :: 4 - Betainpyproject.tomlas appropriate.
curl -fsS https://pypi.org/pypi/minimax-code-sdk/X.Y.Z/json \
| python3 -c 'import json,sys; [print(u["digests"]["sha256"], u["filename"]) for u in json.load(sys.stdin)["urls"]]'Both digests must equal the sha256 lines printed by the Check distribution contents step. If
they differ, stop: the index holds different bytes than the checked files.
smoke="$(mktemp -d)" && cd "$smoke"
uv venv -q && uv pip install -q "minimax-code-sdk==X.Y.Z"
.venv/bin/python -c "import minimax_code; print(minimax_code.__version__, minimax_code.MCode)"It must print X.Y.Z and the MCode class. PyPI's CDN can take a few minutes to serve a new
version.
- The
buildjob fails: nothing was published. Fix it in a pull request, merge, and tag a new commit. If the version number itself was wrong, use a new version; do not reuse the tag. publish-pypifails before upload (Trusted Publisher mismatch, network): fix the cause and re-run the failed job of the same workflow run. The artifact is the already checked build.- Upload accepted but read-back fails: wait and repeat the read-back. Do not re-run the upload unless PyPI confirms the version does not exist.
- Digests differ or the smoke test fails: the version is published and cannot be replaced. Release a fixed version and yank the broken one on PyPI (Manage project → Releases → Options → Yank) with a reason.