Metadata hook plugins¶
メタデータフックを使用すると、ロード後にプロジェクトメタデータを変更できます。
Known third-party¶
- hatch-docstring-description - docstringsを使用してプロジェクトの説明を設定する
- hatch-fancy-pypi-readme - READMEを動的に作成する
- hatch-NodeJS-version - NodeJS
package.json
ファイルのフィールドを使用します。 - hatch-odoo - Odooアドオンのマニフェストに基づいて依存関係を決定する
- hatch-requirements-txt -
requirements.txt
ファイルからプロジェクトの依存関係を読み取ります - UniDep - 両方に対して単一の
requirements.yaml
ファイルを使用して、統合されたpip
とconda
の依存関係管理のため
MetadataHookInterface
¶
Example usage:
from hatchling.metadata.plugin.interface import MetadataHookInterface
class SpecialMetadataHook(MetadataHookInterface):
PLUGIN_NAME = 'special'
...
from hatchling.plugin import hookimpl
from .plugin import SpecialMetadataHook
@hookimpl
def hatch_register_metadata_hook():
return SpecialMetadataHook
Source code in backend/src/hatchling/metadata/plugin/interface.py
class MetadataHookInterface(ABC): # no cov
"""
Example usage:
```python tab="plugin.py"
from hatchling.metadata.plugin.interface import MetadataHookInterface
class SpecialMetadataHook(MetadataHookInterface):
PLUGIN_NAME = 'special'
...
```
```python tab="hooks.py"
from hatchling.plugin import hookimpl
from .plugin import SpecialMetadataHook
@hookimpl
def hatch_register_metadata_hook():
return SpecialMetadataHook
```
"""
PLUGIN_NAME = ''
"""The name used for selection."""
def __init__(self, root: str, config: dict) -> None:
self.__root = root
self.__config = config
@property
def root(self) -> str:
"""
The root of the project tree.
"""
return self.__root
@property
def config(self) -> dict:
"""
The hook configuration.
```toml config-example
[tool.hatch.metadata.hooks.<PLUGIN_NAME>]
```
"""
return self.__config
@abstractmethod
def update(self, metadata: dict) -> None:
"""
This updates the metadata mapping of the `project` table in-place.
"""
def get_known_classifiers(self) -> list[str]: # noqa: PLR6301
"""
This returns extra classifiers that should be considered valid in addition to the ones known to PyPI.
"""
return []
PLUGIN_NAME = ''
class-attribute
instance-attribute
¶
The name used for selection.
root: str
property
¶
The root of the project tree.
config: dict
property
¶
The hook configuration.
[tool.hatch.metadata.hooks.<PLUGIN_NAME>]
[metadata.hooks.<PLUGIN_NAME>]
update(metadata: dict) -> None
abstractmethod
¶
This updates the metadata mapping of the project
table in-place.
Source code in backend/src/hatchling/metadata/plugin/interface.py
@abstractmethod
def update(self, metadata: dict) -> None:
"""
This updates the metadata mapping of the `project` table in-place.
"""
get_known_classifiers() -> list[str]
¶
This returns extra classifiers that should be considered valid in addition to the ones known to PyPI.
Source code in backend/src/hatchling/metadata/plugin/interface.py
def get_known_classifiers(self) -> list[str]: # noqa: PLR6301
"""
This returns extra classifiers that should be considered valid in addition to the ones known to PyPI.
"""
return []