<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 fL                 @   s   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	Z	d dl
Z
d dlZdd Zdd Zdd Zdd	 Zd
d ZdS )    Nc              C   s   t jdd} | jddd | jdddd	tjjd
 | j }d}yttf t	| W n4 t
k
r } ztdj| d}W Y d d }~X nX tjd d S )Nz,Recreate wheel of package with given RECORD.)Zdescriptionrecord_pathzPath to RECORD file)helpz-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.outdir)r   destdefaultr   z
Failed: {}   )argparseArgumentParseradd_argumentospathcurdir
parse_argsprintrewheel_from_recordvarsBaseExceptionformatsysexit)parsernsZretcodee r   ?/opt/alt/python36/lib64/python3.6/ensurepip/rewheel/__init__.pyrun   s    r   c                s   g }t jtjtjg}dd |D }x| D ]}d}xd|D ]\tjj|djtj	  fddtj
D } fdd|D }t|dkr8|d }q8W |dk	r|jtjj|d	 q*|jd 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 jj|r|qS r   )r   r   exists).0spr   r   r   
<listcomp>(   s    z'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infoc                s   g | ]}t jj |qS r   )r   r   join)r   p)r   r   r   r   .   s    c                s   g | ]}t j |r|qS r   )rematch)r   c)dist_info_rer   r   r   0   s    r   r   ZRECORD)sitegetsitepackagesr   base_prefixbase_exec_prefixr   r   r    r   seplistdirlenappend)ZprojectsZrecordsZsys_sitepackZprojectr   Z
candidatesZfilteredr   )r%   r   r   find_system_records   s    

r.   c             C   s   t jjt jj| }| t|d jt jj}t||\}}t| }t jj||d }t	j
|dt	jd}tj }	tj|	}
x:|D ]2\}}}|jt jj|||d |
j|||g qW |
j|ddg |j||	j  |j  |jS )zcRecreates a whee of package with given record_path and returns path
    to the newly created wheel.Nz.whlw)modeZcompression)Zarcname )r   r   dirnamer,   stripr*   get_records_to_packget_wheel_namer    zipfileZZipFileZZIP_DEFLATEDioStringIOcsvwriterwriteZwriterowZwritestrgetvalueclosefilename)r   r   site_dirrecord_relpathto_writeto_omitZnew_wheel_nameZnew_wheel_pathZ	new_wheelZ
new_recordr:   fZsha_hashsizer   r   r   r   :   s    
r   c             C   s  t jjt jj| d}tj|dd}tjj j	|j
 }W dQ R X t jjt jj| d}tj|dd}tjj j	|j
 }W dQ R X |jd}|jd}d}	g }
x&|jd	D ]}|
j|jd
d  qW dj|
}
|jd	jd
dd \}}td|||	|
||g}d
jt|S )z.Return proper name of the wheel, without .whl.ZWHEELzutf-8)encodingNZMETADATANameZVersionr1   ZTag-r   .r      )r   r   r    r2   codecsopenemailr   ZParserZparsestrreadgetZget_allr-   splitfilterlist)r   Zwheel_info_pathZwheel_info_fileZ
wheel_infoZmetadata_pathZmetadata_fileZmetadataZdistributionversionZ	build_tagZlang_tagtZabi_tagZplat_tagZto_joinr   r   r   r5   V   s     


r5   c       
      C   s   t jj| |}tj|dd}|j }W dQ R X t jj|jt jj}|dt	d  d }g }g }x|j
 D ]}|jd}	t	|	dkrnt jj|	d s|	d jd	s|	d jd
s|	d jds|	d |ks|	d j|r|j|	 q|j|	 qnqnW ||fS )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)
    zutf-8)rE   Nz	dist-infodata,rI   r   z..z.pycz.pyo)r   r   r    rJ   rK   rM   r2   r3   r*   r,   
splitlinesrO   isabs
startswithendswithr-   )
r?   r@   Zrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrA   rB   lZsplr   r   r   r4   n   s"    
r4   )r   rJ   r9   Zemail.parserrL   r   r7   r"   r&   
subprocessr   r6   r   r.   r   r5   r4   r   r   r   r   <module>   s   