
    wBfu#                        d Z ddlmZ ddlmZ ddlZerddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZmZmZ dZ	  ej(                  e      Z	  ej,                  e      Z	  G d	 d
      Zy)z
Pluggy hook specifications ("hookspecs") to register conda plugins.

Each hookspec defined in :class:`~conda.plugins.hookspec.CondaSpecs` contains
an example of how to use it.

    )annotations)TYPE_CHECKINGN)Iterable   )
CondaAuthHandlerCondaHealthCheckCondaPostCommandCondaPostSolveCondaPreCommandCondaPreSolveCondaSettingCondaSolverCondaSubcommandCondaVirtualPackagecondac                      e Zd ZdZedd       Zedd       Zedd       Zedd       Zedd       Z	edd       Z
edd       Zedd	       Zedd
       Zedd       Zy)
CondaSpecsz5The conda plugin hookspecs, to be used by developers.c                     y)a  
        Register solvers in conda.

        **Example:**

        .. code-block:: python

            import logging

            from conda import plugins
            from conda.core import solve

            log = logging.getLogger(__name__)


            class VerboseSolver(solve.Solver):
                def solve_final_state(self, *args, **kwargs):
                    log.info("My verbose solver!")
                    return super().solve_final_state(*args, **kwargs)


            @plugins.hookimpl
            def conda_solvers():
                yield plugins.CondaSolver(
                    name="verbose-classic",
                    backend=VerboseSolver,
                )

        :return: An iterable of solver entries.
        N selfs    6lib/python3.12/site-packages/conda/plugins/hookspec.pyconda_solverszCondaSpecs.conda_solvers2           c                     y)a.  
        Register external subcommands in conda.

        **Example:**

        .. code-block:: python

            from conda import plugins


            def example_command(args):
                print("This is an example command!")


            @plugins.hookimpl
            def conda_subcommands():
                yield plugins.CondaSubcommand(
                    name="example",
                    summary="example command",
                    action=example_command,
                )

        :return: An iterable of subcommand entries.
        Nr   r   s    r   conda_subcommandszCondaSpecs.conda_subcommandsS   r   r   c                     y)a  
        Register virtual packages in Conda.

        **Example:**

        .. code-block:: python

            from conda import plugins


            @plugins.hookimpl
            def conda_virtual_packages():
                yield plugins.CondaVirtualPackage(
                    name="my_custom_os",
                    version="1.2.3",
                    build="x86_64",
                )

        :return: An iterable of virtual package entries.
        Nr   r   s    r   conda_virtual_packagesz!CondaSpecs.conda_virtual_packagesn   r   r   c                     y)a  
        Register pre-command functions in conda.

        **Example:**

        .. code-block:: python

           from conda import plugins


           def example_pre_command(command):
               print("pre-command action")


           @plugins.hookimpl
           def conda_pre_commands():
               yield plugins.CondaPreCommand(
                   name="example-pre-command",
                   action=example_pre_command,
                   run_for={"install", "create"},
               )
        Nr   r   s    r   conda_pre_commandszCondaSpecs.conda_pre_commands   r   r   c                     y)a
  
        Register post-command functions in conda.

        **Example:**

        .. code-block:: python

           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"},
               )
        Nr   r   s    r   conda_post_commandszCondaSpecs.conda_post_commands   r   r   c                     y)az  
        Register a conda auth handler derived from the requests API.

        This plugin hook allows attaching requests auth handler subclasses,
        e.g. when authenticating requests against individual channels hosted
        at HTTP/HTTPS services.

        **Example:**

        .. code-block:: python

            import os
            from conda import plugins
            from requests.auth import AuthBase


            class EnvironmentHeaderAuth(AuthBase):
                def __init__(self, *args, **kwargs):
                    self.username = os.environ["EXAMPLE_CONDA_AUTH_USERNAME"]
                    self.password = os.environ["EXAMPLE_CONDA_AUTH_PASSWORD"]

                def __call__(self, request):
                    request.headers["X-Username"] = self.username
                    request.headers["X-Password"] = self.password
                    return request


            @plugins.hookimpl
            def conda_auth_handlers():
                yield plugins.CondaAuthHandler(
                    name="environment-header-auth",
                    auth_handler=EnvironmentHeaderAuth,
                )
        Nr   r   s    r   conda_auth_handlerszCondaSpecs.conda_auth_handlers   r   r   c                     y)a  
        Register health checks for conda doctor.

        This plugin hook allows you to add more "health checks" to conda doctor
        that you can write to diagnose problems in your conda environment.
        Check out the health checks already shipped with conda for inspiration.

        **Example:**

        .. code-block:: python

            from conda import plugins


            def example_health_check(prefix: str, verbose: bool):
                print("This is an example health check!")


            @plugins.hookimpl
            def conda_health_checks():
                yield plugins.CondaHealthCheck(
                    name="example-health-check",
                    action=example_health_check,
                )
        Nr   r   s    r   conda_health_checkszCondaSpecs.conda_health_checks   r   r   c                     y)a?  
        Register pre-solve functions in conda that are used in the
        general solver API, before the solver processes the package specs in
        search of a solution.

        **Example:**

        .. code-block:: python

           from conda import plugins
           from conda.models.match_spec import MatchSpec


           def example_pre_solve(
               specs_to_add: frozenset[MatchSpec],
               specs_to_remove: frozenset[MatchSpec],
           ):
               print(f"Adding {len(specs_to_add)} packages")
               print(f"Removing {len(specs_to_remove)} packages")


           @plugins.hookimpl
           def conda_pre_solves():
               yield plugins.CondaPreSolve(
                   name="example-pre-solve",
                   action=example_pre_solve,
               )
        Nr   r   s    r   conda_pre_solveszCondaSpecs.conda_pre_solves   r   r   c                     y)a  
        Register post-solve functions in conda that are used in the
        general solver API, after the solver has provided the package
        records to add or remove from the conda environment.

        **Example:**

        .. code-block:: python

           from conda import plugins
           from conda.models.records import PackageRecord


           def example_post_solve(
               repodata_fn: str,
               unlink_precs: tuple[PackageRecord, ...],
               link_precs: tuple[PackageRecord, ...],
           ):
               print(f"Uninstalling {len(unlink_precs)} packages")
               print(f"Installing {len(link_precs)} packages")


           @plugins.hookimpl
           def conda_post_solves():
               yield plugins.CondaPostSolve(
                   name="example-post-solve",
                   action=example_post_solve,
               )
        Nr   r   s    r   conda_post_solveszCondaSpecs.conda_post_solves  r   r   c                     y)a  
        Register new setting

        The example below defines a simple string type parameter

        **Example:**

        .. code-block:: python

           from conda import plugins
           from conda.common.configuration import PrimitiveParameter, SequenceParameter


           @plugins.hookimpl
           def conda_settings():
               yield plugins.CondaSetting(
                   name="example_option",
                   description="This is an example option",
                   parameter=PrimitiveParameter("default_value", element_type=str),
                   aliases=("example_option_alias",),
               )
        Nr   r   s    r   conda_settingszCondaSpecs.conda_settings7  r   r   N)returnzIterable[CondaSolver])r.   zIterable[CondaSubcommand])r.   zIterable[CondaVirtualPackage])r.   zIterable[CondaPreCommand])r.   zIterable[CondaPostCommand])r.   zIterable[CondaAuthHandler])r.   zIterable[CondaHealthCheck])r.   zIterable[CondaPreSolve])r.   zIterable[CondaPostSolve])r.   zIterable[CondaSetting])__name__
__module____qualname____doc__	_hookspecr   r   r   r!   r#   r%   r'   r)   r+   r-   r   r   r   r   r   /   s    ? @  4  ,  0  0 " "H  6  <  >  r   r   )r2   
__future__r   typingr   pluggycollections.abcr   typesr   r   r	   r
   r   r   r   r   r   r   	spec_nameHookspecMarkerr3   HookimplMarkerhookimplr   r   r   r   <module>r=      sp    #   (   	 8!F!!),	 !6  +
_ _r   