Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib/python3.6/site-packages/wheel/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib/python3.6/site-packages/wheel/__pycache__/install.cpython-36.pyc

3

Dt�Z-J�@s,dZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZdd	lmZmZmZmZmZmZmZy
e	jZWnek
r�e	jZYnXdZ ej!d
ej"�j#Z$dd�a%Gd
d�de&�Z'Gdd�de(�Z)Gdd�de&�Z*Gdd�dej+�Z,dS)zC
Operations on existing wheel files, including basic installation.
�)�print_functionN�)�
signatures)�get_install_paths)�
get_supported)�read_pkg_info_bytes)�urlsafe_b64encode�	from_json�urlsafe_b64decode�native�binary�HashingFile�open_for_csvz�^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))(-(?P<build>\d.*?))?
     -(?P<pyver>[a-z].+?)-(?P<abi>.+?)-(?P<plat>.+?)(\.whl|\.dist-info)$cCs:yddlmaWn tk
r0ddlmaYnXt|�S)z?Use parse_version from pkg_resources or distutils as available.r)�
parse_version)�LooseVersion)�
pkg_resourcesr�ImportError�distutils.versionr)�version�r�>/opt/alt/python36/lib/python3.6/site-packages/wheel/install.pyr(s
rc@s"eZdZdZdd�Zddd�ZdS)�reifyz�Put the result of a method which uses this (non-data)
    descriptor decorator in the instance dict after the first call,
    effectively replacing the decorator with an instance variable.
    cCs||_|j|_dS)N)�wrapped�__doc__)�selfrrrr�__init__8szreify.__init__NcCs*|dkr|S|j|�}t||jj|�|S)N)r�setattr�__name__)r�instZobjtype�valrrr�__get__<s

z
reify.__get__)N)r�
__module__�__qualname__rrr rrrrr2src@seZdZdS)�BadWheelFileN)rr!r"rrrrr#Dsr#c@s$eZdZdZdZdZddefdd�Zdd	�Ze	d
d��Z
e	dd
��Ze	dd��Ze	dd��Z
e	dd��ZeZe	dd��Ze	dd��Ze	dd��Zdd�Zdd�Ze	dd��Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zed,d-��Zed.d/��Zd0d1�Zed2d3��Z difd4d5�Z!d8d6d7�Z"dS)9�	WheelFilez�Parse wheel-specific attributes from a wheel (.whl) file and offer
    basic installation and verification support.

    WheelFile can be used to simply parse a wheel filename by avoiding the
    methods that require the actual file contents.ZWHEEL�RECORDNFcCsT||_||_||_||_tjj|�}t|�|_|j	d�sD|jdkrPt
d|��dS)a
        :param fp: A seekable file-like object or None to open(filename).
        :param append: Open archive in append mode.
        :param context: Function returning list of supported tags. Wheels
        must have the same context to be sortable.
        z.whlNzBad filename '%s')�filename�fp�append�context�os�path�basename�
WHEEL_INFO_RE�parsed_filename�endswithr#)rr&r'r(r)r,rrrrRs
zWheelFile.__init__cCs|jS)N)r&)rrrr�__repr__fszWheelFile.__repr__cCsd|jjd�S)Nz%s.dist-info�namever)r.�group)rrrr�
distinfo_nameiszWheelFile.distinfo_namecCsd|jjd�S)Nz%s.datar1)r.r2)rrrr�datadir_namemszWheelFile.datadir_namecCsd|j|jfS)Nz%s/%s)r3r%)rrrr�record_nameqszWheelFile.record_namecCsd|j|jfS)Nz%s/%s)r3�
WHEEL_INFO)rrrr�wheelinfo_nameuszWheelFile.wheelinfo_nameccsb|jj�}xR|djd�D]@}x:|djd�D](}x"|djd�D]}|||fVqBWq.WqWdS)a�A wheel file is compatible with the Cartesian product of the
        period-delimited tags in its filename.
        To choose a wheel file among several candidates having the same
        distribution version 'ver', an installer ranks each triple of
        (pyver, abi, plat) that its Python installation can run, sorting
        the wheels by the best-ranked tag it supports and then by their
        arity which is just len(list(compatibility_tags)).
        �pyver�.�abi�platN)r.�	groupdict�split)r�tagsr8r:r;rrrr>ys


zWheelFile.tagscCstt|j��S)z4The number of compatibility tags the wheel declares.)�len�list�compatibility_tags)rrrr�arity�szWheelFile.aritycCs|j|j��S)zo
        Lowest index of any of this wheel's tags in self.context(), and the
        arity e.g. (0, 1)
        )�compatibility_rankr))rrrr�rank�szWheelFile.rankcCs|jdtkS)Nr)rD�_big_number)rrrr�
compatible�szWheelFile.compatiblecCs\g}x8|jD].}y|j|j|��Wqtk
r8YqXqWt|�rTt|�|jfStdfS)z�Rank the wheel against the supported tags. Smaller ranks are more
        compatible!

        :param supported: A list of compatibility tags that the current
            Python implemenation can run.
        r)rAr(�index�
ValueErrorr?�minrBrE)rZ	supportedZpreferences�tagrrrrC�s
zWheelFile.compatibility_rankcCs|j|kstd��|jS)Nzcontext mismatch)r)�AssertionErrorrF)r�xrrr�supports_current_python�sz!WheelFile.supports_current_pythoncCs2|jjd�t|jjd��tdd�|jD��|jfS)N�name�vercss|]}|VqdS)Nr)�.0rLrrr�	<genexpr>�sz&WheelFile._sort_key.<locals>.<genexpr>)r.r2r�tuplerDr&)rrrr�	_sort_key�s
zWheelFile._sort_keycCs|j|jkS)N)r&)r�otherrrr�__eq__�szWheelFile.__eq__cCs|j|jkS)N)r&)rrTrrr�__ne__�szWheelFile.__ne__cCs�|j|jkrtdj||���|j|jkSt|jjd��}t|jjd��}||krX||kS|j|jkrttdj||���|j}|j}|dk	r�|dk	r�||kr�||kS|dkr�|dk	r�dS|j|jkS)Nz{0}.context != {1}.contextrNrOF)	r)�	TypeError�formatrSr.r2rrDr&)rrTZsn�on�svZovZsc�ocrrr�__lt__�s(zWheelFile.__lt__cCs||kS)Nr)rrTrrr�__gt__�szWheelFile.__gt__cCs||kp||kS)Nr)rrTrrr�__le__�szWheelFile.__le__cCs||kp||kS)Nr)rrTrrr�__ge__�szWheelFile.__ge__cCs:d}|jrd}t|jr|jn|j|�}|js6|j|�|S)N�r�a)r(�VerifyingZipFiler'r&�verify)r�modeZvzfrrr�zipfile�s
zWheelFile.zipfilecCst|jj|j��S)z+Parse wheel metadata (the .data/WHEEL file))rre�readr7)rrrr�parsed_wheel_info�szWheelFile.parsed_wheel_infocCs.|jd}ttt|jd���tkr*td��dS)Nz
Wheel-Versionr9zWheel version is too high)rgrR�map�intr=�VERSION_TOO_HIGHrH)rrrrr�
check_versions
zWheelFile.check_versioncCs|jjd�}t|�S)ac
        Consult distutils to get the install paths for our dist.  A dict with
        ('purelib', 'platlib', 'headers', 'scripts', 'data').

        We use the name from our filename as the dist name, which means headers
        could be installed in the wrong place if the filesystem-escaped name
        is different than the Name.  Who cares?
        rN)r.r2r)rrNrrr�
install_pathss
zWheelFile.install_pathscs4��fdd�}�jddkr&|d�}n|d�}i}x��jj�D]�}|j}|jd�rTq>|jd�rj|d	d
�}|jd�\}}	}
|	r�|�jkr�|
jd�\}}	}
|	s�tdj	|���||�}nd}|}|}
t
jjt
jj
||
��}
|||
|
f||<q>W|�s4xB|j�D]6\}}|j}|\}}}
}
t
jj|
�r�td
j	||
���q�Wtjjtj��}g}�jd}�xn|j�D�]`\}\}}}
}
|j}�jj|�}||k�r��q^t
jj|
�}t
jj|��s�t
j|�|
d}y`t|d��L}|dk�r|j�}|jd��r�d|tt
j�}|j|�tj||�Wd
QRXWn0t k
�rLt
jj|��rFt
j!|��YnXt
j"||
�t
jj#|
|�}|j$t
j%d�|j&||j'�|j(f�|j)�|j)�|j*d?}|�r^t
j+|
|j*d?��q^Wt
jj
|�j,�}t-|d��L}t.j/|�}x(t0|�D]\}}}|j1|||f��q�W|j1�j,ddf�Wd
QRXd
S)z7
        Install the wheel into site-packages.
        cs�j|�p�j|S)N)�getrl)�key)�	overridesrrr�get_pathsz#WheelFile.install.<locals>.get_pathzRoot-Is-Purelib�true�purelib�platlib�/z./�NzInvalid filename in wheel: {0}�zAWheel file {0} would overwrite {1}. Use force if this is intendedz/RECORDz.part�wb�scriptss#!pythons#!�zw+)2rgre�infolistr&r/�
startswith�	partitionr4rHrXr*r+�normpath�join�items�exists�sys�
executable�encode�getfilesystemencodingr3�open�dirname�isdir�makedirsr
�readliner�linesep�write�shutil�copyfileobj�
BaseException�unlink�rename�relpath�replace�sepr(�digest�length�close�
external_attr�chmodr5r�csv�writer�sortedZwriterow)r�forcerorp�rootZ
name_trans�inforNZbasedirr�r&rn�target�dest�v�kZexenameZrecord_datar5�sourceZddirZ
temp_filenameZdestinationZhashbangZreldest�attrsZrecord_filer�r�r�r)rorr�installs�











zWheelFile.installcCs�d}|dkr|j}d|_dj|jdf�}dj|jdf�}dj|jdf�}|j|d�|j|d�|j|d�|j|�}ttj|�j	��}yt
t|j|���}Wntk
r�YnX|r�t
j|�\}}	|	ddt|�kr�d	}
t|
j|	dt|����tjd
d�|j�D��}x�|D]z}|d}
|d
}|�sR|
||fk�rtd|
tjd��q|d
jdd
�\}}|dk�sxtd��|j|
tt|����qWdS)aConfigure the VerifyingZipFile `zipfile` by verifying its signature
        and setting expected hashes for every hash in RECORD.
        Caller must complete the verification process by completely reading
        every file in the archive (e.g. with extractall).NTrtr%z
RECORD.jwsz
RECORD.p7s�hashzsha256=z6RECORD.jws claimed RECORD hash {} != computed hash {}.css|]}t|d�VqdS)zutf-8N)r)rPr`rrrrQ�sz#WheelFile.verify.<locals>.<genexpr>rrz%s has no hash!)�file�=�sha256zUnsupported hash algorithm)re�strictr~r3�set_expected_hashrfr�hashlibr�r�r	r�KeyErrorrrcr#rXr��reader�
splitlines�printr��stderrr=rKr
r)rre�sigr5Zsig_nameZsmime_sig_name�recordZ
record_digest�headers�payload�msgr��rowr&r�Zalgo�datarrrrc�sB

zWheelFile.verify)N)#rr!r"rr6r%rrr0�propertyr3r4r5r7r>rArBrDrFrCrMrSrUrVr\r]r^r_rrergrkrlr�rcrrrrr$Hs>

|r$csHeZdZdZdejdf�fdd�	Zdd�Zd
�fd	d
�	Zdd�Z	�Z
S)rbz�ZipFile that can assert that each of its extracted contents matches
    an expected sha256 hash. Note that each file must be completely read in
    order for its hash to be checked.r`Tcs.tt|�j||||�d|_i|_tj|_dS)NF)�superrbrr��_expected_hashesr�r��_hash_algorithm)rr�rd�compression�
allowZip64)�	__class__rrr�szVerifyingZipFile.__init__cCs||j|<dS)zn
        :param name: name of zip entry
        :param hash: bytes of hash (or None for "don't care")
        N)r�)rrNr�rrrr��sz"VerifyingZipFile.set_expected_hashNc
s�tt|�j|||��t|tj�r(|j}n|}||jkr�|j|dk	r�|j|�y
�j�Wnt	k
rvt
jd��SX|j��t
�d�r�����fdd�}nd����fdd�	}|�_n|jr�||jkr�td�j���S)	z#Return file-like object for 'name'.NzRNeed ZipExtFile._update_crc to implement file hash verification (in Python >= 2.7)�_eofcs6�|��j|��jr2�j��kr2td�j��dS)NzBad hash for file %r)�updater�r�r#rN)r�)�_update_crc_orig�ef�
expected_hash�running_hashrr�_update_crc�s
z*VerifyingZipFile.open.<locals>._update_crccs8�||d��j|�|r4�j��kr4td�j��dS)N)�eofzBad hash for file %r)r�r�r#rN)r�r�)r�r�r�r�rrr��s
zNo expected hash for file %r)N)r�rbr��
isinstancere�ZipInfor&r�r��AttributeError�warnings�warnr��hasattrr�r#rN)rZname_or_inford�pwdrNr�)r�)r�r�r�r�rr��s&



zVerifyingZipFile.opencCsJ|jstd��|j�j�}|j|j=|jj|jtj	�|jj
�d|_dS)z�Truncate the last file off this zipfile.
        Assumes infolist() is in the same order as the files (true for
        ordinary zip files created by Python)z7Attempt to pop from ZIP archive that was already closedTN)r'�RuntimeErrorrz�pop�
NameToInfor&�seek�
header_offsetr*�SEEK_SET�truncate�
_didModify)r�lastrrrr��s

zVerifyingZipFile.pop)r`N)rr!r"rre�
ZIP_STOREDrr�r�r��
__classcell__rr)r�rrb�s#rb)rr)-r�
__future__rr�r��os.pathr*�rer�r�r�rervr�pathsrZ
pep425tagsrZpkginfor�utilrr	r
rrr
r�maxsizerE�	NameErrorZmaxintrj�compile�VERBOSE�matchr-r�objectrrHr#r$�ZipFilerbrrrr�<module>s:$


w