Making a new Python library release

This guide shows how to make a new Perfetto Python library release to PyPI.

The package version is derived automatically from the CHANGELOG (the top vX.Y entry maps to the PyPI version 0.X.Y), so there is no separate version-bump step.

The normal path is the publish-pypi job of the finalize-release.yml GitHub workflow, which runs as part of finalizing a release. The manual path below, driven by tools/release/release_python.py, is the fallback.

Prebuilt pinning

The package ships the prebuilt manifests under python/perfetto/prebuilts/manifests, and TraceProcessor downloads the trace_processor pinned there. Those manifests are rolled on main only after a release is tagged, because they hash the binaries LUCI builds from the tag. So the tree at tag vX.Y still pins the previous release, and a package built naively from the tag ships the wrong trace_processor.

Both release paths therefore regenerate the manifests for vX.Y before building, and python/setup.py refuses to build when PERFETTO_PYPI_RELEASE is set and the pin in python/perfetto/prebuilts/manifests/version.py does not match the package version. Never publish a package built without that variable.

Prerequisites

Publishing

  1. Pick the release commit to publish from — normally the vX.Y tag commit. For example:
COMMIT=$(git rev-parse v56.0^{commit})
  1. Run the release script, passing that commit:
tools/release/release_python.py --publish --commit "$COMMIT"

The script will then perform the following steps:

  1. Once the script completes, push the new branch for the download_url update and create a pull request. After this final PR is landed, the release is complete.