Y } @s+dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlZddlmZddlmZmZdd lmZmZm Z dd l!m"Z"m#Z#dd lm$Z$dd l%m&Z&m'Z'm(Z(m)Z)m*Z*dd l+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8dZ9ddfZ:ej;e<Z=Gddde>Z?ddZ@ddZAddd>ddZBd d!ZCd"d#ZDe jEd$e jFZGd%d&ZHd'd(ZId)ddd*dd)dd+d,ZJd-d.ZKeKd/d0ZLd1d2ZMd3d4ZNGd5d6d6e>ZOGd7d8d8e>ZPdS)9zH 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_stdoutrmtree read_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(|rt|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"(/tmp/pip-build-3puug3g5/pip/pip/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 rL|jdk rL|jdj|j|jgdj|}tj|jj}|dd|dd|dd|ddg}t j j|d|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=#wheels) url_without_fragment hash_namehashappendjoinhashlibsha224encode hexdigestospath)r r& key_partskey_urlhashedpartsr"r"r#_cache_for_linkGs ":rAc Cs|s |S|s|S|jr!|S|js.|S|s8|St|}tjj||}d|kri|St||}ytj|}WnGt k r}z'|j t j t j fkr|SWYdd}~XnXg} x^|D]V} yt | } Wntk rwYnX| jsq| j| j| fqW| sF|S| jtjj|| dd} tjjt| S)Nbinaryrr)is_wheel is_artifactrpipindexfmt_ctl_formatsrAr;listdirOSErrorerrnoENOENTENOTDIRWheelr supportedr5support_index_minsortr<r6Linkr) r r&r!r'canonical_nameformatsroot wheel_namese candidates wheel_namewheelr<r"r"r#r%psF        r%sha256c Cstj|}d}t|dA}x7t|d|D]#}|t|7}|j|q:WWdQRXdt|jjdj d}||fS)z6Return (hash, length) for path using hashlib.new(algo)rrbsizeNzsha256=latin1r,) r7newopenrlenupdaterdigestdecoderstrip)r<algo blocksizehlengthfblockrcr"r"r#rehashsrlcCsHtjddkr"i}d}nddi}d}t||||S)Nrbnewline)sys version_infor`)namemodenlbinr"r"r# open_for_csvs   rwcCstjj|rt|dd}|j}|jdsCdStjjtj }d|tj jd}|j }WdQRXt|d!}|j ||j |WdQRXdSdS) zLReplace #!python with #!/path/to/python Return True if file was changed.r\s#!pythonFs#!asciiNwbT) r;r<isfiler`readline startswithrq executabler9getfilesystemencodinglinesepreadwrite)r<script firstlineexenamerestr"r"r# fix_scripts  rzZ^(?P(?P.+?)(-(?P\d.+?))?) \.dist-info$c Cs|jdd}xtj|D]}tj|}|r"|jd|kr"ttjj||d:}x0|D](}|j j }|dkrzdSqzWWdQRXq"WdS) zP Return True if the extracted wheel in wheeldir should go into purelib. -_rsWHEELzroot-is-purelib: trueTNF) replacer;rH dist_info_rematchgroupr`r<r6lowerre)rswheeldir name_foldeditemrrYliner"r"r#root_is_purelibs!  rc Cstjj|siifSt|N}t}x.|D]&}|j|j|jdq;W|jdWdQRXtj }dd|_ |j |i}i}|j drt |jd}|j drt |jd}||fS)N rcSs|S)Nr")optionr"r"r#sz!get_entrypoints..console_scripts gui_scripts)r;r<existsr`rrstripseekrRawConfigParser optionxformreadfp has_sectiondictitems)filenamefpdatarcpconsoleguir"r"r#get_entrypointss$     rFTc )(s|s0t|d|d|d|d|d| }t| rL|dn |dgg jtjjtjj} itg} |rtA} tj +tj dt j | d d d d Wd QRXWd QRXt j| jd dd fdd d d  fdd} | | d sptd tjjdd}t|\fdd}xD]}d }d }xtjtjj |D]b}d }|dkr t}|}tjj ||} ||}| | |dd|d|qWqWtd |dd _td9_d _ fdd}|_d_jd d }|rd!tjkrd"|}| jj|tjjd!dd#krBd$t j!d d%|f}| jj|d$t j!d d&|f}| jj|d'd(D}x|D] }|=qWjd)d }|rEd!tjkrd*|}| jj|d+t j!d d&|f}| jj|d,d(D}x|D] }|=q4Wt"dkr| jj#d-d(j$Dt"dkr| jj#d.d(j$Dd/d itjjdd0}tjjdd1}t%|d2}|j&d3Wd QRXt'j(||| j)|tjjdd4}tjjdd5} t*|d6}!t*| d7}"t+j,|!}#t+j-|"}$xg|#D]_}%j|%d|%d|%d<|%dkrt.|%d\|%d%<|%d8<|$j/|%qWx?| D]7}&t.|&\}'}(|$j/|&|'|(fqWx(D] }&|$j/|&ddfq`WWd QRXWd QRXt'j(| |d S):zInstall a wheeluserhomerTisolatedprefixpurelibplatlibignoreforceTquietNcSs%tjj||jtjjdS)N/)r;r<relpathrsep)srcpr"r"r#normpathsz"move_wheel_files..normpathFcs?|}|}||<|r;j|dS)z6Map archive RECORD paths to installation RECORD paths.N)add)srcfiledestfilemodifiedoldpathnewpath)changed installedlib_dirrrr"r#record_installeds  z*move_wheel_files..record_installedcst|xntj|D]]\}}}|t|djtjj}tjj||} |r|jtjjddj drqx|D]} tjj||| } |r|dkr| j drj | qq|r| j drt | j t j r sEtd| ddjj | qWx|D]} |rx|| rxq]tjj|| } tjj||| }t| tj| |tj| }ttdrtj||j|jftj| tjrKtj| }|jtjBtjBtjB}tj||d }|rc||}| ||q]WqWdS) Nrrz.datarpz .dist-infoz!Multiple .dist-info directories: z, utimeF)rr;walkralstripr<rr6splitendswithr5rr|rsAssertionErrorshutilcopyfilestathasattrrst_atimest_mtimeaccessX_OKst_modeS_IXUSRS_IXGRPS_IXOTHchmod)sourcedestis_basefixerfilterdirsubdirsfilesbasedirdestdirs destsubdirrjrrst permissionsr) data_dirsinfo_dirrreqr"r#clobbersJ %+ !       z!move_wheel_files..clobberz!%s .dist-info directory not foundrzentry_points.txtcs|jjdr(|dd}nV|jjdrP|dd}n.|jjdrx|dd}n|}|kp|kS) Nz.exer/z -script.py z.pyair)rr)rs matchname)rrr"r#is_entrypoint_wrapperasz/move_wheel_files..is_entrypoint_wrapperscriptsrrrpcsX|jdkr%td|fjd|jd|jjddd|jiS)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.module import_name.rfunc)suffixr script_templaterr)entry)makerrr"r#_get_script_texts z*move_wheel_files.._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()) rEENSUREPIP_OPTIONSzpip = altinstallz pip%s = %srrmcSs(g|]}tjd|r|qS)zpip(\d(\.\d)?)?$)rer).0kr"r"r# s z$move_wheel_files.. easy_installzeasy_install = zeasy_install-%s = %scSs(g|]}tjd|r|qS)zeasy_install(-\d\.\d)?$)rr)rrr"r"r#rs cSsg|]}d|qS)z%s = %sr")rkvr"r"r#rs cSsg|]}d|qS)z%s = %sr")rrr"r"r#rs r INSTALLERz INSTALLER.pipryspip RECORDz RECORD.piprzw+r.)rp)0r rrer;r<rsetrwarningscatch_warningsfilterwarnings compileall compile_dirloggerdebuggetvaluerr6rrHrrrvariantsset_moderrpopenvironextendmakegetrqversionra make_multiplerr`rrmover5rwcsvreaderwriterrlwriterow))rsrrrrrT pycompileschemerrr generatedstdoutrep_filerdatadirrrsubdirrr pip_scriptspecpip_epreasy_install_scripteasy_install_ep installertemp_installerinstaller_filerecord temp_record record_in record_outrrrowrjrhlr") rrrrrrrrrrrrr#move_wheel_filess       ' !!; %  $   #      #   # ,r,cs%tjfdd}|S)Nc?sEt}x5||D]$}||kr|j||VqWdS)N)rr)argskwseenr)fnr"r#uniques    z_unique..unique) functoolswraps)r0r1r")r0r#_uniques!r4ccsddlm}tj||jd}x|D]|}tjj|j|d}|V|j dr5tjj |\}}|dd}tjj||d}|Vq5WdS) 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.pyNrmz.pyc) pip.utilsr5rrget_metadata_linesr;r<r6locationrr)distr5rr*r<dnr0baser"r"r#uninstallation_pathss  r=c Csyzddtjd|Dd}|jd}tj|}|dj}ttt|j d}|SWn dSYnXdS) 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;s z!wheel_version..Nrrz Wheel-VersionrF) r find_on_path get_metadatarparsestrrtuplemapintr) source_dirr: wheel_datarr"r"r# wheel_version4s#rGcCs|std||dtdkrUtd|djtt|fn.|tkrtjddjtt|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)r VERSION_COMPATIBLEr6rCstrrwarning)rrsr"r"r#check_compatibilityGs  % rKc@sUeZdZdZejdejZddZdddZ ddd Z dS) rMz A wheel filez^(?P(?P.+?)-(?P\d.*?)) ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) \.whl|\.dist-info)$csjj|}|s(td||_|jdjdd_|jdjdd_|jdjd_ |jdjd_ |jd jd_ t fd d j D_ d S) zX :raises InvalidWheelFilename: when the filename is invalid for a wheel z!%s is not a valid wheel filename.rsrrverpyverrabiplatc3s>|]4}jD]$}jD]}|||fVqqqdS)N)abisplats)rxyz)rr"r# sz!Wheel.__init__..N) wheel_file_rerr rrrrsrr pyversionsrPrQr file_tags)rr wheel_infor")rr#r$ps  zWheel.__init__NcsEdkrtjfdd|jD}|rAt|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. Ncs+g|]!}|krj|qSr")rF)rc)tagsr"r#rs z+Wheel.support_index_min..)rsupported_tagsrXmin)rr[indexesr")r[r#rOs  zWheel.support_index_mincCs1|dkrtj}tt|j|jS)z'Is this wheel supported on this system?N)rr\boolr intersectionrX)rr[r"r"r#rNs  zWheel.supported) r(r)r*r+rcompileVERBOSErVr$rOrNr"r"r"r#rMds    rMc@smeZdZdZddddZdddZddZdd d Zd d Zd ddZ dS) WheelBuilderz#Build wheels from a RequirementSet.NcCsO||_||_|jj|_|j|_|p6g|_|pEg|_dS)N) requirement_setfinder _wheel_cacher _cache_rootwheel_download_dir _wheel_dir build_optionsglobal_options)rrdrerjrkr"r"r#r$s    zWheelBuilder.__init__cCstjd}z|j||d|ry_tj|d}tjj||}tjtjj|||t j d||SWnYnX|j |dSWdt |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) tempfilemkdtemp_WheelBuilder__build_oner;rHr<r6rrrinfo _clean_oner)rr output_dirrltempdrX wheel_pathr"r"r# _build_ones zWheelBuilder._build_onecCs'tjddt|jgt|jS)Nz-uz-c)rqr}rsetup_pylistrk)rrr"r"r#_base_setup_argss  zWheelBuilder._base_setup_argscCs|j|}d|jf}t|}tjd||dd|g|j}|dk rt|d|g7}y't|d|jddd |d SWn,|jd tj d |jdSYnXWdQRXdS) Nz#Running setup.py bdist_wheel for %szDestination directory: %s bdist_wheelz-dz --python-tagcwd show_stdoutFspinnerTerrorzFailed building wheel for %s) rxrsrrrrjr setup_py_dirfinishr})rrrsrl base_args spin_messager| wheel_argsr"r"r# __build_ones   zWheelBuilder.__build_onec Csy|j|}tjd|j|ddg}y!t|d|jdddSWntjd|jdSYnXdS) NzRunning setup.py clean for %scleanz--allrzr{FTz Failed cleaning build dir for %s)rxrrprsrrEr})rrr clean_argsr"r"r#rqszWheelBuilder._clean_oneFcCs|js|r|jst|jj|j|jjj}g}x|D] }|jrbqP|j r|sZt j d|j qP|r|j rqP|r|jr|jj rqP|r|j rqP|rM|j}|j\}}tjj|d|dkr qPdtjj|jjt|j krMt j d|j qP|j|qPW|shdSt j ddjdd |Dtgg}} x|D]}d} |r;tj} t|j|j} yt| WqDtk r7} z+t j d |j | | j|wWYdd} ~ XqDXn |j} |j!|| d | } | r&|j||r3|jrt"j#j$t"j#j|jt% rtd |j&|j'|jj(|_tjj)t*| |_|jj stt+|j|jdd d|jj,q| j|qWWdQRX|rjt j ddjdd |D| rt j ddjdd | 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.NrBzCSkipping bdist_wheel for %s, due to binaries being disabled for it.Tz*Building wheels for collected packages: %sz, cSsg|]}|jqSr")rs)rrr"r"r#rs z&WheelBuilder.build..z Building wheel for %s failed: %srlzbad source dir - missing markerFsessionzSuccessfully built %s cSsg|]}|jqSr")rs)rrr"r"r#rMs zFailed to build %scSsg|]}|jqSr")rs)rrr"r"r#rRs r).rirgrrd prepare_filesre requirementsvalues constraintrCrrprseditabler&rDrEsplitextrErFegg_info_matchesrGr!rr5r6rrimplementation_tagrArrIrJrur;r<rr remove_temporary_sourcebuild_location build_dirrQrrrra)r autobuildingreqsetbuildsetrr&r<ext build_success build_failurerlrrrV wheel_filer"r"r#builds                     zWheelBuilder.build) r(r)r*r+r$rurxrorqrr"r"r"r#rcs   rc)Qr+ __future__rrrrJr2r7loggingr;os.pathrrrrqrmrbase64r email.parserrpip._vendor.sixrrE pip.compatr pip.downloadrrpip.exceptionsr r r pip.locationsr r rr7rrrrr pip.utils.uirpip.utils.loggingrpip.utils.setuptools_buildrpip._vendor.distlib.scriptsr pip._vendorrpip._vendor.packaging.utilsrpip._vendor.six.movesr wheel_extrH getLoggerr(robjectrrAr%rlrwrrarbrrrr,r4r=rGrKrMrcr"r"r"r#sl               (  ) '    "   7