Skip to main content

Add a packaging extra with pinned dependencies from a lock file

Project description

hatch-pinned-extra

License GitHub last commit PyPI - Downloads uv

Hatch plugin that adds a packaging extra to the wheel metadata with pinned dependencies from uv.lock.

Usage

# pyproject.toml
[build-system]
requires = [
    "hatchling",
    "hatch-pinned-extra>=0.0.1,<0.1.0",
]
build-backend = "hatchling.build"

[tool.hatch.metadata.hooks.pinned_extra]
name = "pinned"

If your package doesn't have any optional dependencies already, you will need to mark them as dynamic:

# pyproject.toml
[project]
dynamic = [
    "optional-dependencies",
]

Reading pinned dependencies from pylock.toml file

To use a pylock.toml file instead of uv.lock, set lockfile to the file path:

[tool.hatch.metadata.hooks.pinned_extra]
lockfile = "pylock.prod.toml"

[!NOTE] The pinned will contain ALL the dependencies in pylock.toml, so you'll want to make sure it includes only runtime or relevant dependencies, e.g. by generating it with the --no-dev flag.

[!NOTE] pylock.toml files may produce less precise environment markers than uv.lock because the pylock format does not carry the resolver's internal per-Python-version splits. For example, a uv.lock-derived pinned requirement might read anyio==4.13.0; python_full_version >= "3.13" or (python_full_version >= "3.10" and python_full_version < "3.13") while the equivalent from a pylock.toml would be anyio==4.13.0; python_full_version >= "3.10".

Enabling the Plugin

The plugin requires the HATCH_PINNED_EXTRA_ENABLE environment variable to be set to a truthy value to activate (e.g. 1, true, yes, on). 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.

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

hatch_pinned_extra-0.4.0.tar.gz (322.3 kB view details)

Uploaded Source

Built Distribution

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

hatch_pinned_extra-0.4.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file hatch_pinned_extra-0.4.0.tar.gz.

File metadata

  • Download URL: hatch_pinned_extra-0.4.0.tar.gz
  • Upload date:
  • Size: 322.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hatch_pinned_extra-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7dd4a871e41321fe23c3a3e158c670502c7afdcb4b23079a758df708d6b83d73
MD5 b5c3a31e4310fdae4a148da58f7425fd
BLAKE2b-256 da5a8b9632e7f87ee49bce3f566f1529325cfaa0520ec97de5ad81bb289ef97d

See more details on using hashes here.

Provenance

The following attestation bundles were made for hatch_pinned_extra-0.4.0.tar.gz:

Publisher: build.yaml on edgarrmondragon/hatch-pinned-extra

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

File details

Details for the file hatch_pinned_extra-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_pinned_extra-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8386c1b9934099784504bbe5ab4f0d99d3b56ef55bb6f17115971d0dc1cebc40
MD5 f97f74d2c7913b843d172c342a8befbe
BLAKE2b-256 5d0b1e1189debc743fa0e59b8af418c9b718f723a37b79860418d06a4302e7cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for hatch_pinned_extra-0.4.0-py3-none-any.whl:

Publisher: build.yaml on edgarrmondragon/hatch-pinned-extra

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