hatchling-autoextras-hook 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hatchling_autoextras_hook/__init__.py +7 -0
- hatchling_autoextras_hook/hooks.py +64 -0
- hatchling_autoextras_hook-0.0.1.dist-info/METADATA +188 -0
- hatchling_autoextras_hook-0.0.1.dist-info/RECORD +7 -0
- hatchling_autoextras_hook-0.0.1.dist-info/WHEEL +4 -0
- hatchling_autoextras_hook-0.0.1.dist-info/entry_points.txt +2 -0
- hatchling_autoextras_hook-0.0.1.dist-info/licenses/LICENSE +28 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Hatchling metadata hook to automatically generate 'all' extras."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
|
6
|
+
from hatchling.plugin import hookimpl
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AutoExtrasMetadataHook(MetadataHookInterface):
|
|
10
|
+
"""Metadata hook that automatically generates an 'all' extra.
|
|
11
|
+
|
|
12
|
+
This hook collects all optional dependencies defined in the project
|
|
13
|
+
and creates an 'all' extra that includes all of them.
|
|
14
|
+
|
|
15
|
+
Example usage:
|
|
16
|
+
|
|
17
|
+
```pycon
|
|
18
|
+
|
|
19
|
+
>>> from hatchling_autoextras_hook.hooks import AutoExtrasMetadataHook
|
|
20
|
+
>>> metadata = {
|
|
21
|
+
... "optional-dependencies": {
|
|
22
|
+
... "dev": ["pytest>=7.0", "black>=22.0"],
|
|
23
|
+
... }
|
|
24
|
+
... }
|
|
25
|
+
>>> AutoExtrasMetadataHook("test", {}).update(metadata)
|
|
26
|
+
>>> metadata
|
|
27
|
+
{'optional-dependencies': {'dev': ['pytest>=7.0', 'black>=22.0'],
|
|
28
|
+
'all': ['black>=22.0', 'pytest>=7.0']}}
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
PLUGIN_NAME = "autoextras"
|
|
34
|
+
|
|
35
|
+
def update(self, metadata: dict) -> None:
|
|
36
|
+
"""Update the project metadata to add the 'all' extra.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
metadata: The project metadata dictionary to update.
|
|
40
|
+
"""
|
|
41
|
+
# Get optional dependencies
|
|
42
|
+
optional_dependencies = metadata.get("optional-dependencies", {})
|
|
43
|
+
|
|
44
|
+
if not optional_dependencies:
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
# Collect all dependencies from all extras (except 'all' if it already exists)
|
|
48
|
+
all_deps = set()
|
|
49
|
+
for extra_name, deps in optional_dependencies.items():
|
|
50
|
+
if extra_name != "all":
|
|
51
|
+
all_deps.update(deps)
|
|
52
|
+
|
|
53
|
+
# Sort for consistent output
|
|
54
|
+
all_deps_sorted = sorted(all_deps)
|
|
55
|
+
|
|
56
|
+
# Add or update the 'all' extra
|
|
57
|
+
optional_dependencies["all"] = all_deps_sorted
|
|
58
|
+
metadata["optional-dependencies"] = optional_dependencies
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@hookimpl
|
|
62
|
+
def hatch_register_metadata_hook() -> type[MetadataHookInterface]:
|
|
63
|
+
"""Register the autoextras metadata hook with hatchling."""
|
|
64
|
+
return AutoExtrasMetadataHook
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hatchling-autoextras-hook
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Hatchling metadata hook to generate all extras
|
|
5
|
+
Project-URL: homepage, https://github.com/durandtibo/hatchling-autoextras-hook
|
|
6
|
+
Project-URL: repository, https://github.com/durandtibo/hatchling-autoextras-hook
|
|
7
|
+
Project-URL: documentation, https://durandtibo.github.io/hatchling-autoextras-hook/
|
|
8
|
+
Author-email: Thibaut Durand <durand.tibo+gh@gmail.com>
|
|
9
|
+
License-Expression: BSD-3-Clause
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Requires-Dist: hatchling<2.0,>=1.18
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# hatchling-autoextras-hook
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://github.com/durandtibo/hatchling-autoextras-hook/actions">
|
|
19
|
+
<img alt="CI" src="https://github.com/durandtibo/hatchling-autoextras-hook/workflows/CI/badge.svg">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://github.com/durandtibo/hatchling-autoextras-hook/actions">
|
|
22
|
+
<img alt="Nightly Tests" src="https://github.com/durandtibo/hatchling-autoextras-hook/workflows/Nightly%20Tests/badge.svg">
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://github.com/durandtibo/hatchling-autoextras-hook/actions">
|
|
25
|
+
<img alt="Nightly Package Tests" src="https://github.com/durandtibo/hatchling-autoextras-hook/workflows/Nightly%20Package%20Tests/badge.svg">
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://codecov.io/gh/durandtibo/hatchling-autoextras-hook">
|
|
28
|
+
<img alt="Codecov" src="https://codecov.io/gh/durandtibo/hatchling-autoextras-hook/branch/main/graph/badge.svg">
|
|
29
|
+
</a>
|
|
30
|
+
<br/>
|
|
31
|
+
<a href="https://durandtibo.github.io/hatchling-autoextras-hook/">
|
|
32
|
+
<img alt="Documentation" src="https://github.com/durandtibo/hatchling-autoextras-hook/workflows/Documentation%20(stable)/badge.svg">
|
|
33
|
+
</a>
|
|
34
|
+
<a href="https://durandtibo.github.io/hatchling-autoextras-hook/">
|
|
35
|
+
<img alt="Documentation" src="https://github.com/durandtibo/hatchling-autoextras-hook/workflows/Documentation%20(unstable)/badge.svg">
|
|
36
|
+
</a>
|
|
37
|
+
<br/>
|
|
38
|
+
<a href="https://github.com/psf/black">
|
|
39
|
+
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg">
|
|
40
|
+
</a>
|
|
41
|
+
<a href="https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings">
|
|
42
|
+
<img alt="Doc style: google" src="https://img.shields.io/badge/%20style-google-3666d6.svg">
|
|
43
|
+
</a>
|
|
44
|
+
<a href="https://github.com/astral-sh/ruff">
|
|
45
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff" style="max-width:100%;">
|
|
46
|
+
</a>
|
|
47
|
+
<a href="https://github.com/guilatrova/tryceratops">
|
|
48
|
+
<img alt="Doc style: google" src="https://img.shields.io/badge/try%2Fexcept%20style-tryceratops%20%F0%9F%A6%96%E2%9C%A8-black">
|
|
49
|
+
</a>
|
|
50
|
+
<br/>
|
|
51
|
+
<a href="https://pypi.org/project/hatchling-autoextras-hook/">
|
|
52
|
+
<img alt="PYPI version" src="https://img.shields.io/pypi/v/hatchling-autoextras-hook">
|
|
53
|
+
</a>
|
|
54
|
+
<a href="https://pypi.org/project/hatchling-autoextras-hook/">
|
|
55
|
+
<img alt="Python" src="https://img.shields.io/pypi/pyversions/hatchling-autoextras-hook.svg">
|
|
56
|
+
</a>
|
|
57
|
+
<a href="https://opensource.org/licenses/BSD-3-Clause">
|
|
58
|
+
<img alt="BSD-3-Clause" src="https://img.shields.io/pypi/l/hatchling-autoextras-hook">
|
|
59
|
+
</a>
|
|
60
|
+
<br/>
|
|
61
|
+
<a href="https://pepy.tech/project/hatchling-autoextras-hook">
|
|
62
|
+
<img alt="Downloads" src="https://static.pepy.tech/badge/hatchling-autoextras-hook">
|
|
63
|
+
</a>
|
|
64
|
+
<a href="https://pepy.tech/project/hatchling-autoextras-hook">
|
|
65
|
+
<img alt="Monthly downloads" src="https://static.pepy.tech/badge/hatchling-autoextras-hook/month">
|
|
66
|
+
</a>
|
|
67
|
+
<br/>
|
|
68
|
+
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
Hatchling metadata hook to automatically generate an `all` extra that combines all optional
|
|
72
|
+
dependencies.
|
|
73
|
+
|
|
74
|
+
## Overview
|
|
75
|
+
|
|
76
|
+
This package provides a Hatchling metadata hook that automatically creates an `all` extra in your
|
|
77
|
+
project's optional dependencies. The `all` extra will contain all dependencies from all other
|
|
78
|
+
extras, making it easy for users to install all optional features at once.
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
Add this package as a build dependency in your `pyproject.toml`:
|
|
83
|
+
|
|
84
|
+
```toml
|
|
85
|
+
[build-system]
|
|
86
|
+
requires = ["hatchling>=1.18.0", "hatchling-autoextras-hook"]
|
|
87
|
+
build-backend = "hatchling.build"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
Enable the hook in your `pyproject.toml`:
|
|
93
|
+
|
|
94
|
+
```toml
|
|
95
|
+
[tool.hatch.metadata.hooks.autoextras]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Important**: Hatchling metadata hooks are only triggered when there is at least one dynamic field
|
|
99
|
+
in your project metadata. If you don't already have any dynamic fields, you can add `version` as a
|
|
100
|
+
dynamic field:
|
|
101
|
+
|
|
102
|
+
```toml
|
|
103
|
+
[project]
|
|
104
|
+
name = "your-package"
|
|
105
|
+
dynamic = ["version"]
|
|
106
|
+
|
|
107
|
+
[tool.hatch.version]
|
|
108
|
+
path = "src/your_package/__init__.py"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Then add `__version__ = "x.y.z"` to your `__init__.py` file.
|
|
112
|
+
|
|
113
|
+
### Example
|
|
114
|
+
|
|
115
|
+
Given this configuration:
|
|
116
|
+
|
|
117
|
+
```toml
|
|
118
|
+
[project]
|
|
119
|
+
name = "my-package"
|
|
120
|
+
dynamic = ["version"]
|
|
121
|
+
|
|
122
|
+
[project.optional-dependencies]
|
|
123
|
+
dev = ["pytest>=7.0", "black>=22.0"]
|
|
124
|
+
docs = ["sphinx>=5.0", "sphinx-rtd-theme>=1.0"]
|
|
125
|
+
typing = ["mypy>=1.0"]
|
|
126
|
+
|
|
127
|
+
[tool.hatch.version]
|
|
128
|
+
path = "src/my_package/__init__.py"
|
|
129
|
+
|
|
130
|
+
[tool.hatch.metadata.hooks.autoextras]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The hook will automatically generate an `all` extra combining all dependencies:
|
|
134
|
+
|
|
135
|
+
```toml
|
|
136
|
+
[project.optional-dependencies]
|
|
137
|
+
all = [
|
|
138
|
+
"black>=22.0",
|
|
139
|
+
"mypy>=1.0",
|
|
140
|
+
"pytest>=7.0",
|
|
141
|
+
"sphinx-rtd-theme>=1.0",
|
|
142
|
+
"sphinx>=5.0",
|
|
143
|
+
]
|
|
144
|
+
# ... dev, docs, typing remain unchanged
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Users can then install all optional dependencies with:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
pip install your-package[all]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Features
|
|
154
|
+
|
|
155
|
+
- Automatically combines all optional dependencies
|
|
156
|
+
- Removes duplicates across extras
|
|
157
|
+
- Sorts dependencies alphabetically for consistency
|
|
158
|
+
- Works seamlessly with the Hatchling build system
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
This project uses `uv` for dependency management.
|
|
163
|
+
|
|
164
|
+
### Setup
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Install uv
|
|
168
|
+
pip install uv
|
|
169
|
+
|
|
170
|
+
# Install dependencies
|
|
171
|
+
uv sync
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Running Tests
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
uv run pytest
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Dependencies
|
|
181
|
+
|
|
182
|
+
| `batcharray` | `hatchling` | `python` |
|
|
183
|
+
|--------------|---------------|----------------|
|
|
184
|
+
| `main` | `>=1.18,<2.0` | `>=3.10,<3.15` |
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
See LICENSE file for details.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
hatchling_autoextras_hook/__init__.py,sha256=zFYpAULhoC7xb6YTTieqmFWtXljioYbCVI6t1ZvUB1Q,212
|
|
2
|
+
hatchling_autoextras_hook/hooks.py,sha256=fHZEIqTjFIRke2RJW3Y0AGcEXcurdVI7lNQ7rrmaNc8,1997
|
|
3
|
+
hatchling_autoextras_hook-0.0.1.dist-info/METADATA,sha256=eVUa1i7Sz5QpKDL_tD9nGSVPKuhKY-IwYQYIxVqsuZI,6080
|
|
4
|
+
hatchling_autoextras_hook-0.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
+
hatchling_autoextras_hook-0.0.1.dist-info/entry_points.txt,sha256=bDjOi6AHGw6WdcChJ0EY-tcZSCAD4LObJCYIxo8PpTw,53
|
|
6
|
+
hatchling_autoextras_hook-0.0.1.dist-info/licenses/LICENSE,sha256=vpSWJAV9Wfa6wuEUGvLoJUBFO8jKugvbime1BfQVvEY,1501
|
|
7
|
+
hatchling_autoextras_hook-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Thibaut Durand
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|