Build-time version metadata injection for Python packages.
Project description
buildstamp
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: _version.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. Add a thin backend shim — _build_backend.py at your project root:
from buildstamp.backend import * # noqa: F401, F403
2. Configure pyproject.toml:
[project]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = {file = "VERSION"}
[tool.setuptools.package-data]
your_package = ["_version.json"]
[build-system]
requires = ["setuptools>=64.0", "wheel", "buildstamp"]
build-backend = "_build_backend"
backend-path = ["."]
3. Add _version.json to .gitignore:
your_package/_version.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file buildstamp-0.3.0.tar.gz.
File metadata
- Download URL: buildstamp-0.3.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a3a50a9e1d26bee441c84d17228bb76a34a70f74b6ae1e107074ae0d73b2c56
|
|
| MD5 |
837e6ecf0d9c696a2761caf857d0b88a
|
|
| BLAKE2b-256 |
deda16380f9f1ddd8ec44892abc8d906387c63344f2a9d682d54f4d0f98a2907
|
Provenance
The following attestation bundles were made for buildstamp-0.3.0.tar.gz:
Publisher:
release.yml on basvandriel/buildstamp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
buildstamp-0.3.0.tar.gz -
Subject digest:
8a3a50a9e1d26bee441c84d17228bb76a34a70f74b6ae1e107074ae0d73b2c56 - Sigstore transparency entry: 1272415847
- Sigstore integration time:
-
Permalink:
basvandriel/buildstamp@b2647f6da542d6ff4642a4fb2a5bc88dfaf5e1aa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/basvandriel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b2647f6da542d6ff4642a4fb2a5bc88dfaf5e1aa -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file buildstamp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: buildstamp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
723294fffdf86556a75169791ef72f464f3f22a11113a00f57dd588fda2323b1
|
|
| MD5 |
f3da6903b60fd9ba6f9d633f91ffce24
|
|
| BLAKE2b-256 |
1dde8610fde39c677dffccb13a75254353b9db8405a0578e2493d7e3562e778c
|
Provenance
The following attestation bundles were made for buildstamp-0.3.0-py3-none-any.whl:
Publisher:
release.yml on basvandriel/buildstamp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
buildstamp-0.3.0-py3-none-any.whl -
Subject digest:
723294fffdf86556a75169791ef72f464f3f22a11113a00f57dd588fda2323b1 - Sigstore transparency entry: 1272416099
- Sigstore integration time:
-
Permalink:
basvandriel/buildstamp@b2647f6da542d6ff4642a4fb2a5bc88dfaf5e1aa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/basvandriel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b2647f6da542d6ff4642a4fb2a5bc88dfaf5e1aa -
Trigger Event:
workflow_dispatch
-
Statement type: