Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/wheel/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/wheel/__pycache__/install.cpython-35.pyc



/U�U�F�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	y
ej
ZWnek
r�ej
ZYnXddlmZddlmZmZmZmZmZmZddlmZddlmZddlmZdd	lmZdd
lmZddfZ ej!dej"�j#Z$dd
�a%Gdd�de&�Z'Gdd�de(�Z)Gdd�dej*�Z+dS)zD
Operations on existing wheel files, including basic installation. 
�N)�reify)�urlsafe_b64encode�	from_json�urlsafe_b64decode�native�binary�HashingFile)�
signatures)�read_pkg_info_bytes)�open_for_csv�)�
get_supported)�get_install_pathsz�^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
    ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
    \.whl|\.dist-info)$cCsCyddlmaWn"tk
r8ddlmaYnXt|�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/python35/lib/python3.5/site-packages/wheel/install.pyr*s

rc@seZdZdS)�BadWheelFileN)�__name__�
__module__�__qualname__rrrrr3src@s�eZdZdZdZdZddedd�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 did4d5�Z!dd6d7�Z"dS)8�	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�RECORDNFcCsx||_||_||_||_tjj|�}t|�|_|j	d�sd|jdkrtt
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)�selfrrrr r#rrr�__init__As				zWheelFile.__init__cCs|jS)N)r)r'rrr�__repr__UszWheelFile.__repr__cCsd|jjd�S)Nz%s.dist-info�namever)r%�group)r'rrr�
distinfo_nameXszWheelFile.distinfo_namecCsd|jjd�S)Nz%s.datar*)r%r+)r'rrr�datadir_name\szWheelFile.datadir_namecCsd|j|jfS)Nz%s/%s)r,r)r'rrr�record_name`szWheelFile.record_namecCsd|j|jfS)Nz%s/%s)r,�
WHEEL_INFO)r'rrr�wheelinfo_namedszWheelFile.wheelinfo_nameccs{|jj�}xe|djd�D]P}xG|djd�D]2}x)|djd�D]}|||fVqWWq=Wq#WdS)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'�tagsr1r3r4rrrr7hs

zWheelFile.tagscCstt|j��S)z4The number of compatibility tags the wheel declares.)�len�list�compatibility_tags)r'rrr�arityzszWheelFile.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 )r'rrr�rankszWheelFile.rankcCs|jdtkS)Nr)r=�_big_number)r'rrr�
compatible�szWheelFile.compatiblecCsrg}x@|jD]5}y|j|j|��Wqtk
rDYqXqWt|�rht|�|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)r:r�index�
ValueErrorr8�minr;r>)r'Z	supportedZpreferences�tagrrrr<�s
	zWheelFile.compatibility_rankcCs"|j|kstd��|jS)Nzcontext mismatch)r �AssertionErrorr?)r'�xrrr�supports_current_python�sz!WheelFile.supports_current_pythoncCsG|jjd�t|jjd��tdd�|jD��|jfS)N�name�vercss|]}|VqdS)Nr)�.0rErrr�	<genexpr>�sz&WheelFile._sort_key.<locals>.<genexpr>)r%r+r�tupler=r)r'rrr�	_sort_key�szWheelFile._sort_keycCs|j|jkS)N)r)r'�otherrrr�__eq__�szWheelFile.__eq__cCs|j|jkS)N)r)r'rMrrr�__ne__�szWheelFile.__ne__cCsP|j|jkr*tdj||���|j|jkS|jjd�}|jjd�}||krt||kSt|jjd��}t|jjd��}||kr�||kS|j|jkr�tdj||���|j}|j}|dkr$|dkr$||kr$||kS|dkr@|dkr@dS|j|jkS)Nz{0}.context != {1}.contextrGrHF)	r �	TypeError�formatrLr%r+rr=r)r'rMZsn�on�svZovZsc�ocrrr�__lt__�s(

		$
zWheelFile.__lt__cCs
||kS)Nr)r'rMrrr�__gt__�szWheelFile.__gt__cCs||kp||kS)Nr)r'rMrrr�__le__�szWheelFile.__le__cCs||kp||kS)Nr)r'rMrrr�__ge__�szWheelFile.__ge__cCsSd}|jrd}t|jr*|jn|j|�}|jsO|j|�|S)N�r�a)r�VerifyingZipFilerr�verify)r'�modeZvzfrrr�zipfile�s	$	
zWheelFile.zipfilecCst|jj|j��S)z+Parse wheel metadata (the .data/WHEEL file))r
r^�readr0)r'rrr�parsed_wheel_info�szWheelFile.parsed_wheel_infocCsA|jd}ttt|jd���tkr=td��dS)Nz
Wheel-Versionr2zWheel version is too high)r`rK�map�intr6�VERSION_TOO_HIGHrA)r'rrrr�
check_version�s
$zWheelFile.check_versioncCs|jjd�}t|�S)al
        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? 
        rG)r%r+r)r'rGrrr�
install_paths�s
zWheelFile.install_pathscs���fdd�}�jddkr7|d�}n|d�}i}x	�jj�D]�}|j}|jd�rzqY|jd�r�|d	d
�}|jd�\}}	}
|	r|�jkr|
jd�\}}	}
|	s�tdj	|���||�}nd}|}|}
t
jjt
jj
||
��}
|||
|
f||<qYW|s�x_|j�D]Q\}}|j}|\}}}
}
t
jj|
�rhtd
j	||
���qhWtjjtj��}g}�jd}xv|j�D]h\}\}}}
}
|j}�jj|�}||kr7q�t
jj|
�}t
jj|�sht
j|�tt|
d��}|dkr�|j�}|jd�r�d|tt
j�}|j|�tj||�t
jj |
|�}|j!t
j"d�|j#||j$�|j%f�|j&�|j&�|j'd?}|r�t
j(|
|j'd?�q�Wt
jj
|�j)�}t*j+t,|d��}x3t-|�D]%\}}}|j.|||f�q�W|j.�j)ddf�d
S)z7
        Install the wheel into site-packages.
        cs�j|�p�j|S)N)�getre)�key)�	overridesr'rr�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/RECORD�wb�scriptss#!pythons#!�zw+)/r`r^�infolistrr&�
startswith�	partitionr-rArQr!r"�normpath�join�items�exists�sys�
executable�encode�getfilesystemencodingr,�open�dirname�isdir�makedirsr�readliner�linesep�write�shutil�copyfileobj�relpath�replace�sepr�digest�length�close�
external_attr�chmodr.�csv�writerr�sortedZwriterow)r'�forcerhri�rootZ
name_trans�inforGZbasedirr�rrg�target�dest�v�kZexenameZrecord_datar.�sourceZddirZdestinationZhashbangZreldest�attrsr�r�r�r)rhr'r�installsv	!	
%	




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|rWt
j|�\}}	|	ddt|�krWd	}
t|
j|	dt|����tjd
d�|j�D��}x�|D]�}|d}
|d
}|s�|
||fkr�tjjd|
�q�|d
jdd
�\}}|dks�td��|j|
tt|���q�WdS)a	Configure 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).NTrmrz
RECORD.jwsz
RECORD.p7s�hashzsha256=z8RECORD.sig claimed RECORD hash {0} != computed hash {1}.css|]}t|�VqdS)N)r)rIrYrrrrJ�sz#WheelFile.verify.<locals>.<genexpr>rrz%s has no hash!
�=�sha256zUnsupported hash algorithm)r^�strictrwr,�set_expected_hashr_r�hashlibr�r�rr�KeyErrorr	r\rrQr��reader�
splitlinesrz�stderrr�r6rDrr)r'r^�sigr.Zsig_nameZsmime_sig_name�recordZ
record_digest�headers�payload�msgr��rowrr�Zalgo�datarrrr\psB		
"


zWheelFile.verify)#rrr�__doc__r/rr
r(r)�propertyr,r-r.r0r7r:r;r=r?r<rFrLrNrOrUrVrWrXrr^r`rdrer�r\rrrrr7s>

nrc@sXeZdZdZdejddd�Zdd�Zddd	d
�Zdd�Z	dS)
r[z�ZipFile that can assert that each of its extracted contents matches
    an expected sha256 hash. Note that each file must be completly read in 
    order for its hash to be checked.rYFcCs>tjj|||||�d|_i|_tj|_dS)NF)r^�ZipFiler(r��_expected_hashesr�r��_hash_algorithm)r'�filer]�compression�
allowZip64rrrr(�s		zVerifyingZipFile.__init__cCs||j|<dS)zn
        :param name: name of zip entry
        :param hash: bytes of hash (or None for "don't care")
        N)r�)r'rGr�rrrr��sz"VerifyingZipFile.set_expected_hashNc
s3tjj||||��t|tj�r9|j}n|}||jkr|j|dkr|j|�y
�j�Wn#tk
r�t	j
d��SYnX|j��t�d�r�����fdd�}nd����fdd�}|�_n+|j
r/||jkr/td�j���S)z#Return file-like object for 'name'.NzRNeed ZipExtFile._update_crc to implement file hash verification (in Python >= 2.7)�_eofcsI�|��j|��jrE�j��krEtd�j��dS)NzBad hash for file %r)�updater�r�rrG)r�)�_update_crc_orig�ef�
expected_hash�running_hashrr�_update_crc�s

z*VerifyingZipFile.open.<locals>._update_crccsL�|d|��j|�|rH�j��krHtd�j��dS)N�eofzBad hash for file %r)r�r�rrG)r�r�)r�r�r�r�rrr��s
zNo expected hash for file %r)r^r�r~�
isinstance�ZipInforr�r��AttributeError�warnings�warnr��hasattrr�rrG)r'Zname_or_infor]�pwdrGr�r)r�r�r�r�rr~�s(



	zVerifyingZipFile.opencCsg|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�RuntimeErrorrs�pop�
NameToInfor�seek�
header_offsetr!�SEEK_SET�truncate�
_didModify)r'�lastrrrr��s		

zVerifyingZipFile.pop)
rrrr�r^�
ZIP_STOREDr(r�r~r�rrrrr[�s#r[),r�rzr��os.pathr!�rer^r�r�r��maxsizer>�	NameErrorZmaxintZwheel.decoratorrZ
wheel.utilrrrrrr�wheelr	Z
wheel.pkginfor
rZ
pep425tagsr
�pathsrrc�compile�VERBOSE�matchr$rrAr�objectrr�r[rrrr�<module>s8

.	�g