3
A|e`                  @   s   d Z ddlm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mZ ddlmZ ddlmZ ddlmZ e	jd	e	jjZd
Zdd ZG dd dZdS )zWheels support.    )get_platform)logN)parse_version)sys_tags)canonicalize_name)write_requirementsz^(?P<project_name>.+?)-(?P<version>\d.*?)
    ((-(?P<build>\d.*?))?-(?P<py_version>.+?)-(?P<abi>.+?)-(?P<platform>.+?)
    )\.whl$z8__import__('pkg_resources').declare_namespace(__name__)
c             C   s   xt j| D ]\}}}t jj|| }x6|D ].}t jj||}t jj|||}t j|| q*W xXttt|D ]D\}	}
t jj||
}t jj|||
}t jj	|snt j|| ||	= qnW qW x0t j| ddD ]\}}}| st
t j| qW dS )zDMove everything under `src_dir` to `dst_dir`, and delete the former.T)topdownN)oswalkpathrelpathjoinrenamesreversedlist	enumerateexistsAssertionErrorrmdir)src_dirZdst_dirdirpathdirnames	filenamessubdirfsrcdstnd r   T/var/www/html/StaffProfile/staffvenv/lib/python3.6/site-packages/setuptools/wheel.pyunpack   s    

r!   c               @   sh   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	e
dd Ze
dd Ze
dd ZdS )Wheelc             C   sT   t tjj|}|d kr$td| || _x$|j j D ]\}}t| || q8W d S )Nzinvalid wheel name: %r)	
WHEEL_NAMEr	   r   basename
ValueErrorfilename	groupdictitemssetattr)selfr&   matchkvr   r   r    __init__6   s    zWheel.__init__c             C   s&   t j| jjd| jjd| jjdS )z>List tags (py_version, abi, platform) supported by this wheel..)	itertoolsproduct
py_versionsplitabiplatform)r*   r   r   r    tags>   s    

z
Wheel.tagsc                s0   t dd t D  t fdd| j D dS )z5Is the wheel is compatible with the current platform?c             s   s   | ]}|j |j|jfV  qd S )N)interpreterr4   r5   ).0tr   r   r    	<genexpr>I   s    z&Wheel.is_compatible.<locals>.<genexpr>c             3   s   | ]}| krd V  qdS )TNr   )r8   r9   )supported_tagsr   r    r:   J   s    F)setr   nextr6   )r*   r   )r;   r    is_compatibleF   s    zWheel.is_compatiblec             C   s,   t j| j| j| jdkrd nt dj d S )Nany)project_nameversionr5   z.egg)pkg_resourcesDistributionr@   rA   r5   r   egg_name)r*   r   r   r    rD   L   s    zWheel.egg_namec             C   sJ   x<|j  D ]0}tj|}|jdr
t|jt| jr
|S q
W tdd S )Nz
.dist-infoz.unsupported wheel format. .dist-info not found)namelist	posixpathdirnameendswithr   
startswithr@   r%   )r*   zfmemberrG   r   r   r    get_dist_infoR   s    

zWheel.get_dist_infoc          
   C   s(   t j| j}| j|| W dQ R X dS )z"Install wheel as an egg directory.N)zipfileZipFiler&   _install_as_egg)r*   destination_eggdirrJ   r   r   r    install_as_egg\   s    zWheel.install_as_eggc             C   s\   d| j | jf }| j|}d| }tjj|d}| j|||| | j|| | j|| d S )Nz%s-%sz%s.datazEGG-INFO)	r@   rA   rL   r	   r   r   _convert_metadata_move_data_entries_fix_namespace_packages)r*   rP   rJ   Zdist_basename	dist_info	dist_dataegg_infor   r   r    rO   a   s    
zWheel._install_as_eggc                sL  fdd}|d}t |jd}t d|  ko>t dk n  }|sTtd| tj| j| tjj|tj	j
|tj|d d	d
 ttt j  fdd jD }tj| tjtjj|dtjj|d tj	t|dd}	tjj}
tjtj z t|	jdd tjj|d W d tj|
 X d S )Nc          	      s<   j tj |  }|j jd}tjj j|S Q R X d S )Nzutf-8)	openrF   r   readdecodeemailparserParserparsestr)namefpvalue)rU   rJ   r   r    get_metadatam   s    z-Wheel._convert_metadata.<locals>.get_metadataWHEELzWheel-Versionz1.0z2.0dev0z$unsupported wheel format version: %s)metadatac             S   s   d | _ t| S )N)markerstr)reqr   r   r    raw_req   s    z(Wheel._convert_metadata.<locals>.raw_reqc                s2   i | ]*}t fd dt j|fD |qS )c             3   s   | ]}| kr|V  qd S )Nr   )r8   rg   )install_requiresr   r    r:      s   z5Wheel._convert_metadata.<locals>.<dictcomp>.<genexpr>)sortedmaprequires)r8   extra)distri   rh   r   r    
<dictcomp>   s   z+Wheel._convert_metadata.<locals>.<dictcomp>METADATAzPKG-INFO)ri   extras_require)attrsrW   zrequires.txt)r   getr%   r	   mkdir
extractallr   r   rB   rC   from_locationPathMetadatar   rj   rk   rl   extrasrename
setuptoolsdictr   _global_log	thresholdset_thresholdWARNr   get_command_obj)rJ   rP   rU   rW   rb   Zwheel_metadatawheel_versionZwheel_v1rq   Z
setup_distZlog_thresholdr   )rn   rU   ri   rh   rJ   r    rR   k   sB     



zWheel._convert_metadatac                s   t jj|   t jj d}t jj|rt jj| dd}t j| xRt j|D ]D}|jdrrt jt jj|| qNt jt jj||t jj|| qNW t j	| x.t
t jj fdddD D ]}t||  qW t jj rt j	  d
S )z,Move data entries to their correct location.scriptszEGG-INFOz.pycc             3   s   | ]}t jj |V  qd S )N)r	   r   r   )r8   r   )rV   r   r    r:      s   z+Wheel._move_data_entries.<locals>.<genexpr>dataheaderspurelibplatlibN)r   r   r   r   )r	   r   r   r   rt   listdirrH   unlinkry   r   filterr!   )rP   rV   Zdist_data_scriptsZegg_info_scriptsentryr   r   )rV   r    rS      s&    





zWheel._move_data_entriesc             C   s   t jj| d}t jj|rt|}|j j }W d Q R X xt|D ]l}t jj|f|jd }t jj|d}t jj|st j| t jj|s@t|d}|jt	 W d Q R X q@W d S )Nznamespace_packages.txtr/   z__init__.pyw)
r	   r   r   r   rX   rY   r3   rt   writeNAMESPACE_PACKAGE_INIT)rW   rP   namespace_packagesr`   modZmod_dirZmod_initr   r   r    rT      s    


zWheel._fix_namespace_packagesN)__name__
__module____qualname__r.   r6   r>   rD   rL   rQ   rO   staticmethodrR   rS   rT   r   r   r   r    r"   4   s   

@r"   )__doc__distutils.utilr   	distutilsr   r[   r0   r	   rF   rerM   rB   rz   r   Z setuptools.extern.packaging.tagsr   Z!setuptools.extern.packaging.utilsr   Zsetuptools.command.egg_infor   compileVERBOSEr+   r#   r   r!   r"   r   r   r   r    <module>   s(   
