
    ˀh&,                       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rMd 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l5Z5n 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!d,d"Z8d	d!d,d#Z9d	d!d,d$Z:d	d!d,d%Z;d	d!d,d&Z<d	d!d,d'Z=	 	 	 	 	 d-	 	 	 	 	 	 	 	 	 	 	 	 	 d.d(Z>g d)Z?y)/    )annotationsN)Hashable)cache)import_module)	find_spec)
ModuleType)TYPE_CHECKINGAnyClassVarcastTc                  ^     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_pfxc               ^    || _         || _        t               | _        t        |   |       y)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__)selfmodule_namemodule_available	__class__s      o/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/dependencies.pyr   z_LazyModule.__init__0   s+    $ "2'	%    c                    t        | j                        }|| 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    c                z   |dk(  r| j                   d|}t        |      | j                  r| j                         }t	        ||      S |dk(  r| j                   S t        j                  d|      r|dk7  ry | j                  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   namemsgr&   pfxs        r   __getattr__z_LazyModule.__getattr__N   s     = &&))B4(KC %% !!\\^F64(( Z$$$XXlD)dm.C  --##D$5$5r:CE$z$*;*;)>>UVC%c*4r    )r   strr   boolreturnNone)r8   r   )r2   r6   r8   r
   )r#   
__module____qualname____doc____lazy__r   __annotations__r   r'   r5   __classcell__)r   s   @r   r   r      sW     H 	*H& && 	&
 
&.5r    r   c                    | t         j                  v rt         j                  |    dfS 	 t        |       }|du xs |j                  du  }t        | |      |fS # t        $ r d}Y w xY w)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   loaderr1   r   )r   module_specr   s      r   _lazy_importrE   i   s    0 ckk!{{;'--!, +t 3 Q{7I7IT7QR 	#-	
 	   ! !s    A A&%A&dataclasseshtmljsonpickle
subprocessaltair	deltalakefsspecgeventgreat_tables
hypothesisr   r   r   r   pydantic	pyicebergtorchpytzc                h    	 t        fd| j                         D              S # t        $ r Y yw xY w)Nc              3  >   K   | ]  } d t        |      v   yw).Nr6   ).0otype_s     r   	<genexpr>z_might_be.<locals>.<genexpr>   s      <QeWA;#a&(<s   F)anymro	TypeError)clsr[   s    `r   	_might_bera      s1    
<#'')<<< s   !% 	11)
check_typec               `    t         xr' t        t        t        |rt	        |       n|       d      S )Nr   )_NUMPY_AVAILABLEra   r   r   typeobjrb   s     r   _check_for_numpyrh      *     	XJtCyC8'! r    c               `    t         xr' t        t        t        |rt	        |       n|       d      S )Nr   )_PANDAS_AVAILABLEra   r   r   re   rf   s     r   _check_for_pandasrl      s*     XJtCyC8(" r    c               `    t         xr' t        t        t        |rt	        |       n|       d      S )Nr   )_PYARROW_AVAILABLEra   r   r   re   rf   s     r   _check_for_pyarrowro      s*     )XJtCyC8)# r    c               `    t         xr' t        t        t        |rt	        |       n|       d      S )NrQ   )_PYDANTIC_AVAILABLEra   r   r   re   rf   s     r   _check_for_pydanticrr      s*     9XJtCyC8*$ r    c               `    t         xr' t        t        t        |rt	        |       n|       d      S )NrS   )_TORCH_AVAILABLEra   r   r   re   rf   s     r   _check_for_torchru      ri   r    c               `    t         xr' t        t        t        |rt	        |       n|       d      S )NrT   )_PYTZ_AVAILABLEra   r   r   re   rf   s     r   _check_for_pytzrx      s*     yXJtCyC8&  r    c           
        ddl m} ddlm} | j	                  dd      d   }	 t        |       }	|ra ||      } ||	j                        }||k  rB| d| ddj                  d |D               ddj                  d |D               d} ||      |	S # t        $ rS |r|j                  d       dnd}
|rd|j                  d       nd}|
 d|  d| d	|xs d
| dz   }t        |      dw xY w)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)ModuleUpgradeRequiredErrorrW       r+   'z.
z.Please install using the command `pip install z`.Nc              3  2   K   | ]  }t        |        y wr"   rX   rY   vs     r   r\   z"import_optional.<locals>.<genexpr>-  s     8qCF8   z or higher (found c              3  2   K   | ]  }t        |        y wr"   rX   r   s     r   r\   z"import_optional.<locals>.<genexpr>.  s     #@qCF#@r   ))polars._utils.variousrz   polars.exceptionsr{   splitr   ImportErrorstripr1   r*   join)r   
err_prefix
err_suffixmin_versionmin_err_prefixinstall_messagerz   r{   module_rootr&   prefixsuffixerr_messagemod_versionr3   s                  r   import_optionalr      s>   H 4<##C+A.K	9{+ #K0#F$6$67$!"!K=888K889 :88#@K#@@AD 
 -S11M)  90:J$$S)*!,0:1Z%%c*+,+axs; P?}BO
 "+.D89s   B AC/)%rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   r   r   r   rQ   rR   r   rS   rT   rh   rl   ro   rr   ru   rx   _ALTAIR_AVAILABLE_DELTALAKE_AVAILABLE_FSSPEC_AVAILABLE_GEVENT_AVAILABLE_GREAT_TABLES_AVAILABLE_HYPOTHESIS_AVAILABLErd   rk   _POLARS_CLOUD_AVAILABLErn   rq   _PYICEBERG_AVAILABLErt   )r   r6   r8   ztuple[ModuleType, bool])r`   re   r[   r6   r8   r7   )rg   r
   rb   r7   r8   r7   )zrequired packagez	not foundNrequiresN)r   r6   r   r6   r   r6   r   zstr | tuple[int, ...] | Noner   r6   r   z
str | Noner8   r
   )@
__future__r   r.   rA   collections.abcr   	functoolsr   	importlibr   importlib.utilr   typesr   typingr	   r
   r   r   r   r   r   r   r   r   rd   rk   r   rn   rq   r   rt   rw   r   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   r   r   r   rQ   rR   rT   rS   _ra   rh   rl   ro   rr   ru   rx   r   __all__ r    r   <module>r      s   " 	 
 $  # $  5 5             J5* J5Z*Z  "-0NK6"GD!6"GD!X&IFA .MJ !-X 6F&2;&?#I# ,X 6F ,X 6F,8,H)L)(4\(B%J%*73E ,X 6F,8,H)L)".y"9G$0$<!H!&2;&?#I#*73E(0D/   6:  7;  8<  9=  6:  59  )!04$"&>>> > .	>
 >  > 	>B*r    