
    lj                    B   U d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 dgZ
 G d de          Zg Zd	ed<   	 	 d#d$dZ edd          d%d            Z eddeg          d%d            Z edd          d%d            Z ed d!eg          d%d"            ZdS )&z\Auxiliary module for the checkhealth subcommand, contains
the actual check implementations.
    )annotationsN)Callable)ProtocolcastHEALTH_CHECKSc                  J    e Zd ZU ded<   ded<   ded<   ded<   ded<   ddZdS )HealthCheckFunctionstrdescriptionrecommendationz	list[str]skip_on_failedCallable[..., object] | Nonepost_fail_fix_hook__name__returnboolc                    d S N )selfs    W/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/cli/checkhealth/checks.py__call__zHealthCheckFunction.__call__   s          Nr   r   )r   
__module____qualname____annotations__r   r   r   r   r	   r	      sW         4444MMM######r   r	   zlist[HealthCheckFunction]r   r
   r   r   &list[HealthCheckFunction | str] | Noner   r   r   3Callable[[Callable[[], bool]], HealthCheckFunction]c                B     |g nd |D             d fd}|S )	a  Decorator used for declaring health checks.

    This decorator attaches some data to a function, which is then added to a
    a list containing all checks.

    Parameters
    ----------
    description
        A brief description of this check, displayed when the ``checkhealth``
        subcommand is run.
    recommendation
        Help text which is displayed in case the check fails.
    skip_on_failed
        A list of check functions which, if they fail, cause the current check
        to be skipped.
    post_fail_fix_hook
        A function that is meant to (interactively) help to fix the detected
        problem, if possible. This is only called upon explicit confirmation of
        the user.

    Returns
    -------
    Callable[Callable[[], bool], :class:`HealthCheckFunction`]
        A decorator which converts a function into a health check function, as
        required by the ``checkhealth`` subcommand.
    Nc                >    g | ]}t          |          r|j        n|S r   )callabler   ).0skips     r   
<listcomp>zhealthcheck.<locals>.<listcomp>@   s6     
 
 
:>Xd^^5DMM
 
 
r   funcCallable[[], bool]r   r	   c                    t          t          |           }|_        |_        |_        |_        t                              |           |S r   )r   r	   r   r   r   r   r   append)r&   health_funcr   new_skip_on_failedr   r   s     r   wrapperzhealthcheck.<locals>.wrapperD   sM    .55"-%3"%7");&[)))r   )r&   r'   r   r	   r   )r   r   r   r   r,   r+   s   `` ` @r   healthcheckr-      sk    B 
 
BP
 
 
         Nr   z&Checking whether manim is on your PATHa  The command <manim> is currently not on your system's PATH.

You can work around this by calling the manim module directly via <python -m manim> instead of just <manim>.

To fix the PATH issue properly: Usually, the Python package installer pip issues a warning during the installation which contains more information. Consider reinstalling manim via <pip uninstall manim> followed by <pip install manim> to see the warning again, then consult the internet on how to modify your system's PATH variable.)r   r   r   c                 2    t          j        d          } | duS )zCheck whether ``manim`` is in ``PATH``.

    Returns
    -------
    :class:`bool`
        Whether ``manim`` is in ``PATH`` or not.
    manimN)shutilwhich)path_to_manims    r   is_manim_on_pathr3   P   s    . L))M$$r   z0Checking whether the executable belongs to manima  The command <manim> does not belong to your installed version of this library, it likely belongs to manimgl / manimlib.

Run manim via <python -m manim> or via <manimce>, or uninstall and reinstall manim via <pip install --upgrade --force-reinstall manim> to fix this.)r   r   r   c                     t          j        d          } | J t          | d          5 }|                                }ddd           n# 1 swxY w Y   d|v pd|v S )a  Check whether the ``manim`` executable in ``PATH`` is associated to this
    library. To verify this, the executable should look like this:

    .. code-block:: python

        #!<MANIM_PATH>/.../python
        import sys
        from manim.__main__ import main

        if __name__ == "__main__":
            sys.exit(main())


    Returns
    -------
    :class:`bool`
        Whether the ``manim`` executable in ``PATH`` is associated to this
        library or not.
    r/   Nrbs   manim.__main__s   "%~dp0\manim")r0   r1   openread)r2   manim_binary
manim_execs      r   .is_manim_executable_associated_to_this_libraryr:   k   s    > L))M$$$	mT	"	" )l!&&((
) ) ) ) ) ) ) ) ) ) ) ) ) ) ) 
*M.?:.MMs   A

AAz#Checking whether latex is availablea<  Manim cannot find <latex> on your system's PATH. You will not be able to use Tex and MathTex mobjects in your scenes.

Consult our installation instructions at https://docs.manim.community/en/stable/installation.html or search the web for instructions on how to install a LaTeX distribution on your operating system.c                 p    t          j        d          } | duot          j        | t          j                  S )zCheck whether ``latex`` is in ``PATH`` and can be executed.

    Returns
    -------
    :class:`bool`
        Whether ``latex`` is in ``PATH`` and can be executed or not.
    latexNr0   r1   osaccessX_OK)path_to_latexs    r   is_latex_availablerB      s1    ( L))M$J="')J)JJr   z%Checking whether dvisvgm is availablezManim could find <latex>, but not <dvisvgm> on your system's PATH. Make sure your installed LaTeX distribution comes with dvisvgm and consider installing a larger distribution if it does not.c                 p    t          j        d          } | duot          j        | t          j                  S )zCheck whether ``dvisvgm`` is in ``PATH`` and can be executed.

    Returns
    -------
    :class:`bool`
        Whether ``dvisvgm`` is in ``PATH`` and can be executed or not.
    dvisvgmNr=   )path_to_dvisvgms    r   is_dvisvgm_availablerF      s1    $ l9--O$&N29_bg+N+NNr   )NN)
r   r
   r   r
   r   r   r   r   r   r   r   )__doc__
__future__r   r>   r0   collections.abcr   typingr   r   __all__r	   r   r   r-   r3   r:   rB   rF   r   r   r   <module>rL      s     # " " " " " 				  $ $ $ $ $ $ ! ! ! ! ! ! ! !
$ $ $ $ $( $ $ $ ,. - - - - >B7;	1 1 1 1 1h 8		  	% 	% 	% 	% B	0 %%
 
 
N N N
 
N> 5	7  	K 	K 	K 	K 7	
 ''	 	 		O 	O 	O	 		O 	O 	Or   