Spade
Mini Shell
| Directory:~$ /proc/self/root/lib64/python3.6/ensurepip/rewheel/__pycache__/ |
| [Home] [System Details] [Kill Me] |
3
k��hM�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZdd�Zdd�Z
dd�Zdd �Zd
d�ZdS)�NcCs�tjdd�}|jddd�|jdddd tjjd
�|j�}d}yttft |���Wn4t
k
r�}ztdj|��d
}WYdd}~XnXtj
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
srcs�g}tjtjtjg�}dd�|D�}x�|D]�}d}xd|D]\�tjj�|�djtj ���fdd�tj
��D�}�fdd�|D�}t|�dkr8|d}q8W|dk r�|jtjj|d ��q*|jd�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)rr
�exists)�.0�sprrr�
<listcomp>(sz'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infocsg|]}tjj�|��qSr)rr
�join)r�p)rrrr
.scsg|]}tj�|�r|�qSr)�re�match)r�c)�dist_info_rerrr
0srrZRECORD)
�site�getsitepackagesr�base_prefix�base_exec_prefixrr
r!r�sep�listdir�len�append)ZprojectsZrecordsZsys_sitepackZprojectr
Z
candidatesZfilteredr)r&rr�find_system_recordss
r/cCs�tjjtjj|��}|t|�d�jtjj�}t||�\}}t|�}tjj||d�}t j
|dt jd�}tj
�} 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�)rr
�dirnamer-�stripr+�get_records_to_pack�get_wheel_namer!�zipfileZZipFileZZIP_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&|jd �D]}|
j
|jd
�d�q�Wdj|
�}
|jd �jd
�d
d�\}}
td||| |
||
g�}d
jt|��S)z.Return proper name of the wheel, without
.whl.ZWHEELzutf-8)�encodingNZMETADATA�NameZVersionr2ZTag�-r�.r�)rr
r!r3�codecs�open�emailrZParserZparsestr�read�getZget_allr.�split�filter�list)rZwheel_info_pathZwheel_info_fileZ
wheel_infoZ
metadata_pathZ
metadata_fileZmetadataZdistribution�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)rr
r!rKrLrNr3r4r+r-�
splitlinesrP�isabs�
startswith�endswithr.)
r@rAZrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrBrC�lZsplrrrr5ns"
r5)r rKr:Zemail.parserrMrr8r#r'�
subprocessrr7rr/rr6r5rrrr�<module>s