o
    Vi8                     @  sJ  U d Z ddlm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mZ ddlmZ ddlmZmZmZmZ er[ddlmZmZ dd	lmZ dd
lmZ G dd deZeeZde d< d%ddZ!e! Z"de d< dZ#de d< e$dej%Z&de d< G dd dZ'd&dd Z(d'd"d#Z)ed$kre)  dS dS )(zdConcrete Python interpreter information, also used as subprocess interrogation script (stdlib only).    )annotationsN)OrderedDict)digits)TYPE_CHECKINGClassVarFinal
NamedTuple)	GeneratorMapping   )PyInfoCache)
PythonSpecc                   @  s6   e Zd ZU ded< ded< ded< ded< ded< dS )	VersionInfointmajorminormicrostrreleaselevelserialN)__name__
__module____qualname____annotations__ r   r   M/home/ubuntu/.local/lib/python3.10/site-packages/python_discovery/_py_info.pyr      s   
 r   zFinal[logging.Logger]_LOGGERreturn	list[str]c                   C  s*   t tdgtjdd tjS )N PATHEXT)	listr   fromkeysosenvirongetlowersplitpathsepr   r   r   r   _get_path_extensions$   s   *r)   zFinal[list[str]]
EXTENSIONS   z
Final[int]_32BIT_POINTER_SIZEzB
    \{ \w+  }   # sysconfig variable placeholder like {base}
    zFinal[re.Pattern[str]]_CONF_VAR_REc                   @  s>  e Zd ZU dZdddZdddZddd	Zdd
dZdddZe	dddZ
dddZdddZdddZe	dddZedddZedd d!Zedd"d#Zedd%d&Zedd'd(Zd)ejfdd-d.Zedd/d0Zedd1d2Zedd3d4Zdd5d6Zdd7d8Zedd9d:Zedd;d<Zedd?d@Z ddDdEZ!ddFdGZ"ddHdIZ#ddJdKZ$d)Z%d)Z&edddMdNZ'edddOdPZ(ddQdRZ)ddTdUZ*e	)ddVdWdVd)dXdd`daZ+eddcddZ,eddfdgZ-eddidjZ.i Z/dke0dl< dVd)dmddpdqZ1ddwdxZ2e	ddydzZ3dd}d~Z4dddZ5dddZ6d)S )
PythonInfoz.Contains information for a Python interpreter.r   Nonec                 C  s$   |    |   |   |   d S N)_init_identity_init_prefixes_init_schemes_init_sysconfigselfr   r   r   __init__5   s   zPythonInfo.__init__c                 C  s   t j| _t | _| jdkrtt j| _tt j | _t	dt
kr#dnd| _t | _td| _t j| _tj| _tddk| _d S )NPyPyP    @   py_version_nodotPy_GIL_DISABLEDr   )sysplatformpython_implementationimplementationtuplepypy_version_infor   version_infostructcalcsizer,   architecture	sysconfigget_platformsysconfig_platformget_config_varversion_nodotversionr#   namefree_threadedr5   r   r   r   r1   ;   s   


zPythonInfo._init_identityc                 C  s   ddd}|t tdd | _|t tdd | _|t tdd | _|t td	d | _|t td
d | _|tj| _|| j| _| 	 | _
ztd d}W n tyV   d}Y nw || _tj| _t | _t tjdd | _d S )Nvalue
str | Noner   c                 S  s   | d u rd S t j| S r0   )r#   pathabspath)rP   r   r   r   abs_pathK   s   z+PythonInfo._init_prefixes.<locals>.abs_pathprefixbase_prefixreal_prefixbase_exec_prefixexec_prefixvenvTFencoding)rP   rQ   r   rQ   )getattrr>   rU   rV   rW   rX   rY   
executableoriginal_executable_fast_get_system_executablesystem_executable
__import__ImportErrorhas_venvrR   getfilesystemencodingfile_system_encodingstdoutstdout_encoding)r6   rT   hasr   r   r   r2   J   s&   


zPythonInfo._init_prefixesc                   s   t  }d|v rd _ fddt  D  _i  _d S tjd d dkr=d|v r=d _ fddt  D  _i  _d S d  _d	d t  D  _  	  _d S )
NrZ   c                       i | ]}|t j|d  jdqS F)expandschemerH   get_pathsysconfig_scheme.0ir5   r   r   
<dictcomp>g       z,PythonInfo._init_schemes.<locals>.<dictcomp>   )   
   
deb_systemposix_prefixc                   ri   rj   rm   rp   r5   r   r   rs   n   rt   c                 S  s   i | ]
}|t j|d dqS )F)rk   )rH   rn   rp   r   r   r   rs   t       )
rH   get_scheme_namesro   get_path_namessysconfig_pathsdistutils_installr>   rD   _distutils_installcopy)r6   scheme_namesr   r5   r   r3   b   s    



zPythonInfo._init_schemesc                   s  t tdt tdd }dd d|d ur| nd ffD  _t } j D ]}|dd t|D  q$|d |d	 d
d |D  _	dt
jv rT  \ _ _nd\ _ _ fdd j	 D } d| _ d| _t tdt tdd  _d  _d S )Nget_makefile_filename_get_makefile_filenamec                 S  s   i | ]\}}|d ur||qS r0   r   rq   kvr   r   r   rs   y   s
    z.PythonInfo._init_sysconfig.<locals>.<dictcomp>makefile_filenamec                 s  s    | ]	}|d d V  qdS )r   Nr   )rq   r   r   r   r   	<genexpr>   s    z-PythonInfo._init_sysconfig.<locals>.<genexpr>PYTHONFRAMEWORK)Py_ENABLE_SHARED
INSTSONAMELIBDIRc                 S  s   i | ]
}|t |p
d qS r   )rH   rK   rp   r   r   r   rs      rz   TCL_LIBRARYNNc                   2   i | ]\}}|t |tr| jr jn|qS r   
isinstancer   
startswithrU   system_prefixr   r5   r   r   rs           stdlib
platstdlibmaxsizemaxint)r\   rH   setr}   valuesupdater-   findalladdsysconfig_varsr#   r$   _get_tcl_tk_libstcl_libtk_libitemssysconfig_pathsystem_stdlibsystem_stdlib_platformr>   max_size	_creators)r6   makefileconfig_var_keyselementconfsr   r5   r   r4   w   s*   




zPythonInfo._init_sysconfigtuple[str | None, str | None]c            	      C  sH  d\} }zddl }W n ty   Y | |fS w z| }|d} z|d}|r0tj|r0nd}W n |jy?   d}Y nw |du r|d}tj| }|d	|
ddd |
dd g}|D ]'}tj	|d	| }tj|sxqetjtj	|d
r|} nqeW | |fS W | |fS W | |fS  |jy   Y | |fS w )z.Detect the tcl and tk libraries using tkinter.r   r   Nzinfo libraryzset tk_libraryzpackage require Tk.ru   tkztk.tcl)tkinterrb   Tclevalr#   rR   isdirTclErrordirnamejoinr'   exists)	r   r   r   tcl
tk_version
tcl_parentversion_variantsrM   tk_lib_pathr   r   r   r      sX   '


zPythonInfo._get_tcl_tk_libsrQ   c                 C  sp   | j s| jdur| j| jks| jS | j durdS ttdd}|du r$dS tj|kr+dS tj	|r3|S | 
|S )z?Try to get the system executable by just looking at properties.N_base_executable)rW   rV   rU   r^   r\   r>   r]   r#   rR   r   _try_posix_fallback_executable)r6   base_executabler   r   r   r_      s   


z&PythonInfo._fast_get_system_executabler   r   c              	   C  s   | j j| j j}}| jdks||fdk rdS tj|}d| d| d| g}| jdkr@|ddd| d| d| g |D ]}tj||}tj	|rU|  S qBdS )	zJFind a versioned Python binary as fallback for POSIX virtual environments.posix)rv      Npythonr   r8   pypypypy3)
rD   r   r   r#   rR   r   rA   extendr   r   )r6   r   r   r   base_dir
candidates	candidate	full_pathr   r   r   r      s   
$z)PythonInfo._try_posix_fallback_executablekeyc                   sZ   | j |}|du r+| j| j| j| jf  fdd| j D }| j||d	t
j}|S )z
        Return the relative installation path for a given installation scheme *key*.

        :param key: sysconfig installation scheme key (e.g. ``"scripts"``, ``"purelib"``).
        Nc                   s"   i | ]\}}|| v rd n|qS r   r   r   prefixesr   r   rs     s   " z+PythonInfo.install_path.<locals>.<dictcomp>)
config_var)r~   r%   rU   rY   rV   rX   r   r   r   lstripr#   sep)r6   r   resultr   r   r   r   install_path   s   zPythonInfo.install_pathdict[str, str]c               	     s   t  . t d zddlm}  ddlm} W n ty*   i  Y W  d    S w W d    n1 s5w   Y  | ddi}t	t
drId t
_t   t d |jdd	d
 W d    n1 sdw   Y  tj _    fdd|D S )Nignorer   )dist)SCHEME_KEYSscript_argsz--no-user-cfg
_frameworkinstallT)createc                   s.   i | ]}|t  d | dd tjqS )install_r   N)r\   r   r#   r   )rq   r   r   r   r   rs     s   . z1PythonInfo._distutils_install.<locals>.<dictcomp>)warningscatch_warningssimplefilter	distutilsr   distutils.command.installr   rb   Distributionhasattrr>   r   get_command_objr#   r   rU   finalize_options)r   r   distributionr   r   r   r     s.   




zPythonInfo._distutils_installc                 C     d dd | jdd D S )zCThe full version as ``major.minor.micro`` string (e.g. ``3.13.2``).r   c                 s      | ]}t |V  qd S r0   r   rp   r   r   r   r   #      z)PythonInfo.version_str.<locals>.<genexpr>r   rv   r   rD   r5   r   r   r   version_str      zPythonInfo.version_strc                 C  r   )z>The release version as ``major.minor`` string (e.g. ``3.13``).r   c                 s  r   r0   r   rp   r   r   r   r   (  r   z1PythonInfo.version_release_str.<locals>.<genexpr>r   ru   r   r5   r   r   r   version_release_str%  r   zPythonInfo.version_release_strc                 C  s   | j }d|j d|j S )zBThe python executable name as ``pythonX.Y`` (e.g. ``python3.13``).r   r   )rD   r   r   )r6   rD   r   r   r   python_name*  s   zPythonInfo.python_nameboolc                 C  
   | j duS )zW``True`` if this interpreter runs inside an old-style virtualenv (has ``real_prefix``).N)rW   r5   r   r   r   is_old_virtualenv0     
zPythonInfo.is_old_virtualenvc                 C  r   )zN``True`` if this interpreter runs inside a PEP 405 venv (has ``base_prefix``).N)rV   r5   r   r   r   is_venv5  r   zPythonInfo.is_venvNr   dict[str, str] | Noner   c                 C  sX   | j |}|du rdS |du r| j}n| j }|| |}|jdi |d|S )ap  
        Return the sysconfig install path for a scheme *key*, optionally substituting config variables.

        :param key: sysconfig path key (e.g. ``"purelib"``, ``"include"``).
        :param config_var: replacement mapping for sysconfig variables; when ``None`` uses the interpreter's own values.
        :param sep: path separator to use in the result.
        Nr   /r   )r}   r%   r   r   r   formatreplace)r6   r   r   r   patternbaser   r   r   r   :  s   

zPythonInfo.sysconfig_pathc                   s^     d fdd j D }tj|s-tj jtj 	d}tj|r-|}|S )z7The path to the system include directory for C headers.includec                   r   r   r   r   r5   r   r   rs   R  r   z-PythonInfo.system_include.<locals>.<dictcomp>headers)
r   r   r   r#   rR   r   r   rU   r   r   )r6   rR   fallbackr   r5   r   system_includeM  s   
zPythonInfo.system_includec                 C     | j p| jp| jS )z=The prefix of the system Python this interpreter is based on.)rW   rV   rU   r5   r   r   r   r   ]     zPythonInfo.system_prefixc                 C  r   )zBThe exec prefix of the system Python this interpreter is based on.)rW   rX   rY   r5   r   r   r   system_exec_prefixb  r   zPythonInfo.system_exec_prefixc                 C  s    d | jjdd | j D S )Nz{}({!r})c                 S  s    i | ]\}}| d s||qS )_)r   r   r   r   r   rs   j  s     z'PythonInfo.__repr__.<locals>.<dictcomp>)r   	__class__r   __dict__r   r5   r   r   r   __repr__g  s   zPythonInfo.__repr__c                 C  s   d | jjddd d| jf| jd ur| j| jkrdnd | jf| j| j| jhvr*dnd | jfd| jfd	| jfd
t	| j
fd| j d| j ffD S )Nz{}({})z, c                 s  s*    | ]\}}|d ur| d| V  qd S )N=r   r   r   r   r   r   p  s    z%PythonInfo.__str__.<locals>.<genexpr>specsystemoriginalexer?   rM   encoding_fs_io-)r   r  r   r   r  r`   r]   r^   r?   reprrM   re   rg   r5   r   r   r   __str__m  s*   
zPythonInfo.__str__c                 C  sJ   | j }|du r	dS |dkrdS |ddd }|dkr!t  }t|S )	zZReturn the instruction set architecture (ISA) derived from :func:`sysconfig.get_platform`.Nunknownwin32x86r  r   r   
universal2)rJ   rsplitr?   machiner&   normalize_isa)r6   platisar   r   r   r    s   zPythonInfo.machinec                 C  s4   d | jddd | jD | jrdnd| j| jS )zVA specification string identifying this interpreter (e.g. ``CPython3.13.2-64-arm64``).z{}{}{}-{}-{}r   c                 s  r   r0   r   rp   r   r   r   r     r   z"PythonInfo.spec.<locals>.<genexpr>tr   )r   rA   r   rD   rO   rG   r  r5   r   r   r   r    s   zPythonInfo.speccacher   c                 C  s"   ddl m} || | j  dS )zy
        Clear all cached interpreter information from *cache*.

        :param cache: the cache store to clear.
        r   )clearN)_cached_py_infor  _cache_exe_discovery)clsr  r  r   r   r   clear_cache  s   zPythonInfo.clear_cacher  r   impl_must_matchc                C  s   |j r
| |s
dS |r| |sdS |jdur |j| jkr dS |jdur-|j| jkr-dS |jdur:|j| jkr:dS |jdurF| |sFdS tdd t	| j
dd |j|j|jfD S )z
        Check if a given specification can be satisfied by this python interpreter instance.

        :param spec: the specification to check against.
        :param impl_must_match: when ``True``, the implementation name must match exactly.
        FNc                 s  s,    | ]\}}|d u p|d u p||kV  qd S r0   r   )rq   ourreqr   r   r   r     s
    
z'PythonInfo.satisfies.<locals>.<genexpr>r   rv   )rR   _satisfies_path_satisfies_implementationrG   r  rO   version_specifier_satisfies_version_specifierallziprD   r   r   r   )r6   r  r  r   r   r   	satisfies  s   zPythonInfo.satisfiesc                 C  s|   | j tj|jkrdS |jrdS tj| j}|j}tjdkr:tj	|\}}|r8|
|r8|d t|  n|}||kS )NTr  )r]   r#   rR   rS   is_absbasenamer^   r>   r?   splitextendswithlen)r6   r  r*  	spec_pathsuffixr   r   r   r"    s   
$zPythonInfo._satisfies_pathc                 C  s   |j d u p|j  | j  kS r0   )rA   r&   )r6   r  r   r   r   r#    s   z$PythonInfo._satisfies_implementationc                 C  sr   |j d u rdS | j}|j d|j d|j }|jdkr3dddd|j}|d ur3| | |j }|j |S )NTr   finalabrc)alphabetar   )	r$  rD   r   r   r   r   r%   r   contains)r6   r  rD   releaser/  r   r   r   r%    s   

z'PythonInfo._satisfies_version_specifierPyInfoCache | Nonec                 C  s>   | j du r| jtj|ddd}|du rd}t||| _ | j S )z
        Locate the current host interpreter information.

        :param cache: interpreter metadata cache; when ``None`` results are not cached.
        NTFraise_on_errorresolve_to_hostz*failed to query current Python interpreter)_currentfrom_exer>   r]   RuntimeErrorr  r  r   msgr   r   r   current     
zPythonInfo.currentc                 C  s>   | j du r| jtj|ddd}|du rd}t||| _ | j S )z
        Locate the current system interpreter information, resolving through any virtualenv layers.

        :param cache: interpreter metadata cache; when ``None`` results are not cached.
        NTr9  z1failed to query current system Python interpreter)_current_systemr=  r>   r]   r>  r?  r   r   r   current_system  rB  zPythonInfo.current_systemc                 C  s   t j|  ddS )z8Serialize this interpreter information to a JSON string.ru   )indent)jsondumpsto_dictr5   r   r   r   to_json   s   zPythonInfo.to_jsondict[str, object]c                   s<    fddt  D }|d }t|dr| n||d< |S )z;Convert this interpreter information to a plain dictionary.c                   s$   i | ]}||d krt  |ndqS )r   N)r\   )rq   varr5   r   r   rs     s   $ z&PythonInfo.to_dict.<locals>.<dictcomp>rD   _asdict)varsr   rL  )r6   datarD   r   r5   r   rH    s   zPythonInfo.to_dictTF)r:  ignore_cacher;  envr
  r:  rO  r;  rP  Mapping[str, str] | NonePythonInfo | Nonec          
   
   C  s   ddl m} |du rtjn|}|| |||||d}t|trJ|rJz	|||}W |S  tyI }	 z|r4 t	d|j
|	 d}W Y d}	~	|S d}	~	ww |S )a  
        Get the python information for a given executable path.

        :param exe: path to the Python executable.
        :param cache: interpreter metadata cache; when ``None`` results are not cached.
        :param raise_on_error: raise on failure instead of returning ``None``.
        :param ignore_cache: bypass the cache and re-query the interpreter.
        :param resolve_to_host: resolve through virtualenv layers to the system interpreter.
        :param env: environment mapping; defaults to :data:`os.environ`.
        r   )r=  N)rP  r:  rO  z-ignore %s due cannot resolve system due to %r)r  r=  r#   r$   r   r.   resolve_to_system	Exceptionr   infor^   )
r  r
  r  r:  rO  r;  rP  r=  proposed	exceptionr   r   r   r=    s    zPythonInfo.from_exepayloadc                 C  s   t |}| | S )z
        Deserialize interpreter information from a JSON string.

        :param payload: JSON produced by :meth:`to_json`.
        )rF  loads	from_dictr   )r  rX  rawr   r   r   	from_json/  s   
zPythonInfo.from_jsonrN  c                 C  s*   t di |d |d< |  }| |_|S )z
        Reconstruct a :class:`PythonInfo` from a plain dictionary.

        :param data: dictionary produced by :meth:`to_dict`.
        rD   Nr   )r   r   r  )r  rN  r   r   r   r   rZ  9  s   
zPythonInfo.from_dicttargetc                 C  s  |j }t }|jdu rk|jp|jp|j}||v rZt|dkr)td| |j |_nBt	|
 ddD ]\}\}}td||| q1tdt|d || dd| }	t|	|||< |j||dd	}|jdu s|j |jkr~| |j|}
|
dur~|
}||_ |S )
z
        Walk virtualenv/venv prefix chains to find the underlying system interpreter.

        :param cache: interpreter metadata cache; when ``None`` results are not cached.
        :param target: the interpreter to resolve.
        Nr   z$%r links back to itself via prefixes)startz%d: prefix=%s, info=%rz prefixes are causing a circle {}|F)rU   exact)r]   r   r`   rW   rV   rU   r-  r   rU  	enumerater   errorr   r   keysr>  discover_exer=  )r  r  r]  start_executabler   rU   atpr  r@  resolvedr   r   r   rS  E  s.   

zPythonInfo.resolve_to_systemz,ClassVar[dict[tuple[str, bool], PythonInfo]]r  )r`  rP  rU   r`  c             
   C  s  ||f}|| j v r|rtd||| j |  | j | S td| | |  }| |}g }|du r4tjn|}|D ]!}	|D ]}
| j||	|
|||d}|durX|| j |< |    S q<q8|du rz|rz| || }tj	
|}|| j |< td|| |S dd
|tj	
|}t|)	aS  
        Discover a matching Python executable under a given *prefix* directory.

        :param cache: interpreter metadata cache.
        :param prefix: directory prefix to search under.
        :param exact: when ``True``, require an exact version match.
        :param env: environment mapping; defaults to :data:`os.environ`.
        z)discover exe from cache %s - exact %s: %rzdiscover exe for %s in %sN)r`  FzFno exact match found, chosen most similar of %s within base folders %szfailed to detect {} in {}r_  )r  r   debug_find_possible_exe_names_find_possible_foldersr#   r$   
_check_exe_select_most_likelyr(   r   r   r>  )r6   r  rU   r`  rP  r   possible_namespossible_folders
discoveredfolderrN   rU  foldersr@  r   r   r   rd  f  s2   



zPythonInfo.discover_exerq  rN   rp  list[PythonInfo]Mapping[str, str]c                C  s   t j||}t j|sd S | j||dd|d}|d u rd S dD ]A}	t||	}
t| |	}|
|krb|	dkrJddd |
D ddd |D }
}|j}td||	|
| |du r_|	|  d S q!|S )	NF)r;  r:  rP  )rA   rG   r  rD   rD   r   c                 s  r   r0   r   rp   r   r   r   r     r   z(PythonInfo._check_exe.<locals>.<genexpr>z2refused interpreter %s because %s differs %s != %s)
r#   rR   r   r   r=  r\   r]   r   ri  append)r6   r  rq  rN   rp  rP  r`  exe_pathrU  itemfoundsearchedr]   r   r   r   rl    s(   


*
	zPythonInfo._check_exec                   s$   d
 fdd}t | |dd}|d	 S )NrU  r.   r   r   c              	     s   | j  j k| jj jjk| jj jjk| j jk| j jk| jj jjk| jj jjk| jj jjkg}t	dd t
t|D S )Nc                 s  s$    | ]\}}|rd |> ndV  qdS )r   r   Nr   )rq   posmatchr   r   r   r     s   " zBPythonInfo._select_most_likely.<locals>.sort_by.<locals>.<genexpr>)rA   rD   r   r   rG   r  r   r   r   sumra  reversed)rU  matchesr]  r   r   sort_by  s   



z/PythonInfo._select_most_likely.<locals>.sort_byT)r   reverser   )rU  r.   r   r   )sorted)rp  r]  r  sorted_discoveredr   r  r   rm    s   zPythonInfo._select_most_likelyinside_folderr   c                 C  s   t  }t  }d |tj| j< d || j< d |tj| j< d || j< |D ]}tj|}|| jrC|t	| jd  }d || | < q$d ||< dd |D S )Nc                 S  s   g | ]
}t j|r|qS r   )r#   rR   r   rp   r   r   r   
<listcomp>  rz   z5PythonInfo._find_possible_folders.<locals>.<listcomp>)
r   r#   rR   realpathr]   r^   r   r   rU   r-  )r6   r  candidate_folderexecutablesr
  r   relativer   r   r   rk    s   

z!PythonInfo._find_possible_foldersc           
   
   C  s   t  }|  D ]F}dD ]A}ddd | jd | D }dg}| jr'|d |D ]"}d| j dfD ]}tD ]}| | | | | }	d ||	< q7q3q)qqt|	 S )N)rv   ru   r   r   r   c                 s  r   r0   r   rp   r   r   r   r     r   z6PythonInfo._find_possible_exe_names.<locals>.<genexpr>r   r  r  )
r   _possible_baser   rD   rO   ru  rG   r*   r!   rc  )
r6   name_candidaterN   rf  rM   modsmodarchextr   r   r   r   rj    s"   


z#PythonInfo._find_possible_exe_namesGenerator[str, None, None]c                 c  s    t  }tjtj| jd t}d ||< d || j< d|v r$|d= d |d< |D ]$}|	 }|V  ddl
m} | rN||krC|V  | }||krN|V  q*d S )Nr   r   r   )fs_is_case_sensitive)r   r#   rR   r+  r*  r]   rstripr   rA   r&   _compatr  upper)r6   possible_baser*  r   r&   r  r  r   r   r   r    s(    
zPythonInfo._possible_baser   r/   )r   r   )r   rQ   )r   r   r   rQ   )r   r   r   r   )r   r   )r   r   )r   r   )r   r   r   r   r   r   r   r   )r  r   r   r/   )r  r   r  r   r   r   )r  r   r   r   r0   )r  r8  r   r.   )r   rJ  )r
  r   r  r8  r:  r   rO  r   r;  r   rP  rQ  r   rR  )rX  r   r   r.   )rN  rJ  r   r.   )r  r8  r]  r.   r   r.   )
r  r   rU   r   r`  r   rP  rQ  r   r.   )r  r8  rq  r   rN   r   rp  rs  rP  rt  r`  r   r   rR  )rp  rs  r]  r.   r   r.   )r  r   r   r   r   r   )r   r  )7r   r   r   __doc__r7   r1   r2   r3   r4   staticmethodr   r_   r   r   r   propertyr   r   r   r   r   r#   r   r   r   r   r  r  r  r  r  classmethodr  r(  r"  r#  r%  rC  r<  rA  rD  rI  rH  r=  r\  rZ  rS  r  r   rd  rl  rm  rk  rj  r  r   r   r   r   r.   2   s   
 




 
2










#	
(

r.   r  r   c                 C  s   |   }ddd||S )Nx86_64arm64)amd64aarch64)r&   r%   )r  lowr   r   r   r    s   r  r/   c               
   C  s   t jdd  } t| dkr| d }| dd  } nd}t| dkr+| d }| dd  } nd}t jd d |  t _t  }t jd|d d d ||d d d f t j  d S )Nr   r   r   r   )	r>   argvr-  r.   rI  rf   writer   flush)r  start_cookie
end_cookier   r   r   r   _main  s   
,r  __main__r  )r  r   r   r   r  )*r  
__future__r   rF  loggingr#   r?   rerE   r>   rH   r   collectionsr   stringr   typingr   r   r   r   collections.abcr	   r
   _cacher   _py_specr   r   	getLoggerr   r   r   r)   r*   r,   compileVERBOSEr-   r.   r  r  r   r   r   r   <module>   sL    
     
J

