3
fL @ s d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl
Z
d dlZdd Zdd Z
dd Zdd Zd
d ZdS ) Nc C s t jdd} | jddd | jdddd tjjd
| j }d}yttf t | W n4 t
k
r } ztdj| d
}W Y d d }~X nX tj
d
d S )Nz,Recreate wheel of package with given RECORD.)Zdescriptionrecord_pathzPath to RECORD file)helpz-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.outdir)r destdefaultr z
Failed: {} )argparseArgumentParseradd_argumentospathcurdir
parse_argsprintrewheel_from_recordvars
BaseExceptionformatsysexit)parsernsZretcodee r ?/opt/alt/python36/lib64/python3.6/ensurepip/rewheel/__init__.pyrun
s r c s g }t jtjtjg}dd |D }x| D ]}d}xd|D ]\tjj|djtj fddtj
D } fdd|D }t|dkr8|d }q8W |dk r|jtjj|d q*|jd q*W |S )
zReturn 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
c S s g | ]}t jj|r|qS r )r r exists).0spr r r
( s z'find_system_records..Nz-[^\{0}]+\.dist-infoc s g | ]}t jj |qS r )r r join)r p)r r r r . s c s g | ]}t j |r|qS r )rematch)r c)dist_info_rer r r 0 s r r ZRECORD)
sitegetsitepackagesr base_prefixbase_exec_prefixr r r r seplistdirlenappend)ZprojectsZrecordsZsys_sitepackZprojectr Z
candidatesZfilteredr )r% r r find_system_records s
r. c C s t jjt jj| }| t|d jt jj}t||\}}t| }t jj||d }t j
|dt jd}tj
} tj| }
x:|D ]2\}}}
|jt jj|||d |
j|||
g qW |
j|ddg |j|| j |j |jS )zcRecreates a whee of package with given record_path and returns path
to the newly created wheel.Nz.whlw)modeZcompression)Zarcname )r r dirnamer, stripr* get_records_to_packget_wheel_namer zipfileZZipFileZZIP_DEFLATEDioStringIOcsvwriterwriteZwriterowZwritestrgetvalueclosefilename)r r site_dirrecord_relpathto_writeto_omitZnew_wheel_nameZnew_wheel_pathZ new_wheelZ
new_recordr: fZsha_hashsizer r r r : s
r c C s t jjt jj| d}tj|dd}tjj j |j
}W dQ R X t jjt jj| d}tj|dd}tjj j |j
}W dQ R X |jd}|jd}d} g }
x&|jd D ]}|
j
|jd
d qW dj|
}
|jd jd
d
d \}}
td||| |
||
g}d
jt|S )z.Return proper name of the wheel, without .whl.ZWHEELzutf-8)encodingNZMETADATANameZVersionr1 ZTag-r .r )r r r r2 codecsopenemailr ZParserZparsestrreadgetZget_allr- splitfilterlist)r Zwheel_info_pathZwheel_info_fileZ
wheel_infoZ
metadata_pathZ
metadata_fileZmetadataZdistributionversionZ build_tagZlang_tagtZabi_tagZplat_tagZto_joinr r r r5 V s
r5 c
C s t jj| |}tj|dd}|j }W dQ R X t jj|jt jj}|dt d d }g }g }x|j
D ]}|jd} t | dkrnt jj| d s| d j
d s| d jd
s| d jds| d |ks| d j
|r|j| q|j| qnqnW ||fS )a Accepts 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)rE Nz dist-infodata,rI r z..z.pycz.pyo)r r r rJ rK rM r2 r3 r* r,
splitlinesrO isabs
startswithendswithr- )
r? r@ Zrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrA rB lZsplr r r r4 n s"
r4 )r rJ r9 Zemail.parserrL r r7 r" r&