Your IP : 3.135.195.74


Current Path : /lib64/python3.6/ensurepip/rewheel/__pycache__/
Upload File :
Current File : //lib64/python3.6/ensurepip/rewheel/__pycache__/__init__.cpython-36.pyc

3

�meM�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZdd�Zdd�Z
dd�Zdd	�Zd
d�ZdS)�NcCs�tjdd�}|jddd�|jdddd	tjjd
�|j�}d}yttft	|���Wn4t
k
r�}ztdj|��d
}WYdd}~XnXtj
d
�dS)Nz,Recreate wheel of package with given RECORD.)�description�record_pathzPath to RECORD file)�helpz-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.�outdir)r�dest�defaultrz
Failed: {}�)�argparse�ArgumentParser�add_argument�os�path�curdir�
parse_args�print�rewheel_from_record�vars�
BaseException�format�sys�exit)�parser�nsZretcode�e�r� /usr/lib64/python3.6/__init__.py�run
srcs�g}tjtjtjg�}dd�|D�}x�|D]�}d}xd|D]\�tjj�|�djtj	���fdd�tj
��D�}�fdd�|D�}t|�dkr8|d}q8W|dk	r�|jtjj|d	��q*|jd�q*W|S)
z�Return list of paths to RECORD files for system-installed projects.

    If a project is not installed, the resulting list contains None instead
    of a path to its RECORD
    cSsg|]}tjj|�r|�qSr)rr
�exists)�.0�sprrr�
<listcomp>(sz'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infocsg|]}tjj�|��qSr)rr
�join)r�p)rrrr .scsg|]}tj�|�r|�qSr)�re�match)r�c)�dist_info_rerrr 0srrZRECORD)
�site�getsitepackagesr�base_prefix�base_exec_prefixrr
r!r�sep�listdir�len�append)ZprojectsZrecordsZsys_sitepackZprojectr
Z
candidatesZfilteredr)r&rr�find_system_recordss

r/cCs�tjjtjj|��}|t|�d�jtjj�}t||�\}}t|�}tjj||d�}t	j
|dt	jd�}tj
�}	tj|	�}
x:|D]2\}}}
|jtjj||�|d�|
j|||
g�q�W|
j|ddg�|j||	j��|j�|jS)zcRecreates a whee of package with given record_path and returns path
    to the newly created wheel.Nz.whl�w)�modeZcompression)Zarcname�)rr
�dirnamer-�stripr+�get_records_to_pack�get_wheel_namer!�zipfileZZipFileZZIP_DEFLATED�io�StringIO�csv�writer�writeZwriterowZwritestr�getvalue�close�filename)rr�site_dir�record_relpath�to_write�to_omitZnew_wheel_nameZnew_wheel_pathZ	new_wheelZ
new_recordr;�fZsha_hash�sizerrrr:s
rcCstjjtjj|�d�}tj|dd��}tjj�j	|j
��}WdQRXtjjtjj|�d�}tj|dd��}tjj�j	|j
��}WdQRX|jd�}|jd�}d}	g}
x&|jd	�D]}|
j
|jd
�d�q�Wdj|
�}
|jd	�jd
�d
d�\}}
td|||	|
||
g�}d
jt|��S)z.Return proper name of the wheel, without .whl.ZWHEELzutf-8)�encodingNZMETADATA�NameZVersionr2ZTag�-r�.r�)rr
r!r3�codecs�open�emailrZParserZparsestr�read�getZget_allr.�split�filter�list)rZwheel_info_pathZwheel_info_fileZ
wheel_infoZ
metadata_pathZ
metadata_fileZmetadataZdistribution�versionZ	build_tagZlang_tag�tZabi_tagZplat_tagZto_joinrrrr6Vs 


r6c
Cstjj||�}tj|dd��}|j�}WdQRXtjj|�jtjj�}|dt	d��d}g}g}x�|j
�D]�}|jd�}	t	|	�dkrntjj|	d�s�|	dj
d	�s�|	djd
�s�|	djd�s�|	d|ks�|	dj
|�r�|j|	�q�|j|	�qnqnW||fS)aAccepts path of sitedir and path of RECORD file relative to it.
    Returns two lists:
    - list of files that can be written to new RECORD straight away
    - list of files that shouldn't be written or need some processing
      (pyc and pyo files, scripts)
    zutf-8)rFNz	dist-info�data�,rJrz..z.pycz.pyo)rr
r!rKrLrNr3r4r+r-�
splitlinesrP�isabs�
startswith�endswithr.)
r@rAZrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrBrC�lZsplrrrr5ns"
r5)r	rKr:Zemail.parserrMrr8r#r'�
subprocessrr7rr/rr6r5rrrr�<module>s