hatch-pinned-extra
Hatch plugin that adds a pinned packaging extra to the core metadata with pinned dependencies from uv.lock or pylock.toml.
Contents
Requirements
- Python 3.10+
- Hatchling 1.27+
- For
uv.lock: a version 1 lockfile. It is the version used in tests, so a future lockfile version may not work with this plugin. - For
pylock.toml: a compliant lockfile.
Usage
# pyproject.toml
[build-system]
requires = [
"hatchling",
"hatch-pinned-extra>=0.4.0,<1",
]
build-backend = "hatchling.build"
# Leaving this empty is fine, as it registers the plugin
# and will result in using the default settings
[tool.hatch.metadata.hooks.pinned_extra]
The plugin needs optional-dependencies to be declared as dynamic:
# pyproject.toml
[project]
dynamic = [
"optional-dependencies",
]
Dynamic dependencies
If dependencies is also dynamic, because another metadata hook provides it, list that hook before this one. Hatchling runs metadata hooks in the order of their tables in pyproject.toml, so a hook listed later hasn't run yet when this plugin reads dependencies.
# pyproject.toml
[tool.hatch.metadata.hooks.another_dependencies_hook] # provides `dependencies`
foo = "bar"
[tool.hatch.metadata.hooks.pinned_extra]
If dependencies is still unset when this plugin runs, it falls back to the dependencies of the project recorded in uv.lock. pylock.toml files don't need them, since the pinned extra contains everything in the file.
Combining static and dynamic optional dependencies
Configuration
-
extra-name: the name users will include when installing the package, e.g.pip install my-package[<extra-name>]. Defaults topinned. -
lockfile: path to the lockfile, relative to the project root. Defaults touv.lock, which must be at the project root.pylock.*.tomlfiles are also supported, and may be in a subdirectory.When the plugin is enabled, the build fails if the lockfile doesn't exist or isn't a
uv.lockorpylock.*.tomlfile.
Enabling the plugin at build time
The plugin requires the HATCH_PINNED_EXTRA_ENABLE environment variable to be set to a truthy value (e.g. 1, true, yes, on) to activate. This design allows you to control when pinned dependencies are included:
# Build with pinned dependencies
HATCH_PINNED_EXTRA_ENABLE=1 uv build
# Update lockfile without constraints from pinned dependencies
uv lock --upgrade
This approach solves the circular dependency issue where pinned dependencies become constraints during uv lock --upgrade, preventing actual upgrades.
If HATCH_PINNED_EXTRA_ENABLE is not set, the plugin will emit a UserWarning and skip the extra. Some build frontends may surface this warning to you:
$ uvx --with build python -m build . --wheel
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
- hatch_pinned_extra
- hatchling
* Getting build dependencies for wheel...
* Installed build dependency versions:
- hatch-pinned-extra==0.4.1
- hatchling==1.33.0
* Building wheel...
WARNING HATCH_PINNED_EXTRA_ENABLE is not set, pinned extra is disabled
Successfully built project-0.1.0-py3-none-any.whl
Reading pinned dependencies from pylock.toml file
To use a pylock.toml file instead of uv.lock, configure lockfile:
[tool.hatch.metadata.hooks.pinned_extra]
lockfile = "pylock.prod.toml"
Limitations
-
Combining this plugin with static
optional-dependencies. See the note above above regarding PEP 808 support in Hatchling. -
For
pylock.toml, thepinnedextra will contain all the dependencies inpylock.toml, so you'll want to make sure it includes only runtime or relevant dependencies, e.g. by generating it withuv export --format pylock.toml --no-dev. -
pylock.tomlfiles may produce less precise environment markers thanuv.lockbecause some producers may not add the resolver's internal per-Python-version splits.For example, a
uv.lock-derived pinned requirement might readanyio==4.13.0; python_full_version >= "3.13" or (python_full_version >= "3.10" and python_full_version < "3.13"), while the equivalent from apylock.tomlcould beanyio==4.13.0; python_full_version >= "3.10".
Metadata
Release files for hatch-pinned-extra 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hatch_pinned_extra-0.5.0.tar.gz | 580.5 kB | With provenance | Details for hatch_pinned_extra-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hatch_pinned_extra-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for hatch_pinned_extra-0.5.0-py3-none-any.whl |
Total release size: 595.6 kB
Release files / hatch_pinned_extra-0.5.0.tar.gz
| Download URL | hatch_pinned_extra-0.5.0.tar.gz |
|---|---|
| Size | 580.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b769edc93fc4c199f1c3c046115f1a33a3e9a0f64a4d4dfa3dc8a1dbb086f31
|
|
BLAKE2b-256 checksum How to use checksums |
7aeb5e014ecc29844bc4328e00a2dc120407555519fcd9b7c3099cc476d55403
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / hatch_pinned_extra-0.5.0-py3-none-any.whl
| Download URL | hatch_pinned_extra-0.5.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58ae4904db03228ee2551f61970159b0fb10e786c650110b81e4fda914862ba3
|
|
BLAKE2b-256 checksum How to use checksums |
bb97c03e969e6d4358cea3cd54f7d559cb699fef6fc01d07389e40cd28b67673
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logSecurity for hatch-pinned-extra 0.5.0
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
Both files in this release have been uploaded with provenance metadata.
Attestation for hatch_pinned_extra-0.5.0.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 Nov 3, 2026.
Transparency logA 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.