ó ÿ¾v]c@sRdZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZmZerçdd lmZmZmZmZdd lmZnejeƒZd efd „ƒYZdefd„ƒYZ de fd„ƒYZ!defd„ƒYZ"dS(sCache Management iÿÿÿÿN(tcanonicalize_name(tLink(t expanduser(t path_to_url(t TempDirectory(tMYPY_CHECK_RUNNING(tInvalidWheelFilenametWheel(tOptionaltSettListtAny(t FormatControltCachecBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s‚An abstract class - provides cache directories for data from links :param cache_dir: The root of the cache. :param format_control: An object of FormatControl class to limit binaries being read from the cache. :param allowed_formats: which formats of files the cache should store. ('binary' and 'source' are the only allowed values) cCsntt|ƒjƒ|r%t|ƒnd|_||_||_ddh}|jj|ƒ|ksjt ‚dS(Ntsourcetbinary( tsuperR t__init__RtNonet cache_dirtformat_controltallowed_formatstuniontAssertionError(tselfRRRt_valid_formats((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR$s    cCs¥|jg}|jdk rO|jdk rO|jdj|j|jgƒƒndj|ƒ}tj|jƒƒj ƒ}|d |dd!|dd!|dg}|S(sEGet parts of part that must be os.path.joined with cache_dir t=t#iiiN( turl_without_fragmentt hash_nameRthashtappendtjointhashlibtsha224tencodet hexdigest(Rtlinkt key_partstkey_urlthashedtparts((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyt_get_cache_path_parts.s %(cCs²|j p| p| }|r"gSt|ƒ}|jj|ƒ}|jj|ƒsVgS|j|ƒ}ytj|ƒSWn5t k r­}|j t j t j hkr§gS‚nXdS(N( RRRtget_allowed_formatsRt intersectiontget_path_for_linktostlistdirtOSErrorterrnotENOENTtENOTDIR(RR%t package_namet can_not_cachetcanonical_nametformatstrootterr((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyt_get_candidatesHs"    cCs tƒ‚dS(s>Return a directory to store cached items in for link. N(tNotImplementedError(RR%((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR-ascCs tƒ‚dS(saReturns a link to a cached item if it exists, otherwise returns the passed link. N(R;(RR%R4((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pytgetgscCs4|j|ƒ}tjj||ƒ}tt|ƒƒS(N(R-R.tpathR RR(RR%t candidateR8R=((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyt_link_for_candidatenscCsdS(N((R((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pytcleanupus( t__name__t __module__t__doc__RR*R:R-R<R?R@(((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR s      tSimpleWheelCachecBs)eZdZd„Zd„Zd„ZRS(s+A cache of wheels for future installs. cCs#tt|ƒj||dhƒdS(NR(RRDR(RRR((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR~scCs(|j|ƒ}tjj|jd|ŒS(s³Return a directory to store cached wheels 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 link: The link of the sdist for which this will cache wheels. twheels(R*R.R=R R(RR%R)((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR-„scCs™g}xl|j||ƒD]X}yt|ƒ}Wntk rEqnX|jƒsXqn|j|jƒ|fƒqW|s|S|j|t|ƒdƒS(Ni(R:RRt supportedRtsupport_index_minR?tmin(RR%R4t candidatest wheel_nametwheel((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR<™s  (RARBRCRR-R<(((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyRDzs  tEphemWheelCachecBs eZdZd„Zd„ZRS(sGA SimpleWheelCache that creates it's own temporary cache directory cCsBtddƒ|_|jjƒtt|ƒj|jj|ƒdS(Ntkindsephem-wheel-cache(Rt _temp_dirtcreateRRLRR=(RR((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR±s cCs|jjƒdS(N(RNR@(R((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR@ºs(RARBRCRR@(((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyRL­s t WheelCachecBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sØWraps EphemWheelCache and SimpleWheelCache into a single Cache This Cache allows for gracefully degradation, using the ephem wheel cache when a certain link is not found in the simple wheel cache first. cCsDtt|ƒj||dhƒt||ƒ|_t|ƒ|_dS(NR(RRPRRDt _wheel_cacheRLt _ephem_cache(RRR((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyRÆscCs|jj|ƒS(N(RQR-(RR%((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR-ÎscCs|jj|ƒS(N(RRR-(RR%((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pytget_ephem_path_for_linkÒscCs=|jj||ƒ}||kr9|jj||ƒ}n|S(N(RQR<RR(RR%R4tretval((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR<Ös cCs|jjƒ|jjƒdS(N(RQR@RR(R((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyR@Ýs (RARBRCRR-RSR<R@(((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyRP¿s     (#RCR1R!tloggingR.tpip._vendor.packaging.utilsRtpip._internal.models.linkRtpip._internal.utils.compatRtpip._internal.utils.miscRtpip._internal.utils.temp_dirRtpip._internal.utils.typingRtpip._internal.wheelRRttypingRR R R tpip._internal.indexR t getLoggerRAtloggertobjectR RDRLRP(((s2/tmp/pip-install-vZZv26/pip/pip/_internal/cache.pyts&    "a3