:py:mod:`manager` ================= .. py:module:: conda.plugins.manager .. autoapi-nested-parse:: This module contains a subclass implementation of pluggy's `PluginManager `_. Additionally, it contains a function we use to construct the ``PluginManager`` object and register all plugins during conda's startup process. Classes ------- .. autoapisummary:: conda.plugins.manager._HookImplWrapper conda.plugins.manager.CondaPluginManager Functions --------- .. autoapisummary:: conda.plugins.manager.get_plugin_manager .. py:class:: _HookImplWrapper .. py:attribute:: impl :type: pluggy.HookImpl .. py:method:: function(*args) .. py:method:: __getattr__(name) .. py:method:: _isiterable(obj) :staticmethod: .. py:method:: _set_impl(result, impl) :staticmethod: .. py:class:: CondaPluginManager(*args, **kwargs) Bases: :py:obj:`pluggy.PluginManager` The conda plugin manager to implement behavior additional to pluggy's default plugin manager. .. py:attribute:: get_cached_solver_backend :type: collections.abc.Callable[[str | None], type[conda.core.solve.Solver]] Cached version of the :meth:`~conda.plugins.manager.CondaPluginManager.get_solver_backend` method. .. py:attribute:: get_cached_session_headers :type: collections.abc.Callable[[str], dict[str, str]] Cached version of the :meth:`~conda.plugins.manager.CondaPluginManager.get_session_headers` method. .. py:attribute:: get_cached_request_headers :type: collections.abc.Callable[[str, str], dict[str, str]] Cached version of the :meth:`~conda.plugins.manager.CondaPluginManager.get_request_headers` method. .. py:method:: get_canonical_name(plugin: object) -> str Return a canonical name for a plugin object. Note that a plugin may be registered under a different name specified by the caller of :meth:`register(plugin, name) `. To obtain the name of a registered plugin use :meth:`get_name(plugin) ` instead. .. py:method:: register(plugin, name: str | None = None) -> str | None Call :meth:`pluggy.PluginManager.register` and return the result or ignore errors raised, except ``ValueError``, which means the plugin had already been registered. .. py:method:: load_plugins(*plugins) -> int Load the provided list of plugins and fail gracefully on error. The provided list of plugins can either be classes or modules with :attr:`~conda.plugins.hookimpl`. .. py:method:: load_entrypoints(group: str, name: str | None = None) -> int Load modules from querying the specified setuptools ``group``. :param str group: Entry point group to load plugins. :param str name: If given, loads only plugins with the given ``name``. :rtype: int :return: The number of plugins loaded by this call. .. py:method:: _hookexec(hook_name: str, methods: collections.abc.Sequence[pluggy.HookImpl], kwargs: collections.abc.Mapping[str, object], firstresult: bool) -> object | list[object] .. py:method:: get_hook_results(name: Literal['subcommands']) -> list[conda.plugins.types.CondaSubcommand] get_hook_results(name: Literal['virtual_packages']) -> list[conda.plugins.types.CondaVirtualPackage] get_hook_results(name: Literal['solvers']) -> list[conda.plugins.types.CondaSolver] get_hook_results(name: Literal['pre_commands']) -> list[conda.plugins.types.CondaPreCommand] get_hook_results(name: Literal['post_commands']) -> list[conda.plugins.types.CondaPostCommand] get_hook_results(name: Literal['auth_handlers']) -> list[conda.plugins.types.CondaAuthHandler] get_hook_results(name: Literal['health_checks']) -> list[conda.plugins.types.CondaHealthCheck] get_hook_results(name: Literal['pre_solves']) -> list[conda.plugins.types.CondaPreSolve] get_hook_results(name: Literal['post_solves']) -> list[conda.plugins.types.CondaPostSolve] get_hook_results(name: Literal['session_headers'], *, host: str) -> list[conda.plugins.types.CondaRequestHeader] get_hook_results(name: Literal['request_headers'], *, host: str, path: str) -> list[conda.plugins.types.CondaRequestHeader] get_hook_results(name: Literal['settings']) -> list[conda.plugins.types.CondaSetting] get_hook_results(name: Literal['reporter_backends']) -> list[conda.plugins.types.CondaReporterBackend] get_hook_results(name: Literal['pre_transaction_actions']) -> list[conda.plugins.types.CondaPreTransactionAction] get_hook_results(name: Literal['post_transaction_actions']) -> list[conda.plugins.types.CondaPostTransactionAction] get_hook_results(name: Literal['prefix_data_loaders']) -> list[conda.plugins.types.CondaPrefixDataLoader] get_hook_results(name: Literal['environment_specifiers']) -> list[conda.plugins.types.CondaEnvironmentSpecifier] get_hook_results(name: Literal['package_extractors']) -> list[conda.plugins.types.CondaPackageExtractor] get_hook_results(name: Literal['environment_exporters']) -> list[conda.plugins.types.CondaEnvironmentExporter] Return results of the plugin hooks with the given name and raise an error if there is a conflict. .. py:method:: get_solvers() -> dict[str, conda.plugins.types.CondaSolver] Return a mapping from solver name to solver class. .. py:method:: get_solver_backend(name: str | None = None) -> type[conda.core.solve.Solver] Get the solver backend with the given name (or fall back to the name provided in the context). See ``context.solver`` for more details. Please use the cached version of this method called :meth:`get_cached_solver_backend` for high-throughput code paths which is set up as a instance-specific LRU cache. .. py:method:: get_auth_handler(name: str) -> type[requests.auth.AuthBase] | None Get the auth handler with the given name or None .. py:method:: get_settings() -> dict[str, conda.plugins.types.CondaSetting] Return a mapping of plugin setting name to CondaSetting objects. This method intentionally overwrites any duplicates that may be present .. py:method:: invoke_pre_commands(command: str) -> None Invokes ``CondaPreCommand.action`` functions registered with ``conda_pre_commands``. :param command: name of the command that is currently being invoked .. py:method:: invoke_post_commands(command: str) -> None Invokes ``CondaPostCommand.action`` functions registered with ``conda_post_commands``. :param command: name of the command that is currently being invoked .. py:method:: disable_external_plugins() -> None Disables all currently registered plugins except built-in conda plugins .. py:method:: get_subcommands() -> dict[str, conda.plugins.types.CondaSubcommand] .. py:method:: get_health_checks() -> dict[str, conda.plugins.types.CondaHealthCheck] Return a mapping of health check name to health check. .. py:method:: get_reporter_backends() -> tuple[conda.plugins.types.CondaReporterBackend, Ellipsis] .. py:method:: get_reporter_backend(name: str) -> conda.plugins.types.CondaReporterBackend Attempts to find a reporter backend while providing a fallback option if it is not found. This method must return a valid ``CondaReporterBackend`` object or else it will raise an exception. .. py:method:: get_virtual_package_records() -> tuple[conda.models.records.PackageRecord, Ellipsis] .. py:method:: get_session_headers(host: str) -> dict[str, str] .. py:method:: get_request_headers(host: str, path: str) -> dict[str, str] .. py:method:: get_prefix_data_loaders() -> collections.abc.Iterable[conda.plugins.types.CondaPrefixDataLoaderCallable] .. py:method:: invoke_pre_solves(specs_to_add: frozenset[conda.models.match_spec.MatchSpec], specs_to_remove: frozenset[conda.models.match_spec.MatchSpec]) -> None Invokes ``CondaPreSolve.action`` functions registered with ``conda_pre_solves``. :param specs_to_add: :param specs_to_remove: .. py:method:: invoke_post_solves(repodata_fn: str, unlink_precs: tuple[conda.models.records.PackageRecord, Ellipsis], link_precs: tuple[conda.models.records.PackageRecord, Ellipsis]) -> None Invokes ``CondaPostSolve.action`` functions registered with ``conda_post_solves``. :param repodata_fn: :param unlink_precs: :param link_precs: .. py:method:: load_settings() -> None Iterates through all registered settings and adds them to the :class:`conda.common.configuration.PluginConfig` class. .. py:method:: get_config(data) -> conda.plugins.config.PluginConfig Retrieve the configuration for the plugin. :returns: The configuration object for the plugin, initialized with raw data from the context. :rtype: PluginConfig .. py:method:: get_environment_specifiers(*, supports_detection: bool | None = None, with_aliases: bool = True) -> dict[str, conda.plugins.types.CondaEnvironmentSpecifier] Returns a mapping from environment specifier name to environment specifier. :param supports_detection: ternary value that returns either everything, only supporting detection or not supporting detection. :param with_aliases: whether to include aliased values of environment specifiers. .. py:method:: _get_name_and_alias_mapping(plugins: collections.abc.Iterable[conda.plugins.types.CondaPlugin]) -> dict[str, conda.plugins.types.CondaEnvironmentSpecifier] Get a mapping from plugin names (including aliases) to plugin. :param plugins: List of plugins that have a name and aliases attribute. :return: Dict mapping format name to CondaEnvironmentExporter :raises PluginError: If multiple exporters use the same format name or alias .. py:method:: get_environment_specifier_by_name(source: str, name: str) -> conda.plugins.types.CondaEnvironmentSpecifier Get an environment specifier plugin by name :param source: full path to the environment spec file/source :param name: name of the environment plugin to load :raises CondaValueError: if the requested plugin is not available. :raises PluginError: if the requested plugin is unable to handle the provided file. :returns: an environment specifier plugin that matches the provided plugin name, or can handle the provided file .. py:method:: _detect_filename_env_spec(source: str, basename: str, hooks: dict[str, conda.plugins.types.CondaEnvironmentSpecifier]) -> list[conda.plugins.types.CondaEnvironmentSpecifier] Detect environment specifier by filename pattern matching. :param basename: basename of the source file :param hooks: mapping of environment specifier plugins :returns: list of matching plugins, or None if no filename matches .. py:method:: _detect_content_env_spec(source: str, hooks: dict[str, conda.plugins.types.CondaEnvironmentSpecifier]) -> list[conda.plugins.types.CondaEnvironmentSpecifier] :staticmethod: Detect environment specifier by content-based autodetection. :param source: full path to the environment spec file or source :param hooks: mapping of environment specifier plugins :returns: tuple of (found plugins, autodetect disabled plugin names) .. py:method:: detect_environment_specifier(source: str) -> conda.plugins.types.CondaEnvironmentSpecifier Detect the environment specifier plugin for a given spec source Uses two-phase detection: 1. Filename-based filtering using fnmatch patterns 2. Fallback to content-based autodetection (can_handle()) Raises PluginError if more than one environment_spec plugin is found to be able to handle the file. Raises EnvironmentSpecPluginNotDetected if no plugins were found. :param source: full path to the environment spec file or source :returns: an environment specifier plugin that can handle the provided file .. py:method:: get_environment_specifier(source: str, name: str | None = None) -> conda.plugins.types.CondaEnvironmentSpecifier Get the environment specifier plugin for a given spec source, or given a plugin name Raises PluginError if more than one environment_spec plugin is found to be able to handle the file. Raises EnvironmentSpecPluginNotDetected if no plugins were found. Raises CondaValueError if the requested plugin is not available. :param filename: full path to the environment spec file/source :param name: name of the environment plugin to load :returns: an environment specifier plugin that matches the provided plugin name, or can handle the provided file .. py:method:: get_environment_exporters() -> collections.abc.Iterable[conda.plugins.types.CondaEnvironmentExporter] Yields all detected environment exporters. .. py:method:: get_exporter_format_mapping() -> dict[str, conda.plugins.types.CondaEnvironmentExporter] Get a mapping from format names (including aliases) to environment exporters. :return: Dict mapping format name to CondaEnvironmentExporter :raises PluginError: If multiple exporters use the same format name or alias .. py:method:: detect_environment_exporter(filename: str) -> conda.plugins.types.CondaEnvironmentExporter Detect an environment exporter based on filename matching against default_filenames. Uses fnmatch pattern matching for flexible filename patterns (e.g., *.conda-lock.yml). :param filename: Filename to find an exporter for (basename is used for detection) :return: CondaEnvironmentExporter that supports the filename :raises EnvironmentExporterNotDetected: If no exporter supports the filename :raises PluginError: If multiple exporters claim to support the same filename .. py:method:: get_environment_exporter_by_format(format_name: str) -> conda.plugins.types.CondaEnvironmentExporter Get an environment exporter based on the format name. :param format_name: Format name to find an exporter for (e.g., 'yaml', 'json', 'environment-yaml') :return: CondaEnvironmentExporter that supports the format :raises CondaValueError: If no exporter is found for the given format .. py:method:: get_pre_transaction_actions(transaction_context: dict[str, str] | None = None, target_prefix: str | None = None, unlink_precs: collections.abc.Iterable[conda.models.records.PackageRecord] | None = None, link_precs: collections.abc.Iterable[conda.models.records.PackageRecord] | None = None, remove_specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec] | None = None, update_specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec] | None = None, neutered_specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec] | None = None) -> list[conda.core.path_actions.Action] Get the plugin-defined pre-transaction actions. :param transaction_context: Mapping between target prefixes and PrefixActionGroup instances :param target_prefix: Target prefix for the action :param unlink_precs: Package records to be unlinked :param link_precs: Package records to link :param remove_specs: Specs to be removed :param update_specs: Specs to be updated :param neutered_specs: Specs to be neutered :return: The plugin-defined pre-transaction actions .. py:method:: get_post_transaction_actions(transaction_context: dict[str, str] | None = None, target_prefix: str | None = None, unlink_precs: collections.abc.Iterable[conda.models.records.PackageRecord] | None = None, link_precs: collections.abc.Iterable[conda.models.records.PackageRecord] | None = None, remove_specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec] | None = None, update_specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec] | None = None, neutered_specs: collections.abc.Iterable[conda.models.match_spec.MatchSpec] | None = None) -> list[conda.core.path_actions.Action] Get the plugin-defined post-transaction actions. :param transaction_context: Mapping between target prefixes and PrefixActionGroup instances :param target_prefix: Target prefix for the action :param unlink_precs: Package records to be unlinked :param link_precs: Package records to link :param remove_specs: Specs to be removed :param update_specs: Specs to be updated :param neutered_specs: Specs to be neutered :return: The plugin-defined post-transaction actions .. py:method:: get_package_extractors() -> dict[str, conda.plugins.types.CondaPackageExtractor] Return a mapping from file extension to package extractor plugin. Extensions are lowercased for case-insensitive matching. :return: Dictionary mapping lowercased extensions (e.g., ``".conda"``) to their :class:`~conda.plugins.types.CondaPackageExtractor` plugins. .. py:method:: get_package_extractor(source_full_path: conda.common.path.PathType) -> conda.plugins.types.CondaPackageExtractor Get the package extractor plugin for a given package path. Searches through registered package extractor plugins to find one that handles the file extension of the provided package path. :param source_full_path: Full path to the package archive file. :return: The matching :class:`~conda.plugins.types.CondaPackageExtractor` plugin. :raises PluginError: If no registered extractor handles the file extension. .. py:method:: extract_package(source_full_path: conda.common.path.PathType, destination_directory: conda.common.path.PathType) -> None Extract a package archive to a destination directory. Finds the appropriate extractor plugin based on the file extension and extracts the package. :param source_full_path: Full path to the package archive file. :param destination_directory: Directory to extract the package contents to. :raises PluginError: If no registered extractor handles the file extension. .. py:method:: has_package_extension(path: conda.common.path.PathType) -> str | None Check if a path has a supported package file extension. :param path: Path to check. :return: The matched extension (lowercased) if found, None otherwise. .. py:function:: get_plugin_manager() -> CondaPluginManager Get a cached version of the :class:`~conda.plugins.manager.CondaPluginManager` instance, with the built-in and entrypoints provided by the plugins loaded.