o
    Ëý°j{  ã                   @   s”   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mZm	Z	m
Z
 ddlmZ g d¢ZG dd„ dƒZd	d
„ Zddd„Zddd„Zdd„ Zeƒ  dS )é    N)Úversioné   )Úfind_moduleÚPY_COMPILEDÚ	PY_FROZENÚ	PY_SOURCE)Ú_imp)ÚRequirer   Úget_module_constantÚextract_constantc                   @   sL   e Zd ZdZ		ddd„Zdd„ Zdd	„ Zddd„Zddd„Zddd„Z	dS )r	   z7A prerequisite to building or installing a distributionÚ Nc                 C   sH   |d u r|d urt j}|d ur||ƒ}|d u rd}| j tƒ ¡ | `d S )NÚ__version__)r   ÚVersionÚ__dict__ÚupdateÚlocalsÚself)r   ÚnameÚrequested_versionÚmoduleÚhomepageÚ	attributeÚformat© r   ú…/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/setuptools/depends.pyÚ__init__   s   zRequire.__init__c                 C   s    | j durd| j| j f S | jS )z0Return full package/distribution name, w/versionNz%s-%s)r   r   )r   r   r   r   Ú	full_name#   s   
zRequire.full_namec                 C   s0   | j du p| jdu pt|ƒdko|  |¡| jkS )z%Is 'version' sufficiently up-to-date?NÚunknown)r   r   Ústrr   )r   r   r   r   r   Ú
version_ok)   s   ÿzRequire.version_okr   c                 C   s~   | j du r"zt| j|ƒ\}}}|r| ¡  |W S  ty!   Y dS w t| j| j ||ƒ}|dur=||ur=| jdur=|  |¡S |S )a×  Get version number of installed module, 'None', or 'default'

        Search 'paths' for module.  If not found, return 'None'.  If found,
        return the extracted version attribute, or 'default' if no version
        attribute was specified, or the value cannot be determined without
        importing the module.  The version is formatted according to the
        requirement's version format (if any), unless it is 'None' or the
        supplied 'default'.
        N)r   r   r   ÚcloseÚImportErrorr
   r   )r   ÚpathsÚdefaultÚfÚpÚiÚvr   r   r   Úget_version.   s   
ÿ
zRequire.get_versionc                 C   s   |   |¡duS )z/Return true if dependency is present on 'paths'N)r(   )r   r"   r   r   r   Ú
is_presentI   s   zRequire.is_presentc                 C   s$   |   |¡}|du rdS |  t|ƒ¡S )z>Return true if dependency is present and up-to-date on 'paths'NF)r(   r   r   )r   r"   r   r   r   r   Ú
is_currentM   s   
zRequire.is_current)r   NN)Nr   ©N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r(   r)   r*   r   r   r   r   r	      s    
þ

r	   c                 C   s"   t jdd„ ƒ}| s|ƒ S t  | ¡S )Nc                   s   s   � d V  d S r+   r   r   r   r   r   ÚemptyV   s   €zmaybe_close.<locals>.empty)Ú
contextlibÚcontextmanagerÚclosing)r$   r0   r   r   r   Úmaybe_closeU   s
   

r4   éÿÿÿÿc                 C   sÞ   zt | |ƒ \}}\}}}}	W n
 ty   Y dS w t|ƒ�C |tkr.| d¡ t |¡}
n,|tkr9t 	| |¡}
n!|t
krFt| ¡ |dƒ}
nt | ||	¡}t||dƒW  d  ƒ S W d  ƒ n1 sdw   Y  t|
||ƒS )züFind 'module' by searching 'paths', and extract 'symbol'

    Return 'None' if 'module' does not exist on 'paths', or it does not define
    'symbol'.  If the module defines 'symbol' as a constant, return the
    constant.  Otherwise, return 'default'.Né   Úexec)r   r!   r4   r   ÚreadÚmarshalÚloadr   r   Úget_frozen_objectr   ÚcompileÚ
get_moduleÚgetattrr   )r   Úsymbolr#   r"   r$   ÚpathÚsuffixÚmodeÚkindÚinfoÚcodeÚimportedr   r   r   r
   `   s&   þ


õ€ r
   c                 C   s†   || j vrdS t| j ƒ |¡}d}d}d}|}t | ¡D ]$}|j}	|j}
|	|kr.| j|
 }q|
|kr>|	|ks:|	|kr>|  S |}qdS )a  Extract the constant value of 'symbol' from 'code'

    If the name 'symbol' is bound to a constant value by the Python code
    object 'code', return that value.  If 'symbol' is bound to an expression,
    return 'default'.  Otherwise, return 'None'.

    Return value is based on the first assignment to 'symbol'.  'symbol' must
    be a global, or at least a non-"fast" local in the code block.  That is,
    only 'STORE_NAME' and 'STORE_GLOBAL' opcodes are checked, and 'symbol'
    must be present in 'code.co_names'.
    NéZ   éa   éd   )Úco_namesÚlistÚindexÚdisÚBytecodeÚopcodeÚargÚ	co_consts)rE   r?   r#   Úname_idxÚ
STORE_NAMEÚSTORE_GLOBALÚ
LOAD_CONSTÚconstÚ	byte_codeÚoprP   r   r   r   r   }   s    
÷r   c                  C   s>   t j d¡st jdkrdS d} | D ]}tƒ |= t |¡ qdS )z•
    Patch the globals to remove the objects not available on some platforms.

    XXX it'd be better to test assertions about bytecode instead.
    ÚjavaÚcliN)r   r
   )ÚsysÚplatformÚ
startswithÚglobalsÚ__all__Úremove)Úincompatibler   r   r   r   Ú_update_globals¡   s   þrb   )r5   N)r5   )r[   r9   r1   rM   Úsetuptools.extern.packagingr   r   r   r   r   r   r   r_   r	   r4   r
   r   rb   r   r   r   r   Ú<module>   s    D

$
