Publisher plugins¶
PublisherInterface
¶
Example usage:
from hatch.publish.plugin.interface import PublisherInterface
class SpecialPublisher(PublisherInterface):
PLUGIN_NAME = 'special'
...
from hatchling.plugin import hookimpl
from .plugin import SpecialPublisher
@hookimpl
def hatch_register_publisher():
return SpecialPublisher
Source code in hatch/publish/plugin/interface.py
class PublisherInterface(ABC):
"""
Example usage:
=== ":octicons-file-code-16: plugin.py"
```python
from hatch.publish.plugin.interface import PublisherInterface
class SpecialPublisher(PublisherInterface):
PLUGIN_NAME = 'special'
...
```
=== ":octicons-file-code-16: hooks.py"
```python
from hatchling.plugin import hookimpl
from .plugin import SpecialPublisher
@hookimpl
def hatch_register_publisher():
return SpecialPublisher
```
"""
PLUGIN_NAME = ''
"""The name used for selection."""
def __init__(self, app, root, cache_dir, project_config, plugin_config):
self.__app = app
self.__root = root
self.__cache_dir = cache_dir
self.__project_config = project_config
self.__plugin_config = plugin_config
@property
def app(self):
"""
An instance of [Application](../utilities.md#hatchling.bridge.app.Application).
"""
return self.__app
@property
def root(self):
"""
The root of the project tree as a path-like object.
"""
return self.__root
@property
def cache_dir(self):
"""
The directory reserved exclusively for this plugin as a path-like object.
"""
return self.__cache_dir
@property
def project_config(self) -> dict:
"""
=== ":octicons-file-code-16: pyproject.toml"
```toml
[tool.hatch.publish.<PLUGIN_NAME>]
```
=== ":octicons-file-code-16: hatch.toml"
```toml
[publish.<PLUGIN_NAME>]
```
"""
return self.__project_config
@property
def plugin_config(self) -> dict:
"""
This is defined in Hatch's [config file](../../config/hatch.md).
=== ":octicons-file-code-16: config.toml"
```toml
[publish.<PLUGIN_NAME>]
```
"""
return self.__plugin_config
@abstractmethod
def publish(self, artifacts: list[str], options: dict):
"""
:material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:
This is called directly by the [`publish`](../../cli/reference.md#hatch-publish) command
with the arguments and options it receives.
"""
PLUGIN_NAME = ''
class-attribute
¶
The name used for selection.
app()
property
¶
An instance of Application.
Source code in hatch/publish/plugin/interface.py
@property
def app(self):
"""
An instance of [Application](../utilities.md#hatchling.bridge.app.Application).
"""
return self.__app
root()
property
¶
The root of the project tree as a path-like object.
Source code in hatch/publish/plugin/interface.py
@property
def root(self):
"""
The root of the project tree as a path-like object.
"""
return self.__root
cache_dir()
property
¶
The directory reserved exclusively for this plugin as a path-like object.
Source code in hatch/publish/plugin/interface.py
@property
def cache_dir(self):
"""
The directory reserved exclusively for this plugin as a path-like object.
"""
return self.__cache_dir
project_config() -> dict
property
¶
[tool.hatch.publish.<PLUGIN_NAME>]
[publish.<PLUGIN_NAME>]
Source code in hatch/publish/plugin/interface.py
@property
def project_config(self) -> dict:
"""
=== ":octicons-file-code-16: pyproject.toml"
```toml
[tool.hatch.publish.<PLUGIN_NAME>]
```
=== ":octicons-file-code-16: hatch.toml"
```toml
[publish.<PLUGIN_NAME>]
```
"""
return self.__project_config
plugin_config() -> dict
property
¶
This is defined in Hatch's config file.
[publish.<PLUGIN_NAME>]
Source code in hatch/publish/plugin/interface.py
@property
def plugin_config(self) -> dict:
"""
This is defined in Hatch's [config file](../../config/hatch.md).
=== ":octicons-file-code-16: config.toml"
```toml
[publish.<PLUGIN_NAME>]
```
"""
return self.__plugin_config
publish(artifacts: list[str], options: dict)
abstractmethod
¶
REQUIRED
This is called directly by the publish
command with the arguments and options it receives.
Source code in hatch/publish/plugin/interface.py
@abstractmethod
def publish(self, artifacts: list[str], options: dict):
"""
:material-align-horizontal-left: **REQUIRED** :material-align-horizontal-right:
This is called directly by the [`publish`](../../cli/reference.md#hatch-publish) command
with the arguments and options it receives.
"""
Last update: July 2, 2022