Hatchling metadata hook to generate all extras
Project description
hatchling-autoextras-hook
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hatchling_autoextras_hook-0.0.1.tar.gz.
File metadata
- Download URL: hatchling_autoextras_hook-0.0.1.tar.gz
- Upload date:
- Size: 71.6 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":"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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ae915da152a3eaad8589407548f9c0f2ed9eff71685ca3b7bd0d5b2a83d1562
|
|
| MD5 |
2f990b27c191644ecef9b38cc4be2fac
|
|
| BLAKE2b-256 |
e47d4ae8641962fc32a72bcd29378ae7446b401fe290195d69eb59626fba5ad8
|
File details
Details for the file hatchling_autoextras_hook-0.0.1-py3-none-any.whl.
File metadata
- Download URL: hatchling_autoextras_hook-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 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":"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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fed4f804a38930be3548153b83667185246c7e16fa3a66fd69965d54f260007b
|
|
| MD5 |
0b3a54df0afc51928880ef36fabf6740
|
|
| BLAKE2b-256 |
921149dc15e9647828a0584c6eaf5ad798fb9aaff3a305408edc82c9c7188e79
|