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
0.0.1 >=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.2.tar.gz (7.8 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.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file hatchling_autoextras_hook-0.0.2.tar.gz.

File metadata

  • Download URL: hatchling_autoextras_hook-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hatchling_autoextras_hook-0.0.2.tar.gz
Algorithm Hash digest
SHA256 72783af2e66577bf222f81b6575af426d1510fb6a6b15bf3f6adaf5bbe82bfac
MD5 6c6d916c6017052f71b062270bb3174a
BLAKE2b-256 c7effb06809c4f36213daaa11a29e4e8f899e85632bdd4c3bee1d95ee26ff0f1

See more details on using hashes here.

File details

Details for the file hatchling_autoextras_hook-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: hatchling_autoextras_hook-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hatchling_autoextras_hook-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f11b7711434311203d7147414c73beae396d92436de0abf542a7eed8e894e71
MD5 eef91d2482e435bbd83a61adda0714e6
BLAKE2b-256 35f449cfc44796587b28481ba6b5c9875bc1f30976b05b87880b0782d75a388a

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