Skip to main content

Hatchling metadata hook to generate all extras

Project description

hatchling-autoextras-hook

CI Nightly Tests Nightly Package Tests Codecov
Documentation Documentation
Code style: black Doc style: google Ruff Doc style: google
PYPI version Python BSD-3-Clause
Downloads Monthly downloads

Hatchling metadata hook to automatically generate an all extra that combines all optional dependencies.

Overview

This package provides a Hatchling metadata hook that automatically creates an all extra in your project's optional dependencies. The all extra will contain all dependencies from all other extras, making it easy for users to install all optional features at once.

Installation

Add this package as a build dependency in your pyproject.toml:

[build-system]
requires = ["hatchling>=1.18.0", "hatchling-autoextras-hook"]
build-backend = "hatchling.build"

Usage

Enable the hook in your pyproject.toml:

[tool.hatch.metadata.hooks.autoextras]

Important: Hatchling metadata hooks are only triggered when there is at least one dynamic field in your project metadata. If you don't already have any dynamic fields, you can add version as a dynamic field:

[project]
name = "your-package"
dynamic = ["version"]

[tool.hatch.version]
path = "src/your_package/__init__.py"

Then add __version__ = "x.y.z" to your __init__.py file.

Example

Given this configuration:

[project]
name = "my-package"
dynamic = ["version"]

[project.optional-dependencies]
dev = ["pytest>=7.0", "black>=22.0"]
docs = ["sphinx>=5.0", "sphinx-rtd-theme>=1.0"]
typing = ["mypy>=1.0"]

[tool.hatch.version]
path = "src/my_package/__init__.py"

[tool.hatch.metadata.hooks.autoextras]

The hook will automatically generate an all extra combining all dependencies:

[project.optional-dependencies]
all = [
    "black>=22.0",
    "mypy>=1.0",
    "pytest>=7.0",
    "sphinx-rtd-theme>=1.0",
    "sphinx>=5.0",
]
# ... dev, docs, typing remain unchanged

Users can then install all optional dependencies with:

pip install your-package[all]

Features

  • Automatically combines all optional dependencies
  • Removes duplicates across extras
  • Sorts dependencies alphabetically for consistency
  • Works seamlessly with the Hatchling build system

Development

This project uses uv for dependency management.

Setup

# Install uv
pip install uv

# Install dependencies
uv sync

Running Tests

uv run pytest

Dependencies

batcharray hatchling python
main >=1.18,<2.0 >=3.10,<3.15

License

See LICENSE file for details.

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

hatchling_autoextras_hook-0.0.1a0.tar.gz (73.9 kB view details)

Uploaded Source

Built Distribution

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

hatchling_autoextras_hook-0.0.1a0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file hatchling_autoextras_hook-0.0.1a0.tar.gz.

File metadata

  • Download URL: hatchling_autoextras_hook-0.0.1a0.tar.gz
  • Upload date:
  • Size: 73.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hatchling_autoextras_hook-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 7a850be6cd2b6e8e35f2614635d25994126ab30f529317073bf48e849b2b634f
MD5 86088a1fa7186b24ba741eff0134c8e9
BLAKE2b-256 ad6d1ab113ea603158f73b014f1b6f2541ee8dd1135331de0e31e655ed8559ec

See more details on using hashes here.

File details

Details for the file hatchling_autoextras_hook-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: hatchling_autoextras_hook-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hatchling_autoextras_hook-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 94ebb78651affc03ad9c481a3a8a91ece8faebb1c6571c33296acbb023ff6276
MD5 7b4d2a6dac466223ea79130369467588
BLAKE2b-256 d1180813428fc7f451110b36768c962c3e8ca19d89ca4d33fdb64aec9ef4e841

See more details on using hashes here.

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