-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhatch_build.py
More file actions
51 lines (40 loc) · 1.98 KB
/
Copy pathhatch_build.py
File metadata and controls
51 lines (40 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Hatchling build hooks for the nullrun SDK.
``authors`` / ``maintainers`` injection
---------------------------------------
PEP 621 maps the ``authors`` array to PKG-INFO's ``Author-email:``
line but does NOT populate the legacy single ``Author:`` line, and
``pip show`` only renders ``Author:`` (it does not render
``Maintainer:`` at all). As a result a project whose ``authors`` is
``[{name=..., email=...}]`` ships with an empty ``Author:`` field and
the maintainer's name never appears in ``pip show``.
Hatchling makes this worse: in its ``authors`` property parser
(``hatchling/metadata/core.py``), an inline-table only contributes to
the legacy ``Author:`` field when it has a ``name`` and NO ``email``.
If both are set, the name is folded into the ``Author-email:``
display_name and the ``Author:`` line is suppressed entirely.
This hook splits the primary author into two inline-table entries so
hatchling populates both ``authors_data["name"]`` (``Author:``) and
``authors_data["email"]`` (``Author-email:``)::
Author: Anatolii Maltsev
Author-email: support@nullrun.io
It also sets ``maintainers`` to the publishing org for the PyPI
sidebar (pip does not display ``Maintainer:``).
Why ``authors`` / ``maintainers`` are listed in ``project.dynamic``:
hatchling only invokes ``MetadataHookInterface.update()`` when at
least one field is marked dynamic. Removing the static arrays and
keeping the hook as the single source of truth is what actually wires
the update call.
"""
from __future__ import annotations
from hatchling.metadata.plugin.interface import MetadataHookInterface
class CustomMetadataHook(MetadataHookInterface):
PLUGIN_NAME = "custom"
def update(self, metadata: dict) -> None:
# See module docstring for the full rationale.
metadata["authors"] = [
{"name": "Anatolii Maltsev"},
{"email": "support@nullrun.io"},
]
metadata["maintainers"] = [
{"name": "nullrun.io", "email": "support@nullrun.io"},
]