
    q-Ph&,                       d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZmZmZ d	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Zd	Z  G d
 de          Z!d?dZ"erNd dl#Z#d dl$Z$d dl%Z%d dl&Z&d dl'Z'd dl(Z(d dl)Z)d dl*Z*d dl+Z+d dl,Z,d dl-Z-d dl.Z.d dl/Z/d dl0Z0d dl1Z1d dl2Z2d dl3Z3d dl4Z4d dl5Z5n
 e"d          \  Z#Z6 e"d          \  Z$Z6 e"d          \  Z%Z6 e"d          \  Z&Z6 e"d          \  Z'Z6 e"d          \  Z(Z e"d          \  Z)Z e"d          \  Z*Z e"d          \  Z+Z e"d          \  Z,Z e"d          \  Z-Z e"d          \  Z.Z e"d          \  Z/Z e"d          \  Z0Z e"d          \  Z1Z e"d           \  Z2Z e"d!          \  Z3Z e"d"          \  Z5Z e"d#          \  Z4Z ed@d(            Z7d	d)dAd-Z8d	d)dAd.Z9d	d)dAd/Z:d	d)dAd0Z;d	d)dAd1Z<d	d)dAd2Z=	 	 	 	 	 dBdCd=Z>g d>Z?dS )D    )annotationsN)Hashable)cache)import_module)	find_spec)
ModuleType)TYPE_CHECKINGAnyClassVarcastTc                  R     e Zd ZU dZdZdddddZded	<   d fdZddZddZ	 xZ
S )_LazyModulea/  
    Module that can act both as a lazy-loader and as a proxy.

    Notes
    -----
    We do NOT register this module with `sys.modules` so as not to cause
    confusion in the global environment. This way we have a valid proxy
    module for our own use, but it lives *exclusively* within polars.
    Tznp.zpd.zpa.zpc.)numpypandaspyarrowpolars_cloudzClassVar[dict[str, str]]_mod_pfxmodule_namestrmodule_availableboolreturnNonec                   || _         || _        t                      | _        t	                                          |           dS )a  
        Initialise lazy-loading proxy module.

        Parameters
        ----------
        module_name : str
            the name of the module to lazy-load (if available).

        module_available : bool
            indicate if the referenced module is actually available (we will proxy it
            in both cases, but raise a helpful error when invoked if it doesn't exist).
        N)_module_available_module_nameglobals_globalssuper__init__)selfr   r   	__class__s      S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/dependencies.pyr    z_LazyModule.__init__0   s>    $ "2'		%%%%%    r   c                    t          | j                  }|| j        | j        <   | j                            |j                   |S N)r   __name__r   r   __dict__update)r!   modules     r#   _importz_LazyModule._importG   s=    t}--+1d'(V_---r$   namer
   c                l   |dk    r| j         d|}t          |          | j        r$|                                 }t	          ||          S |dk    r| j         S t          j        d|          r|dk    rd S | j                            | j         d          }| | d| j         d}t          |          d )	N__wrapped__z object has no attribute r'   z	^__\w+__$__version__ z
 requires z module to be installed)
r   AttributeErrorr   r+   getattrrematchr   getModuleNotFoundError)r!   r,   msgr*   pfxs        r#   __getattr__z_LazyModule.__getattr__N   s     =  &KK4KKC %%% ! 	5\\^^F64((( Z$$XlD)) 	5dm.C.C 4 -##D$5r::CV$VV$*;VVVC%c**4r$   )r   r   r   r   r   r   )r   r   )r,   r   r   r
   )r'   
__module____qualname____doc____lazy__r   __annotations__r    r+   r9   __classcell__)r"   s   @r#   r   r      s           H 	* *H    & & & & & &.   5 5 5 5 5 5 5 5r$   r   r   r   r   tuple[ModuleType, bool]c                    | t           j        v rt           j        |          dfS 	 t          |           }|du p|j        du  }n# t          $ r d}Y nw xY wt          | |          |fS )a  
    Lazy import the given module; avoids up-front import costs.

    Parameters
    ----------
    module_name : str
        name of the module to import, eg: "pyarrow".

    Notes
    -----
    If the requested module is not available (eg: has not been installed), a proxy
    module is created in its place, which raises an exception on any attribute
    access. This allows for import and use as normal, without requiring explicit
    guard conditions - if the module is never used, no exception occurs; if it
    is, then a helpful exception is raised.

    Returns
    -------
    tuple of (Module, bool)
        A lazy-loading module and a boolean indicating if the requested/underlying
        module exists (if not, the returned module is a proxy).
    TNF)r   r   )sysmodulesr   loaderr6   r   )r   module_specr   s      r#   _lazy_importrF   i   s    0 ck!!{;'--!,, +t 3 Q{7IT7QR ! ! ! ! 	#-	
 	
 	
 	 s   A AAdataclasseshtmljsonpickle
subprocessaltair	deltalakefsspecgeventgreat_tables
hypothesisr   r   r   r   pydantic	pyicebergtorchpytzclstypetype_r   c                    	 t          fd|                                 D                       S # t          $ r Y dS w xY w)Nc              3  @   K   | ]} d t          |          v V  dS ).Nr   ).0orX   s     r#   	<genexpr>z_might_be.<locals>.<genexpr>   s4      <<Qe;;;#a&&(<<<<<<r$   F)anymro	TypeError)rV   rX   s    `r#   	_might_berc      sU    
<<<<#''))<<<<<<   uus   ,0 
>>)
check_typeobjr
   rd   c               x    t           o3t          t          t          |rt	          |           n|           d          S )Nr   )_NUMPY_AVAILABLErc   r   r   rW   re   rd   s     r#   _check_for_numpyri      9     	XJ7tCyyyC88'! ! r$   c               x    t           o3t          t          t          |rt	          |           n|           d          S )Nr   )_PANDAS_AVAILABLErc   r   r   rW   rh   s     r#   _check_for_pandasrm      s9     XJ7tCyyyC88(" " r$   c               x    t           o3t          t          t          |rt	          |           n|           d          S )Nr   )_PYARROW_AVAILABLErc   r   r   rW   rh   s     r#   _check_for_pyarrowrp      s9     )XJ7tCyyyC88)# # r$   c               x    t           o3t          t          t          |rt	          |           n|           d          S )NrR   )_PYDANTIC_AVAILABLErc   r   r   rW   rh   s     r#   _check_for_pydanticrs      s9     9XJ7tCyyyC88*$ $ r$   c               x    t           o3t          t          t          |rt	          |           n|           d          S )NrT   )_TORCH_AVAILABLErc   r   r   rW   rh   s     r#   _check_for_torchrv      rj   r$   c               x    t           o3t          t          t          |rt	          |           n|           d          S )NrU   )_PYTZ_AVAILABLErc   r   r   rW   rh   s     r#   _check_for_pytzry      s9     yXJ7tCyyyC88&    r$   required package	not foundrequires
err_prefix
err_suffixmin_versionstr | tuple[int, ...] | Nonemin_err_prefixinstall_message
str | Nonec           
     8   ddl m} ddlm} |                     dd          d         }	 t          |           }	nj# t          $ r] |r|                    d           dnd}
|rd|                    d           nd}|
 d|  d| d	|pd
| dz   }t          |          dw xY w|rt ||          } ||	j	                  }||k     rS| d| dd
                    d |D                        dd
                    d |D                        d} ||          |	S )ai  
    Import an optional dependency, returning the module.

    Parameters
    ----------
    module_name : str
        Name of the dependency to import.
    err_prefix : str, optional
        Error prefix to use in the raised exception (appears before the module name).
    err_suffix: str, optional
        Error suffix to use in the raised exception (follows the module name).
    min_version : {str, tuple[int]}, optional
        If a minimum module version is required, specify it here.
    min_err_prefix : str, optional
        Override the standard "requires" prefix for the minimum version error message.
    install_message : str, optional
        Override the standard "Please install it using..." exception message fragment.

    Examples
    --------
    >>> from polars.dependencies import import_optional
    >>> import_optional(
    ...     "definitely_a_real_module",
    ...     err_prefix="super-important package",
    ... )  # doctest: +SKIP
    ImportError: super-important package 'definitely_a_real_module' not installed.
    Please install it using the command `pip install definitely_a_real_module`.
    r   )parse_version)ModuleUpgradeRequiredErrorr[       r0   'z.
z.Please install using the command `pip install z`.Nc              3  4   K   | ]}t          |          V  d S r&   r\   r]   vs     r#   r_   z"import_optional.<locals>.<genexpr>-  s(      88qCFF888888r$   z or higher (found c              3  4   K   | ]}t          |          V  d S r&   r\   r   s     r#   r_   z"import_optional.<locals>.<genexpr>.  s(      #@#@qCFF#@#@#@#@#@#@r$   ))polars._utils.variousr   polars.exceptionsr   splitr   ImportErrorstripr6   r/   join)r   r}   r~   r   r   r   r   r   module_rootr*   prefixsuffixerr_messagemod_versionr7   s                  r#   import_optionalr      s   H 433333<<<<<<##C++A.K	9{++ 9 9 90:BJ$$S)),,,,0:B,Z%%c**,,,;;+;;;;; POOOO
 "+..D89  	2#mK00#mF$677$$! D DK D D8888K88888D D88#@#@K#@#@#@@@D D D 
 -,S111Ms
   : A'B!)%rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   r   r   rR   rS   r   rT   rU   ri   rm   rp   rs   rv   ry   _ALTAIR_AVAILABLE_DELTALAKE_AVAILABLE_FSSPEC_AVAILABLE_GEVENT_AVAILABLE_GREAT_TABLES_AVAILABLE_HYPOTHESIS_AVAILABLErg   rl   _POLARS_CLOUD_AVAILABLEro   rr   _PYICEBERG_AVAILABLEru   )r   r   r   r@   )rV   rW   rX   r   r   r   )re   r
   rd   r   r   r   )rz   r{   Nr|   N)r   r   r}   r   r~   r   r   r   r   r   r   r   r   r
   )@
__future__r   r3   rB   collections.abcr   	functoolsr   	importlibr   importlib.utilr   typesr   typingr	   r
   r   r   r   r   r   r   r   r   rg   rl   r   ro   rr   r   ru   rx   r   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   r   r   r   r   rR   rS   rU   rT   _rc   ri   rm   rp   rs   rv   ry   r   __all__ r$   r#   <module>r      s   " " " " " " 				 



 $ $ $ $ $ $       # # # # # # $ $ $ $ $ $       5 5 5 5 5 5 5 5 5 5 5 5             J5 J5 J5 J5 J5* J5 J5 J5Z* * * *Z  ,1KKKKKKMMMMMMMMMMMMLLLMMMNNNOOOKKKLLLL "\-00NKl6""GD!l6""GD!X&&IFA L..MJ !-X 6 6F&2l;&?&?#I# ,X 6 6F ,X 6 6F,8L,H,H)L)(4\(B(B%J%*l733E ,X 6 6F,8L,H,H)L)".,y"9"9G$0L$<$<!H!&2l;&?&?#I#*l733E(L00D/     6:       7;       8<       9=       6:       59       )!04$"&> > > > >B* * *r$   