Post-commands#
Conda commands can be extended with the conda_post_commands plugin hook.
By specifying the set of commands you would like to use in the run_for configuration
option, you can execute code via the action option after these commands are run.
The functions are provided a command argument representing the name
of the command currently running. If the command fails for any reason, this plugin hook will not
be run.
If you would like to target conda env commands, prefix the command name with env_.
For example, conda env list would be passed to run_for as env_list.
- class CondaPostCommand#
Return type to use when defining a conda post-command plugin hook.
For details on how this is used, see
conda_post_commands().- Parameters:
name -- Post-command name (e.g.,
custom_plugin_post_commands).action -- Callable which contains the code to be run.
run_for -- Represents the command(s) this will be run on (e.g.
installorcreate).
- action#
- name#
- run_for#
- conda_post_commands()#
Register post-command functions in conda.
Example:
from conda import plugins def example_post_command(command): print("post-command action") @plugins.hookimpl def conda_post_commands(): yield plugins.CondaPostCommand( name="example-post-command", action=example_post_command, run_for={"install", "create"}, )