Skip to main content

Build-time version metadata injection for Python packages.

Project description

buildstamp

CI PyPI Python License: MIT

Build-time version metadata injection for Python packages. Every artifact is stamped with its version, quality tier, commit SHA, and build date — with no metadata drift between source and installed packages, and no git required at runtime.


How it works

Environment Version source
Git checkout / editable install Live: git rev-parse + VERSION file
Installed artifact (no .git) Baked: _build.json written at build time

The quality tier (dev / rc / stable) is controlled by the RELEASE_TYPE environment variable at build time, so no tag ceremony is needed and no branch names leak into artifacts.


Quick start

1. Configure pyproject.toml:

[project]
dynamic = ["version"]

[tool.setuptools.dynamic]
version = {file = "VERSION"}

[tool.setuptools.package-data]
your_package = ["_build.json"]

[build-system]
requires = ["setuptools>=64.0", "wheel", "buildstamp"]
build-backend = "buildstamp.backend"

Optional buildstamp configuration:

[tool.buildstamp]
metadata-file = "your_package/_build.json"
version-file = "VERSION"

For dev artifact naming, use an environment variable instead of pyproject:

BUILDSTAMP_DEV_VERSION="{base}+g{sha}" RELEASE_TYPE=dev uv build

No _build_backend.py shim or extra backend-path is required.

3. Add _build.json to .gitignore:

your_package/_build.json

4. Use in your_package/__init__.py:

from buildstamp import load_metadata

_meta          = load_metadata(__file__)
__version__    = _meta.version
__quality__    = _meta.quality
__commit__     = _meta.commit
__build_date__ = _meta.build_date

5. Create a VERSION file at the project root:

1.0.0

BuildMetadata fields

Field Type Dev (checkout) Artifact
version str "1.0.0+g701e4ca" "1.0.0"
quality str "dev" RELEASE_TYPE value
commit str short SHA short SHA baked at build time
build_date datetime | None None UTC datetime

Releasing artifacts

# stable release
RELEASE_TYPE=stable uv build

# release candidate
RELEASE_TYPE=rc uv build

If RELEASE_TYPE is unset, the baked quality defaults to "dev".


Installation

pip install buildstamp

While not yet on PyPI, install from source:

uv pip install setuptools
uv pip install -e /path/to/buildstamp
uv pip install -e . --no-build-isolation

Design rationale

See VERSIONING.md for the full rationale — including why this avoids git tags, dirty flags, and branch names as version sources.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildstamp-0.6.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildstamp-0.6.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file buildstamp-0.6.0.tar.gz.

File metadata

  • Download URL: buildstamp-0.6.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for buildstamp-0.6.0.tar.gz
Algorithm Hash digest
SHA256 b38e45b8632ad3e4c9d565b9d6f989d8bd00e870b3583620ab9cd2cedbdef84c
MD5 eb5117bb3f8844bb1436bd7ea5d7d856
BLAKE2b-256 dfa39e0fe7207a20c006fdb4f0833fd9c29c59350900c00cc3393d088d2f8ada

See more details on using hashes here.

Provenance

The following attestation bundles were made for buildstamp-0.6.0.tar.gz:

Publisher: release.yml on basvandriel/buildstamp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file buildstamp-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: buildstamp-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for buildstamp-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5a6e9baf0d5f843481bc2b472c287ee5fd02a806c3fcc98f2dbd30f10d1f98
MD5 37134f2b51f084adce332f57fd4147f9
BLAKE2b-256 205e58b7c7c52080524e98e2b58cfea14b4a07acc81f7843813e3db86ce81be6

See more details on using hashes here.

Provenance

The following attestation bundles were made for buildstamp-0.6.0-py3-none-any.whl:

Publisher: release.yml on basvandriel/buildstamp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page