| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from abc import ABC, abstractmethod |
| 4 |
from pathlib import Path |
| 5 |
from typing import TYPE_CHECKING, Protocol, runtime_checkable |
| 6 |
|
| 7 |
if TYPE_CHECKING: |
| 8 |
from briefcase.config import AppConfig |
| 9 |
from briefcase.console import Console |
| 10 |
from briefcase.integrations.base import ToolCache |
| 11 |
|
| 12 |
|
| 13 |
@runtime_checkable |
| 14 |
class PublishCommandAPI(Protocol): |
| 15 |
"""Stable API surface exposed to publication channel plugins. |
| 16 |
|
| 17 |
This defines the minimal set of attributes and methods that a plugin |
| 18 |
can rely on from the ``command`` parameter passed to ``publish_app()``. |
| 19 |
""" |
| 20 |
|
| 21 |
console: Console |
| 22 |
tools: ToolCache |
| 23 |
dist_path: Path |
| 24 |
|
| 25 |
def distribution_path(self, app: AppConfig) -> Path: ... |
| 26 |
|
| 27 |
|
| 28 |
class BasePublicationChannel(ABC): |
| 29 |
"""Definition for a plugin that defines a new Briefcase publication channel.""" |
| 30 |
|
| 31 |
@property |
| 32 |
@abstractmethod |
| 33 |
def name(self) -> str: |
| 34 |
"""The name of the publication channel.""" |
| 35 |
|
| 36 |
@abstractmethod |
| 37 |
def publish_app(self, app: AppConfig, command: PublishCommandAPI, **options): |
| 38 |
"""Publish an application to this channel. |
| 39 |
|
| 40 |
:param app: The application to publish |
| 41 |
:param command: The publish command instance |
| 42 |
""" |