Skip to main content

Hatchling Environment Variable Version Source

A Hatchling version source plugin that reads the version from an environment variable with a configurable fallback value, since the built-in env version source does not allow to define a fallback.

Installation

Add the package as a build dependency to your pyproject.toml:

[build-system]
requires = ["hatchling", "hatch-env-plus"]
build-backend = "hatchling.build"

Configuration

Configure a dynamic version source in the project section of pyproject.toml:

[project]
dynamic = ["version"]

Make sure you don't specify the version directly in the project section, or the dynamic version source may not be picked up.

Then, configure the version source:

[tool.hatch.version]
source = "env-plus"
variable = "PACKAGE_VERSION"  # optional, default shown
fallback = "0.0.0dev0"  # optional, default shown

Use the variable field to set the environment variable to use, and set fallback to the desired fallback version.

Note: An empty string, whether from the configured environment variable or from the fallback, is an undefined version.

If you explicitly set the configured environment variable to the empty string, your build will fail as no valid version is set. If you explicitly set fallback to an empty string, your build will fail when the configured environment variable is not set. This is the default behavior of Hatchling's built-in enviroment variable version source env.

Usage

Build your project with the desired version by setting the environment variable:

PACKAGE_VERSION=2.0.0 uv build
# Builds package version "2.0.0".

Leave the environment variable empty to use the default:

uv build
# Builds package version 0.0.0dev0 (or configured fallback).

Metadata

Release files for hatch-env-plus 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hatch-env-plus 1.0.1
File Size Uploaded Provenance Actions
hatch_env_plus-1.0.1.tar.gz 7.7 kB With provenance Details for hatch_env_plus-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hatch-env-plus 1.0.1
File Interpreter ABI Platform Actions
hatch_env_plus-1.0.1-py3-none-any.whl Python 3 none any Details for hatch_env_plus-1.0.1-py3-none-any.whl

Total release size: 15.1 kB

Release files / hatch_env_plus-1.0.1.tar.gz

Download URL hatch_env_plus-1.0.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3f8aa5437746b9557384df264a0335d5fa0975661f84272780272fc5bc64da8d
BLAKE2b-256 checksum
How to use checksums
0a6b070354f08443b23970eea07f3b0a4107690c990c8ee8b3a8f7d96d7b9918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / hatch_env_plus-1.0.1-py3-none-any.whl

Download URL hatch_env_plus-1.0.1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7bfb376a8574c5c64b39ef75cd6698c6db7d16b34f785828cddbd99e7da2fd3
BLAKE2b-256 checksum
How to use checksums
7b9fad46e83914b2b0c006f57cdaba4af642e030845660915957ed60026b8d46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Security for hatch-env-plus 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hatch_env_plus-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page