roborean-plugins-base 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ """Plugin manifests and installed-package discovery."""
2
+
3
+ from .entry_points import load_bit_type_entry_points
4
+ from .manifest import PluginManifest, TrustTier
5
+
6
+ __version__ = "0.2.0"
7
+
8
+ __all__ = [
9
+ "PluginManifest",
10
+ "TrustTier",
11
+ "load_bit_type_entry_points",
12
+ ]
@@ -0,0 +1,68 @@
1
+ """Discover bit types advertised through package entry points."""
2
+
3
+ import logging
4
+ import os
5
+ from importlib.metadata import entry_points
6
+ from typing import Any
7
+
8
+ from .manifest import PluginManifest, TrustTier
9
+
10
+ logger = logging.getLogger(__name__)
11
+
12
+ BIT_TYPES_GROUP = "roborean.bit_types"
13
+
14
+
15
+ def load_bit_type_entry_points(
16
+ *,
17
+ allow_third_party: bool | None = None,
18
+ ) -> list[tuple[PluginManifest, Any]]:
19
+ """Load bit-type factories from installed entry points.
20
+
21
+ Each entry point should resolve to a zero-arg callable that returns
22
+ ``(BitTypeManifest, BitHandler)`` or an object with ``manifest`` and
23
+ ``handler`` attributes.
24
+ """
25
+ if allow_third_party is None:
26
+ allow_third_party = os.environ.get(
27
+ "ROBOREAN_ALLOW_THIRD_PARTY_PLUGINS", ""
28
+ ) in {"1", "true", "TRUE"}
29
+
30
+ selected = entry_points()
31
+ group = selected.select(group=BIT_TYPES_GROUP)
32
+ loaded: list[tuple[PluginManifest, Any]] = []
33
+
34
+ # Load each advertised factory, skipping disallowed trust tiers.
35
+ for item in group:
36
+ try:
37
+ factory = item.load()
38
+ payload = factory() if callable(factory) else factory
39
+ if hasattr(payload, "manifest") and hasattr(payload, "handler"):
40
+ bit_manifest = payload.manifest
41
+ handler = payload.handler
42
+ else:
43
+ bit_manifest, handler = payload
44
+ trust = TrustTier.CORE
45
+ if hasattr(payload, "trust_tier"):
46
+ trust = TrustTier(payload.trust_tier)
47
+ if trust == TrustTier.THIRD_PARTY and not allow_third_party:
48
+ logger.debug(
49
+ "Skipping third-party bit type %s",
50
+ item.name,
51
+ )
52
+ continue
53
+ plugin = PluginManifest(
54
+ id=bit_manifest.type_id,
55
+ version=bit_manifest.version,
56
+ kind="bit-type",
57
+ capabilities=frozenset(bit_manifest.capabilities),
58
+ trust_tier=trust,
59
+ effect_class=bit_manifest.effect_class,
60
+ )
61
+ loaded.append((plugin, (bit_manifest, handler)))
62
+ except Exception:
63
+ logger.debug(
64
+ "Failed loading bit type entry point %s",
65
+ item.name,
66
+ exc_info=True,
67
+ )
68
+ return loaded
@@ -0,0 +1,28 @@
1
+ """Installed plugin manifest types."""
2
+
3
+ from dataclasses import dataclass
4
+ from enum import Enum
5
+ from typing import Literal
6
+
7
+ from roborean_spec import EffectClass
8
+
9
+
10
+ class TrustTier(str, Enum):
11
+ """Trust classification for installed plugins."""
12
+
13
+ CORE = "core"
14
+ INTERNAL = "internal"
15
+ THIRD_PARTY = "third_party"
16
+ DEV = "dev"
17
+
18
+
19
+ @dataclass(frozen=True)
20
+ class PluginManifest:
21
+ """Describes one installed plugin package contribution."""
22
+
23
+ id: str
24
+ version: str
25
+ kind: Literal["bit-type", "document-driver"]
26
+ capabilities: frozenset[str]
27
+ trust_tier: TrustTier
28
+ effect_class: EffectClass | None = None
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: roborean-plugins-base
3
+ Version: 0.1.2
4
+ Summary: Plugin manifests and entry-point discovery for Roborean
5
+ Project-URL: Homepage, https://github.com/TNick/roborean
6
+ Project-URL: Repository, https://github.com/TNick/roborean
7
+ License-Expression: MIT
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: roborean-spec>=0.1.1
10
+ Provides-Extra: dev
11
+ Requires-Dist: black>=24.0; extra == 'dev'
12
+ Requires-Dist: flake8>=7.0; extra == 'dev'
13
+ Requires-Dist: isort>=5.0; extra == 'dev'
14
+ Requires-Dist: pytest>=8.0; extra == 'dev'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # roborean-plugins-base
18
+
19
+ Plugin manifests and `importlib.metadata` entry-point discovery for installed
20
+ bit types (`roborean.bit_types`).
21
+
22
+ Third-party entry points are ignored unless
23
+ `ROBOREAN_ALLOW_THIRD_PARTY_PLUGINS=1`.
@@ -0,0 +1,6 @@
1
+ roborean_plugins_base/__init__.py,sha256=G4nAW6daMbbADRdjh57uVy7PJXr_HhOYU-y5paS4WEI,269
2
+ roborean_plugins_base/entry_points.py,sha256=tYnUmdL_lejYpBuk8LM3e3fkGfOpHJ6IVwsHtfq0V6M,2346
3
+ roborean_plugins_base/manifest.py,sha256=Qq1xFcKtd1CIYit67STQmFnFVYpnsaYtsWzx8ULXDbU,632
4
+ roborean_plugins_base-0.1.2.dist-info/METADATA,sha256=n7sBUj9et2uNA-h5ENo-jn8mFpPfEmo7BUm6rMbg9y4,784
5
+ roborean_plugins_base-0.1.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
6
+ roborean_plugins_base-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any