Documentation Index
Fetch the complete documentation index at: https://mintlify.com/conda/conda/llms.txt
Use this file to discover all available pages before exploring further.
What is the Plugin System?
Conda’s plugin system allows developers to extend conda’s functionality through a standardized plugin architecture. It provides a way to:- Register custom solvers
- Add new subcommands
- Define virtual packages
- Hook into pre/post command execution
- Customize authentication handlers
- Add health checks for
conda doctor - Extend transaction actions
- Register custom settings
- Define custom reporter backends
- Add HTTP request headers
Plugin Architecture
The plugin system consists of three main components:1. Hook Specifications (hookspecs)
Defined in theCondaSpecs class, these are the available plugin hooks that conda provides. Each hookspec defines what kind of plugin can be registered and what it should return.
See Hook Specifications for all available hooks.
2. Plugin Types
These are typed return values that plugins must use when implementing hooks. Each type corresponds to a specific hook. See Plugin Types for all available types.3. Plugin Manager
TheCondaPluginManager class manages plugin registration, loading, and execution. It extends pluggy’s PluginManager with conda-specific functionality.
How to Create a Plugin
Implement Your Plugin Function
Create a function that implements your plugin logic. The function should yield one or more plugin type instances:
Decorate with @hookimpl
Use the
@plugins.hookimpl decorator and name your function according to the hook specification you’re implementing:Complete Example
Here’s a complete example of a plugin that adds a custom subcommand:my_conda_plugin/plugin.py
setup.py
Plugin Entry Points
Entry Point Group
All conda plugins must be registered under the"conda" entry point group.
Loading Mechanism
Plugins are loaded during conda’s startup process through theget_plugin_manager() function:
- Built-in plugins: Conda’s internal plugins are loaded first
- Entry point plugins: External plugins registered via setuptools entry points are discovered and loaded
- Plugin validation: Plugin names are validated and conflicts are detected
Plugin names must be lowercase and stripped of whitespace. The plugin system will automatically normalize names.
Plugin Manager API
TheCondaPluginManager class provides methods for interacting with registered plugins:
Key Methods
| Method | Description |
|---|---|
register(plugin, name) | Register a plugin manually |
load_plugins(*plugins) | Load multiple plugins at once |
load_entrypoints(group, name) | Load plugins from setuptools entry points |
get_hook_results(name, **kwargs) | Get all results from a specific hook |
disable_external_plugins() | Disable all non-built-in plugins |
Example: Getting Registered Solvers
Built-in Plugin Modules
Conda includes several built-in plugin implementations:conda.plugins.solvers: Classic solver implementationconda.plugins.subcommands.doctor:conda doctorandconda checksubcommandsconda.plugins.virtual_packages: Virtual package registrationconda.plugins.post_solves: Post-solve hooksconda.plugins.reporter_backends: Reporter backend implementationsconda.plugins.package_extractors: Package extraction handlersconda.plugins.prefix_data_loaders: Prefix data loadersconda.plugins.environment_specifiers: Environment specification parsersconda.plugins.environment_exporters: Environment exporters
Error Handling
Best Practices
Use Typed Returns
Always use the appropriate plugin type from
conda.plugins.types for your hook implementation.Lowercase Names
Plugin names should be lowercase with hyphens for separation (e.g.,
my-custom-plugin).Handle Errors Gracefully
Your plugin should handle errors without crashing conda.
Document Your Plugin
Provide clear documentation about what your plugin does and how to use it.
Next Steps
Hook Specifications
Learn about all available plugin hooks
Plugin Types
Explore all plugin type definitions