Implementation:Wandb Weave Publish PyPI Release
| Knowledge Sources | |
|---|---|
| Domains | Release_Engineering, Distribution |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
External tool documentation for publishing the Weave SDK to PyPI provided by the Wandb Weave repository.
Description
The publish_pypi_release.py script builds the distribution (if needed) and uploads it to PyPI or Test PyPI using twine upload. Authentication is handled via environment variables (TWINE_API_KEY, TWINE_USERNAME, TWINE_PASSWORD for production; TWINE_TEST_API_KEY or TWINE_TEST_USERNAME/PASSWORD for test).
Usage
Run with uv run scripts/publish_pypi_release.py for production or --test for Test PyPI. Use --dry-run to build without uploading.
Code Reference
Source Location
- Repository: wandb/weave
- File: scripts/publish_pypi_release.py
- Lines: L48-138
Signature
def main() -> None:
"""Build and upload to PyPI.
CLI args: --test (Test PyPI), --dry-run (build only).
Auth via env vars: TWINE_API_KEY, TWINE_USERNAME, TWINE_PASSWORD.
"""
def run_command(cmd: list[str], env: dict[str, str] | None = None) -> int:
"""Run a command, printing it first."""
CLI Usage
# Production
uv run scripts/publish_pypi_release.py
# Test PyPI
uv run scripts/publish_pypi_release.py --test
# Dry run (build only)
uv run scripts/publish_pypi_release.py --dry-run
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| --test | flag | No | Upload to Test PyPI instead of production |
| --dry-run | flag | No | Build only, no upload |
| TWINE_API_KEY | env var | Yes (prod) | Production PyPI API token |
| TWINE_TEST_API_KEY | env var | Yes (test) | Test PyPI API token |
Outputs
| Name | Type | Description |
|---|---|---|
| PyPI package | upload | Package published and installable via pip |
| stdout | str | Twine verbose upload progress |
Usage Examples
Full Release
# Set credentials
export TWINE_API_KEY="pypi-..."
# Build and publish
uv run scripts/publish_pypi_release.py
Test Release
export TWINE_TEST_API_KEY="pypi-..."
uv run scripts/publish_pypi_release.py --test