Metadata hook plugins¶メタデータフックプラグイン¶
Metadata hooks allow for the modification of project metadata after it has been loaded.メタデータフックは、プロジェクトメタデータが読み込まれた後にその修正を可能にします。
Known third-party¶既知のサードパーティ¶
- hatch-docstring-description - set the project description using docstringshatch-docstring-description - ドクストリングを使用してプロジェクトの説明を設定します
- hatch-fancy-pypi-readme - dynamically construct the READMEhatch-fancy-pypi-readme - READMEを動的に構築します
- hatch-nodejs-version - uses fields from NodeJS
package.jsonfileshatch-nodejs-version - NodeJSのpackage.jsonファイルからフィールドを使用します - hatch-odoo - determine dependencies based on manifests of Odoo add-onshatch-odoo - Odooアドオンのマニフェストに基づいて依存関係を決定します
- hatch-requirements-txt - read project dependencies from
requirements.txtfileshatch-requirements-txt -requirements.txtファイルからプロジェクトの依存関係を読み取ります - UniDep - for unified
pipandcondadependency management using a singlerequirements.yamlfile for both UniDep - 両方のための単一のrequirements.yamlファイルを使用した統一されたpipとcondaの依存関係管理
MetadataHookInterface ¶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 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 ¶PLUGIN_NAME = '' class-attribute instance-attribute ¶
The name used for selection.選択に使用される名前。
config: dict property ¶config: dict property ¶
The hook configuration.フックの設定。
[tool.hatch.metadata.hooks.<PLUGIN_NAME>]
[metadata.hooks.<PLUGIN_NAME>]
update(metadata: dict) -> None abstractmethod ¶update(metadata: dict) -> None abstractmethod ¶
This updates the metadata mapping of the project table in-place.これは、projectテーブルのメタデータマッピングをその場で更新します。
Source code in 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] ¶get_known_classifiers() -> list[str] ¶
This returns extra classifiers that should be considered valid in addition to the ones known to PyPI.これは、PyPIに知られているものに加えて、有効と見なされるべき追加の分類子を返します。
Source code in 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 []