Reference
One-screen API table for everything in tn_venv.plugins. For
narrative documentation, see the rest of this directory; for the
implementation, see Extending tn-venv.
Imports
from tn_venv.plugins import (
# Base classes
Plugin,
HookContext,
HookRegistry,
# Hooks
HookName,
# Functions
load_plugins,
parse_plugin_spec,
require_plugin,
# Provenance
PluginSource,
# Constants
PLUGIN_ENTRY_POINT, # "tn_venv.plugins"
PLUGIN_ENV_VAR, # "TN_VENV_PLUGINS"
DEFAULT_PRIORITY, # 100
# Built-ins
VersionStampPlugin,
)
The same names are re-exported from tn_venv:
from tn_venv import (
Plugin,
HookContext,
HookName,
VersionStampPlugin,
load_plugins,
)
Plugin
Member |
Signature |
Notes |
|---|---|---|
|
|
Stable identifier. Auto-assigned from class name on subclass if empty. |
|
classmethod |
Auto-fills |
|
|
Override to install listeners. Default is a no-op. |
HookContext
Field |
Type |
When populated |
|---|---|---|
|
|
every lifecycle hook |
|
|
every lifecycle hook |
|
|
only |
|
|
always; populated by the pipeline |
HookName
Member |
Value |
Fired by |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CLI |
HookRegistry
Method |
Signature |
Notes |
|---|---|---|
|
|
|
|
returns decorator or |
Two forms: |
|
returns |
Calls every listener in priority order. |
|
returns |
Concatenates every |
|
returns |
Read-only introspection. |
|
returns |
Read-only introspection. |
Internal members used by introspection (tn-venv --list-plugins):
Member |
Type |
|---|---|
|
|
|
|
|
|
PluginSource
Field |
Type |
Example |
|---|---|---|
|
|
|
|
|
|
PluginSource instances are exposed as the private
_tn_venv_source attribute on every loaded Plugin.
load_plugins
def load_plugins(
reporter: Reporter | None = None,
*,
env: dict[str, str] | None = None,
) -> HookRegistry: ...
reporter: where warnings go. Defaults toSILENT.env: an explicit env-var override. Defaults toos.environ. Passenv={}to disableTN_VENV_PLUGINSfor tests.
Returns a fresh HookRegistry populated with every successfully-loaded
plugin’s hooks. See Discovery for the full semantics.
parse_plugin_spec
def parse_plugin_spec(value: str) -> list[str]: ...
Splits a TN_VENV_PLUGINS-style value into a deduplicated list of
spec strings. Empty entries are dropped. No import is performed —
this is a pure string utility for tools and tests.
parse_plugin_spec("a:A, b:B ,a,c") # → ['a:A', 'b:B', 'c']
require_plugin
def require_plugin(name: str) -> type[Plugin]: ...
Looks up a built-in plugin class by Plugin.name. Raises
ConfigError when no built-in matches. Useful for third-party
plugins that want to integrate with a specific built-in (e.g.
decorate VersionStampPlugin’s output) without importing its
module directly.
Constants
Constant |
Value |
Where used |
|---|---|---|
|
|
the entry-point group declared in |
|
|
the env var read by |
|
|
the default |
Built-ins
VersionStampPlugin — registered as the version_stamp built-in.
Appends tn-venv-version = <version> to pyvenv.cfg after the
activation scripts have been generated. Doubles as the worked
example for new plugins — tn_venv/plugins/builtin.py is the
canonical short example of the public API.
Errors
Plugins raise their own errors (typically ConfigError from
tn_venv.errors) and the loader logs them at warning level. The
loader itself does not introduce new error types; the only
ConfigError it produces directly is from require_plugin.