Viewing File: /usr/lib/python3.6/site-packages/pip/__pycache__/wheel.cpython-36.opt-1.pyc

3

aj~@s$dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z	ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZddlZddlmZddlmZmZdd	lmZmZm Z dd
l!m"Z"m#Z#ddlm$Z$ddl%m&Z&m'Z'm(Z(m)Z)m*Z*dd
l+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8dZ9d9Z:ej;e<Z=Gddde>Z?ddZ@ddZAd;ddZBd d!ZCd"d#ZDejEd$ejFZGd%d&ZHd'd(ZId<d+d,ZJd-d.ZKeKd/d0ZLd1d2ZMd3d4ZNGd5d6d6e>ZOGd7d8d8e>ZPdS)=zH
Support for installing and building the "wheel" binary package format.
)absolute_importN)urlsafe_b64encode)Parser)StringIO)
expanduser)path_to_url
unpack_url)InstallationErrorInvalidWheelFilenameUnsupportedWheel)distutils_schemePIP_DELETE_MARKER_FILENAME)
pep425tags)call_subprocess
ensure_dircaptured_stdoutrmtreeread_chunks)open_spinner)
indent_log)SETUPTOOLS_SHIM)ScriptMaker)
pkg_resources)canonicalize_name)configparserz.whlc@s eZdZdZddZddZdS)
WheelCachez&A cache of wheels for future installs.cCs|rt|nd|_||_dS)zCreate a wheel cache.

        :param cache_dir: The root of the cache.
        :param format_control: A pip.index.FormatControl object to limit
            binaries being read from the cache.
        N)r
_cache_dir_format_control)self	cache_dirformat_controlr"/usr/lib/python3.6/wheel.py__init__8szWheelCache.__init__cCst|j||j|S)N)cached_wheelrr)rlinkpackage_namer"r"r#r%BszWheelCache.cached_wheelN)__name__
__module____qualname____doc__r$r%r"r"r"r#r5s
rcCs|jg}|jdk	r4|jdk	r4|jdj|j|jgdj|}tj|jj}|dd|dd|dd|ddg}t	j
j|df|S)a
    Return a directory to store cached wheels in for link.

    Because there are M wheels for any one sdist, we provide a directory
    to cache them in, and then consult that directory when looking up
    cache hits.

    We only insert things into the cache if they have plausible version
    numbers, so that we don't contaminate the cache with things that were not
    unique. E.g. ./package might have dozens of installs done for it and build
    a version of 0.0...and if we built and cached a wheel, we'd end up using
    the same wheel even if the source has been edited.

    :param cache_dir: The cache_dir being used by pip.
    :param link: The link of the sdist for which this will cache wheels.
    N=#Zwheels)Zurl_without_fragmentZ	hash_namehashappendjoinhashlibZsha224encodeZ	hexdigestospath)r r&Z	key_partsZkey_urlZhashedpartsr"r"r#_cache_for_linkGs
,r9c
Cs,|s|S|s|S|jr|S|js$|S|s,|St|}tjj||}d|krN|St||}ytj|}Wn:t	k
r}z|j
t
jt
jfkr|SWYdd}~XnXg}	xL|D]D}
yt
|
}Wntk
rwYnX|jsq|	j|j|
fqW|	s|S|	jtjj||	dd}tjjt|S)Nbinaryrr)is_wheelis_artifactrpipindexfmt_ctl_formatsr9r6listdirOSErrorerrnoENOENTENOTDIRWheelr
	supportedr2support_index_minsortr7r3Linkr)
r r&r!r'Zcanonical_nameZformatsrootZwheel_nameseZ
candidates
wheel_namewheelr7r"r"r#r%psF

r%sha256cCsttj|}d}t|d2}x*t||dD]}|t|7}|j|q(WWdQRXdt|jjdj	d}||fS)z6Return (hash, length) for path using hashlib.new(algo)rrb)sizeNzsha256=latin1r,)
r4newopenrlenupdaterdigestdecoderstrip)r7ZalgoZ	blocksizehZlengthfblockrWr"r"r#rehashs

r]cCs6tjddkri}d}nddi}d}t|||f|S)Nrbnewline)sysversion_inforT)namemodenlbinr"r"r#open_for_csvsrhcCstjj|rt|dH}|j}|jds.dStjjtj	}d|tj
jd}|j}WdQRXt|d}|j||j|WdQRXdSdS)	zLReplace #!python with #!/path/to/python
    Return True if file was changed.rPs#!pythonFs#!asciiNwbT)
r6r7isfilerTreadline
startswithrb
executabler5getfilesystemencodinglinesepreadwrite)r7Zscript	firstlineZexenamerestr"r"r#
fix_scripts

ruzZ^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
                                \.dist-info$cCs|jdd}xttj|D]f}tj|}|r|jd|krttjj||d,}x$|D]}|j	j
}|dkrTdSqTWWdQRXqWdS)	zP
    Return True if the extracted wheel in wheeldir should go into purelib.
    -_rdWHEELzroot-is-purelib: trueTNF)replacer6r@dist_info_rematchgrouprTr7r3lowerrY)rdwheeldirZname_foldeditemr{rMliner"r"r#root_is_purelibs

rc
Cstjj|siifSt|<}t}x$|D]}|j|j|jdq*W|jdWdQRXtj	}dd|_
|j|i}i}|jdrt
|jd}|jdrt
|jd}||fS)N
rcSs|S)Nr")Zoptionr"r"r#<lambda>sz!get_entrypoints.<locals>.<lambda>Zconsole_scriptsZgui_scripts)r6r7existsrTrrrstripseekrZRawConfigParserZoptionxformZreadfpZhas_sectiondictitems)filenamefpdatarZcpconsoleguir"r"r#get_entrypointss$





rFTc+)s|st||||||	d}t|r,|dn|dggjtjjtjj}itg}|rt4}
tj	 tj
dtj|dddWdQRXWdQRXt
j|
jdd	d2fdd		d3	
fd
d	}||dtjjdd}t|\fdd}xvD]n}d}d}x^tjtjj|D]F}d}|dkr^t}|}tjj||}||}|||d
||dqDWq"Wtd|dd_td4_d_
fdd}|_d_jdd}|rdtjkrd|}|jj|tjjdddkrBdtj dd|f}|jj|dtj dd|f}|jj|d d!D}x|D]}|=q|Wjd"d}|rdtjkrd#|}|jj|d$tj dd|f}|jj|d%d!D}x|D]}|=qWt!dkr8|jj"d&d!j#Dt!dkrj|jj"d'd!j#Dd(ditjjdd)}tjjdd*}t$|d+}|j%d,WdQRXt&j'|||j(|tjjdd-} tjjdd.}!t)| d/}"t)|!d0}#t*j+|"}$t*j,|#}%xV|$D]N}&j|&d|&d|&d<|&dkr^t-|&d\|&d<|&d1<|%j.|&qWx`|D]X}'t-|'\}(})|'}*|
r|*j/|
rtjjtjtjj0|*|
}*|%j.|*|(|)fqtWx"D]}'|%j.|'ddfqWWdQRXWdQRXt&j'|!| dS)5zInstall a wheel)userhomerJisolatedprefixpurelibplatlibignoreT)forcequietNcSstjj||jtjjdS)N/)r6r7relpathrysep)srcpr"r"r#normpathsz"move_wheel_files.<locals>.normpathFcs.|}|}||<|r*j|dS)z6Map archive RECORD paths to installation RECORD paths.N)add)srcfiledestfileZmodifiedZoldpathnewpath)changed	installedlib_dirrr~r"r#record_installeds


z*move_wheel_files.<locals>.record_installedcst|xtj|D]\}}}|t|djtjj}tjj||}	|rj|jtjjddj	drjqxl|D]d}
tjj|||
}|r|dkr|j	drj
|
qpqp|rp|
j	drpt|
jtj
rpj
|qpWx|D]}|r||rqtjj||}
tjj|||}t|	tj|
|tj|
}ttdrLtj||j|jftj|
tjrtj|
}|jtjBtjBtjB}tj||d}|r||}|
||qWqWdS)Nrrz.dataraz
.dist-infoutimeF)rr6walkrUlstripr7rr3splitendswithr2rrmrdshutilZcopyfilestathasattrrst_atimest_mtimeaccessX_OKst_modeS_IXUSRS_IXGRPS_IXOTHchmod)sourcedestZis_basefixerfilterdirZsubdirsfilesZbasedirZdestdirsZ
destsubdirr[rrstZpermissionsr)	data_dirsinfo_dirrreqr"r#clobbersD





z!move_wheel_files.<locals>.clobberrzentry_points.txtcsh|jjdr|dd}n<|jjdr8|dd}n |jjdrT|dd}n|}|kpf|kS)	Nz.exer/z
-script.py
z.pyair)r}r)rdZ	matchname)rrr"r#is_entrypoint_wrapperasz/move_wheel_files.<locals>.is_entrypoint_wrapperscripts)rrracs<|jdkrtd|fj|j|jjdd|jdS)NzInvalid script entry point: %s for req: %s - A callable suffix is required. Cf https://packaging.python.org/en/latest/distributing.html#console-scripts for more information..r)moduleZimport_namefunc)suffixr	script_templaterr)entry)makerrr"r#_get_script_texts
z*move_wheel_files.<locals>._get_script_textz# -*- coding: utf-8 -*-
import re
import sys

from %(module)s import %(import_name)s

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(%(func)s())
r=ZENSUREPIP_OPTIONSzpip = Z
altinstallz
pip%s = %srr^cSsg|]}tjd|r|qS)zpip(\d(\.\d)?)?$)rer{).0kr"r"r#
<listcomp>sz$move_wheel_files.<locals>.<listcomp>Zeasy_installzeasy_install = zeasy_install-%s = %scSsg|]}tjd|r|qS)zeasy_install(-\d\.\d)?$)rr{)rrr"r"r#rscSsg|]}d|qS)z%s = %sr")rkvr"r"r#rscSsg|]}d|qS)z%s = %sr")rrr"r"r#rsrZ	INSTALLERz
INSTALLER.piprjspip
RECORDz
RECORD.piprzw+r.)F)NN)ra)1rrrYr6r7rsetrwarningscatch_warningsfilterwarnings
compileallcompile_dirloggerdebuggetvaluer3rr@rurrZvariantsZset_moderrpopenvironextendZmakegetrbversionrUZ
make_multiplerrTrrrmover2rhcsvreaderwriterr]Zwriterowrmr)+rdrr~rrrJZ	pycompileschemerrZstrip_file_prefixrZ	generatedstdoutrZep_filerZdatadirrrZsubdirrrZ
pip_scriptspecZpip_eprZeasy_install_scriptZeasy_install_epZ	installerZtemp_installerZinstaller_filerecordZtemp_recordZ	record_inZ
record_outrrrowr[rZlZ
final_pathr")rrrrrrrrrrrr~r#move_wheel_filess




$;



#









.rcstjfdd}|S)Nc?s6t}x*||D]}||kr|j||VqWdS)N)rr)argskwseenr)fnr"r#uniques

z_unique.<locals>.unique)	functoolswraps)rrr")rr#_uniquesrccsddlm}tj||jd}xd|D]\}tjj|j|d}|V|j	dr&tjj
|\}}|dd}tjj||d}|Vq&WdS)	a
    Yield all the uninstallation paths for dist based on RECORD-without-.pyc

    Yield paths to all the files in RECORD. For each .py file in RECORD, add
    the .pyc in the same directory.

    UninstallPathSet.add() takes care of the __pycache__ .pyc.
    r)FakeFilerz.pyNr^z.pyc)	pip.utilsrrrZget_metadata_linesr6r7r3locationrr)distrrrr7Zdnrbaser"r"r#uninstallation_paths"s


rcCsdyTddtjd|Dd}|jd}tj|}|dj}ttt|j	d}|SdSdS)	z
    Return the Wheel-Version of an extracted wheel, if possible.

    Otherwise, return False if we couldn't parse / extract it.
    cSsg|]}|qSr"r")rdr"r"r#r?sz!wheel_version.<locals>.<listcomp>Nrrxz
Wheel-VersionrF)
rZfind_on_pathZget_metadatarZparsestrrtuplemapintr)
source_dirrZ
wheel_datarr"r"r#
wheel_version8s
rcCsb|std||dtdkr>td|djtt|fn |tkr^tjddjtt|dS)a
    Raises errors or warns if called with an incompatible Wheel-Version.

    Pip should refuse to install a Wheel-Version that's a major series
    ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
    installing a version only minor version ahead (e.g 1.2 > 1.1).

    version: a 2-tuple representing a Wheel-Version (Major, Minor)
    name: name of wheel or package to raise exception about

    :raises UnsupportedWheel: when an incompatible Wheel-Version is given
    z(%s is in an unsupported or invalid wheelrzB%s's Wheel-Version (%s) is not compatible with this version of piprz*Installing from a newer Wheel-Version (%s)N)rVERSION_COMPATIBLEr3rstrrwarning)rrdr"r"r#check_compatibilityKs

rc@s:eZdZdZejdejZddZd
ddZ	ddd	Z
dS)rEzA wheel filez^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))
        ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
        \.whl|\.dist-info)$csjj|}|std||_|jdjdd_|jdjdd_|jdjd_	|jdjd_
|jd	jd_tfd
dj	D_
dS)
zX
        :raises InvalidWheelFilename: when the filename is invalid for a wheel
        z!%s is not a valid wheel filename.rdrwrvZverZpyverrabiZplatc3s0|](}jD]}jD]}|||fVqqqdS)N)abisplats)rxyz)rr"r#	<genexpr>sz!Wheel.__init__.<locals>.<genexpr>N)
wheel_file_rer{r
rr|ryrdrrZ
pyversionsr	r
r	file_tags)rrZ
wheel_infor")rr#r$ts
zWheel.__init__Ncs2dkrtjfdd|jD}|r.t|SdS)a"
        Return the lowest index that one of the wheel's file_tag combinations
        achieves in the supported_tags list e.g. if there are 8 supported tags,
        and one of the file tags is first in the list, then return 0.  Returns
        None is the wheel is not supported.
        Ncsg|]}|krj|qSr")r>)rc)tagsr"r#rsz+Wheel.support_index_min.<locals>.<listcomp>)rsupported_tagsrmin)rrZindexesr")rr#rGszWheel.support_index_mincCs"|dkrtj}tt|j|jS)z'Is this wheel supported on this system?N)rrboolrintersectionr)rrr"r"r#rFszWheel.supported)N)N)r(r)r*r+rcompileVERBOSErr$rGrFr"r"r"r#rEhs
rEc@sHeZdZdZdddZdddZddZdd	d
ZddZdddZ	dS)WheelBuilderz#Build wheels from a RequirementSet.NcCs6||_||_|jj|_|j|_|p$g|_|p.g|_dS)N)	requirement_setfinderZ_wheel_cacher_cache_rootZwheel_download_dir
_wheel_dir
build_optionsglobal_options)rrrrrr"r"r#r$s

zWheelBuilder.__init__cCstjd}zn|j|||drlyBtj|d}tjj||}tjtjj|||t	j
d||SYnX|j|dSt|XdS)ziBuild one wheel.

        :return: The filename of the built wheel, or None if the build failed.
        z
pip-wheel-)
python_tagrzStored in directory: %sN)
tempfileZmkdtemp_WheelBuilder__build_oner6r@r7r3rrrinfo
_clean_oner)rr
output_dirr tempdrLZ
wheel_pathr"r"r#
_build_ones

zWheelBuilder._build_onecCstjddt|jgt|jS)Nz-uz-c)rbrnrZsetup_pylistr)rrr"r"r#_base_setup_argss
zWheelBuilder._base_setup_argscCs|j|}d|jf}t|t}tjd||dd|g|j}|dk	rT|d|g7}yt||jd|ddS|jd	tj	d
|jdSWdQRXdS)Nz#Running setup.py bdist_wheel for %szDestination directory: %sZbdist_wheelz-dz--python-tagF)cwdshow_stdoutspinnerTerrorzFailed building wheel for %s)
r)rdrrrrrZsetup_py_dirZfinishr-)rrr&r 	base_argsZspin_messager,Z
wheel_argsr"r"r#Z__build_ones



zWheelBuilder.__build_onecCsV|j|}tjd|j|ddg}yt||jdddStjd|jdSdS)NzRunning setup.py clean for %sZcleanz--allF)r*r+Tz Failed cleaning build dir for %s)r)rr#rdrrr-)rrr.Z
clean_argsr"r"r#r$s
zWheelBuilder._clean_oneFcCs|jj|j|jjj}g}x|D]}|jr0q$|jrJ|stjd|j	q$|rV|j
rVq$|rl|jrl|jjrlq$|rz|j
rzq$|r|j}|j\}}tjj|d|dkrq$dtjj|jjt|j	krtjd|j	q$|j|q$W|sdStjddjdd	|Dt<gg}}	x(|D]}d}
|rtj}
t|j|j}yt|WnBtk
r}z$tjd
|j	||	j|w WYdd}~XnXn|j}|j |||
d}
|
r4|j||r>|j
rt!j"j#t!j"j|j
t$rt%d|j&|j'|jj(|_
tjj)t*|
|_t+|j|j
dd
|jj,dn
|	j|q WWdQRX|rptjddjdd	|D|	rtjddjdd	|	Dt-|	dkS)zBuild wheels.

        :param unpack: If True, replace the sdist we built from with the
            newly built wheel, in preparation for installation.
        :return: True if all the wheels built correctly.
        z(Skipping %s, due to already being wheel.Nr:zCSkipping bdist_wheel for %s, due to binaries being disabled for it.Tz*Building wheels for collected packages: %sz, cSsg|]
}|jqSr")rd)rrr"r"r#rsz&WheelBuilder.build.<locals>.<listcomp>z Building wheel for %s failed: %s)r zbad source dir - missing markerF)sessionzSuccessfully built %s cSsg|]
}|jqSr")rd)rrr"r"r#rQszFailed to build %scSsg|]
}|jqSr")rd)rrr"r"r#rVsr).rZ
prepare_filesrZrequirementsvaluesZ
constraintr;rr#rdZeditabler&r<rsplitextr=r>Zegg_info_matchesr?r!rr2r3rrZimplementation_tagr9rrrArrr'r6r7rr
AssertionErrorZremove_temporary_sourceZbuild_locationZ	build_dirrIrrr/rU)rZautobuildingZreqsetZbuildsetrr&rZextZ
build_successZ
build_failurer r%rKZ
wheel_filer"r"r#builds	






zWheelBuilder.build)NN)N)N)F)
r(r)r*r+r$r'r)r"r$r4r"r"r"r#rs


r)rr)rNr5)FNNTNFNN)Qr+Z
__future__rrrrBrr4Zloggingr6Zos.pathrrrrbr!rbase64rZemail.parserrZpip._vendor.sixrr=Z
pip.compatrZpip.downloadrrZpip.exceptionsr	r
rZ
pip.locationsrr
rrrrrrrZpip.utils.uirZpip.utils.loggingrZpip.utils.setuptools_buildrZpip._vendor.distlib.scriptsrZpip._vendorrZpip._vendor.packaging.utilsrZpip._vendor.six.movesrZ	wheel_extrZ	getLoggerr(robjectrr9r%r]rhrurrrzrrrrrrrrErr"r"r"r#<module>sn
)'



'7
Back to Directory File Manager