3
ØLôYI  ã               @   sš   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
 ddddgZG d	d„ dƒZd
d„ Zddd„Zddd„Zddd„Zdd„ Zeƒ  dS )é    N)ÚStrictVersion)ÚPKG_DIRECTORYÚPY_COMPILEDÚ	PY_SOURCEÚ	PY_FROZEN)ÚsixÚRequireÚfind_moduleÚget_module_constantÚextract_constantc               @   sH   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   sF   |d kr|d k	rt }|d k	r0||ƒ}|d kr0d}| jjtƒ ƒ | `d S )NÚ__version__)r   Ú__dict__ÚupdateÚlocalsÚself)r   ÚnameÚrequested_versionÚmoduleZhomepageÚ	attributeÚformat© r   úl/private/var/folders/7d/20zwc49s3kn54d3vgq8bd4640000gn/T/pip-build-an2lx5zf/setuptools/setuptools/depends.pyÚ__init__   s    zRequire.__init__c             C   s    | j dk	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   s*   | j dkp(| jdkp(t|ƒdko(|| jkS )z%Is 'version' sufficiently up-to-date?NÚunknown)r   r   Ústrr   )r   Úversionr   r   r   Ú
version_ok%   s    zRequire.version_okr   c             C   s|   | j dkrBy"t| j|ƒ\}}}|r*|jƒ  |S  tk
r@   dS X t| j| j ||ƒ}|dk	rx||k	rx| jdk	rx| j|ƒ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   | j |ƒdk	S )z/Return true if dependency is present on 'paths'N)r'   )r   r!   r   r   r   Ú
is_presentE   s    zRequire.is_presentc             C   s    | j |ƒ}|dkrdS | j|ƒS )z>Return true if dependency is present and up-to-date on 'paths'NF)r'   r   )r   r!   r   r   r   r   Ú
is_currentI   s    
zRequire.is_current)r   NN)Nr   )N)N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r'   r(   r)   r   r   r   r   r      s    


c             c   s¼   ddl m } ddlm}m} |d| jƒ}t| jƒ}d}d}x|||k r¶|| }||krž||d  ||d  d  | }	|d7 }||krªtjd }
|	|
d	ƒ }q<nd
}	|d7 }||	fV  q<W d
S )z>Yield '(op,arg)' pair for each operation in code object 'code'r   )Úarray)ÚHAVE_ARGUMENTÚEXTENDED_ARGÚbé   é   é   é   i   Néÿÿÿÿ)r.   Zdisr/   r0   Úco_codeÚlenr   Úinteger_types)Úcoder.   r/   r0   ÚbytesÚeofÚptrZextended_argÚopÚargZ	long_typer   r   r   Ú
_iter_codeQ   s$    

 
r@   c       
      C   sl   | j dƒ}x\|rf|jdƒ}tj||ƒ \}}\}}}}	|tkrP|pFdg}|g}q|rtd|| f ƒ‚qW |	S )z7Just like 'imp.find_module()', but with package supportÚ.r   r   zCan't find %r in %s)ÚsplitÚpopÚimpr	   r   r    )
r   r!   ÚpartsÚpartr#   ÚpathÚsuffixÚmodeÚkindÚinfor   r   r   r	   r   s    


r2   c       
      C   sÎ   yt | |ƒ\}}\}}}W n tk
r.   dS X z‚|tkrP|jdƒ tj|ƒ}	n`|tkrdtj| ƒ}	nL|t	kr~t
|jƒ |dƒ}	n2| tjkržtj| |||||fƒ ttj|  |dƒS W d|rÀ|jƒ  X 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    r   ÚreadÚmarshalÚloadr   rD   Úget_frozen_objectr   ÚcompileÚsysÚmodulesÚload_moduleÚgetattrr   r   )
r   Úsymbolr"   r!   r#   rG   rH   rI   rJ   r:   r   r   r   r
   …   s$    


c       
      C   s|   || j krdS t| j ƒj|ƒ}d}d}d}|}xHt| ƒD ]<\}}	||krT| j|	 }q8|	|krp||ksl||krp|S |}q8W 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Úindexr@   Ú	co_consts)
r:   rW   r"   Zname_idxZ
STORE_NAMEZSTORE_GLOBALZ
LOAD_CONSTÚconstr>   r?   r   r   r   r   §   s    
c              C   sD   t jjdƒ rt jdkrdS d} x| D ]}tƒ |= tj|ƒ q&W 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ÚcliNr   r
   )r   r
   )rS   ÚplatformÚ
startswithÚglobalsÚ__all__Úremove)Zincompatibler   r   r   r   Ú_update_globalsÊ   s    
rg   )Nr6   )r6   Nr6   )r6   )rS   rD   rO   Zdistutils.versionr   r   r   r   r   Zsetuptools.externr   re   r   r@   r	   r
   r   rg   r   r   r   r   Ú<module>   s   C!

"
#