U n aM]@s6dZddlmZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#ddl$m%Z%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0m1Z1ddl2m3Z3e.rddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@ddlAmBZBddl$mCZCe;eDdfZEeFeGZHddZId7ddZJddZKd d!ZLd"d#ZMd$d%ZNd&d'ZOd(d)ZPd*d+ZQGd,d-d-eRZSd.d/ZTGd0d1d1eZUd8d3d4ZVd9d5d6ZWdS):zGSupport for installing and building the "wheel" binary package format. )absolute_importN)urlsafe_b64encode)starmap)ZipFile) pkg_resources) ScriptMaker)get_export_entry)StringIO)InstallationError)get_major_minor_version)DIRECT_URL_METADATA_NAME DirectUrl)adjacent_tmp_filereplace)captured_stdout ensure_dir hash_file) TempDirectory)MYPY_CHECK_RUNNING) current_umask unpack_file) parse_wheel)Message) DictListOptionalSequenceTupleAnyIterableIteratorCallableSet)Scheme)NamedTemporaryFileResult.cCstj||tjjdS)N/)ospathrelpathrsep)srcpr,gC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\operations\install\wheel.pynormpath7sr.cCs6t||\}}dt|dd}|t|fS)z?Return (encoded_digest, length) for path using hashlib.sha256()zsha256=latin1=)rrdigestdecoderstripstr)r' blocksizehlengthr2r,r,r-rehash<sr9cCs(tjjdkrdd|iS|ddSdS)zPReturn keyword arguments to properly open a CSV file in the given mode. modez{}b)r;newlineN)sys version_infomajorformat)r;r,r,r- csv_io_kwargsGs rBc Cstj|rt|dR}|}|ds8W5QRdStjt }d|tj d}| }W5QRXt|d}| || |W5QRXdSdS) zQReplace #!python with #!/path/to/python Return True if file was changed. rbs#!pythonFs#!asciiwbTN) r&r'isfileopenreadline startswithr> executableencodegetfilesystemencodinglinesepreadwrite)r'script firstlineexenamerestr,r,r- fix_scriptRs     rTcCs|dddkS)NzRoot-Is-Purelibr<true)getlower)metadatar,r,r-wheel_root_is_purelibgsrYc stj|siifSt|8}t}|D]}|||dq(|dW5QRXtj |}| di}| di}ddt fdd| D}t fd d| D}||fS) N rconsole_scripts gui_scriptscSs&t|ddd}|d|dfS)z[get the string representation of EntryPoint, remove space and split on '='  r<r1r)r5rsplit)s split_partsr,r,r- _split_epsz"get_entrypoints.._split_epc3s|]}|VqdSNr,.0vrbr,r- sz"get_entrypoints..c3s|]}|VqdSrcr,rdrgr,r-rhs)r&r'existsrGr rOstripseekr EntryPoint parse_maprVdictvalues)filenamefpdataline entry_pointsconsoleguir,rgr-get_entrypointsls       rwc s|sdStt}|D]*}tj|}tj|}|||qddtj dd tj D tj tjtjfdd|D}|sdSg}|D]b\}}t|}t|dkrd |d } n$d d |dd d|d } | d| |qd} t|dkr0| | dn| | dtddtj dd tj D} | rxd} | | d|S)zDetermine if any scripts are not on PATH and format a warning. Returns a warning message if one or more scripts are not on PATH, otherwise None. NcSs g|]}tj|tjqSr,)r&r'normcaser4r)reir,r,r- sz5message_about_scripts_not_on_PATH..PATHr<cs&i|]\}}tj|kr||qSr,)r&r'rx)re parent_dirscripts not_warn_dirsr,r- sz5message_about_scripts_not_on_PATH..r^z script {} isrzscripts {} arez, z and z.The {} installed in '{}' which is not on PATH.zeConsider adding {} to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.zthis directoryzthese directoriescss|]}|r|ddkVqdS)r~Nr,ryr,r,r-rhsz4message_about_scripts_not_on_PATH..ziNOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.rZ) collections defaultdictsetr&r'dirnamebasenameaddenvironrVr_pathsepappendrxr>rJitemssortedlenrAjoinany) r~grouped_by_dirdestfiler} script_namewarn_for msg_lines dir_scriptssorted_scripts start_text last_line_fmtwarn_for_tildetilde_warning_msgr,rr-!message_about_scripts_not_on_PATHsV      rcCst|dddS)a6Return the given rows of a RECORD file in sorted order. Each row is a 3-tuple (path, hash, size) and corresponds to a record of a RECORD file (see PEP 376 and PEP 427 for details). For the rows passed to this function, the size can be an integer as an int or string, or the empty string. cSstdd|DS)Ncss|]}t|VqdSrc)r5)rexr,r,r-rhsz3sorted_outrows....)tuple)rowr,r,r-z sorted_outrows..)key)r)outrowsr,r,r-sorted_outrowssrc Csg}|D]v}t|dkr(td|t|}|d}|||}||d<||krpt|\} } | |d<| |d<|t|q|D]*} t| \} } |t | || t | fq|D]} ||| ddfq|S)z_ :param installed: A map from archive RECORD path to installation RECORD path. r:z,RECORD line has more than three elements: {}rr^r<) rloggerwarningrAlistpopr9rrr.r5) old_csv_rows installedchanged generatedlib_dirinstalled_rowsrold_pathnew_pathr2r8fr,r,r-get_csv_rows_for_installeds*     rc@s eZdZdS)MissingCallableSuffixN)__name__ __module__ __qualname__r,r,r,r-rsrcCs*t|}|dk r&|jdkr&tt|dSrc)rsuffixrr5) specificationentryr,r,r-_raise_for_invalid_entrypointsrcseZdZdfdd ZZS)PipScriptMakerNcst|tt|||Src)rsuperrmake)selfroptions __class__r,r-rszPipScriptMaker.make)N)rrrr __classcell__r,r,rr-rsrTc- sntjjtjj}t||\} } t| r4|jn|jt|} dd| D} it g} |rt 4}t t dtj|dddW5QRXW5QRXt|d*fdd d+fd d }||dtj| }tj|d }t|\fd d}| D]l}d }d }ttj|D]H}d }|dkrTt}|}tj||}t||}|||d||dq:qtd |j}d|_dh|_d|_g}dd }|r8dtjkr|d|tjdddkr|d t!j"d||d t#|ddD}|D] }|=q*dd }|rdtjkrd|d||d t#|ddD}|D] }|=q|$t%dj &t't%dj &}g} z.|(|} | $| | $|(|ddiWn>t)k r2}!z|!j*d}"t+d |"|W5d }!~!XYnX|rVt,| }#|#d k rVt-|#d t.@t/j0fd!d"}$tj|d#}%|$|%}&|&1d$W5QRX| |%|d k rtj|t2}'|$|'}(|(1|34d%W5QRX| |'tj|d&})t5|)ft6d'}*t7t89|*| d(}+W5QRX|$|)ft6d)}*t8:|*},|,;t<|+W5QRXd S),aInstall a wheel. :param name: Name of the project to install :param wheeldir: Base directory of the unpacked wheel :param wheel_zip: open ZipFile for wheel being installed :param scheme: Distutils scheme dictating the install directories :param req_description: String used in place of the requirement, for logging :param pycompile: Whether to byte-compile installed Python files :param warn_script_location: Whether to check that scripts are installed into a directory on PATH :raises UnsupportedWheel: * when the directory holds an unpacked wheel with incompatible Wheel-Version * when the .dist-info dir does not match the wheel cSsg|]}|dr|qSz.dataendswithrer`r,r,r-r{Is z*install_unpacked_wheel..ignoreT)forcequietFcs.t|}t|}||<|r*|dS)z6Map archive RECORD paths to installation RECORD paths.N)r.r)srcfilermodifiedoldpathnewpath)rrrwheeldirr,r-record_installed[s   z0install_unpacked_wheel..record_installedNcsRt|t|D]8\}}}|t|dtjj}tj||} |rh|dkrhdd|D|dd<|D]} |r~|| r~qltj|| } tj||| } t| tj| rt | t | | t | } t tdrt| | j| jft| tjr,t | } | jt jBt jBt jB}t| |d}|r>|| }| | |qlqdS)Nr<cSsg|]}|ds|qSrrrr,r,r-r{rs z;install_unpacked_wheel..clobber..utimeF)rr&walkrlstripr'r)rriunlinkshutilcopyfilestathasattrrst_atimest_mtimeaccessX_OKst_modeS_IXUSRS_IXGRPS_IXOTHchmod)sourcedestis_basefixerfilterdirsubdirsfilesbasedirdestdirrrrst permissionsr)rr,r-clobberds6         z'install_unpacked_wheel..clobberzentry_points.txtcsh|dr|dd}n<|dr8|dd}n |drT|dd}n|}|kpf|kS)Nz.exez -script.pyiz.pya)rWr)name matchname)rurvr,r-is_entrypoint_wrappersz5install_unpacked_wheel..is_entrypoint_wrapperr~)rrr<pipENSUREPIP_OPTIONSzpip = altinstallz pip{} = {}rcSsg|]}td|r|qS)zpip(\d(\.\d)?)?$rematchrekr,r,r-r{s easy_installzeasy_install = zeasy_install-{} = {}cSsg|]}td|r|qS)zeasy_install(-\d\.\d)?$rrr,r,r-r{s z{} = {}rvzInvalid script entry point: {} for req: {} - A callable suffix is required. Cf https://packaging.python.org/specifications/entry-points/#use-for-scripts for more information.ic ;s<t|f| }|VW5QRXt|jt|j|dSrc)rr&rrr)r'kwargsr)generated_file_moder,r-_generate_file<sz.install_unpacked_wheel.._generate_file INSTALLERspip zutf-8RECORDr)rrrrw)F)NN)=r4r&r'r)rrYpurelibplatliblistdirrrwarningscatch_warningsfilterwarnings compileall compile_dirrdebuggetvaluerrwrTgetattrrr~rvariantsset_moderrrrVrAr>r?r extendrrr make_multiplerargsr rrr contextlibcontextmanagerrOr to_jsonrKrGrBrcsvreaderwriter writerowsr)-rr wheel_zipschemereq_description pycompilewarn_script_location direct_urlrinfo_dirrXr data_dirsrstdoutr dest_info_direp_filerdatadirrrsubdirrmakerscripts_to_generate pip_scriptpip_epreasy_install_scripteasy_install_epgui_scripts_to_generategenerated_console_scriptsermsgrinstaller_pathinstaller_filedirect_url_pathdirect_url_file record_path record_filerowsrr,)rrurrvrrrrr-install_unpacked_wheel s   $ @     #                   r9c CsZt|ddD}t|dd,} t||jt||j| |||||dW5QRXW5QRXdS)Nzunpacked-wheel)r'kindT) allowZip64)rrrrrrrr )rrrr'r9) r wheel_pathrrrr_temp_dir_for_testingr  unpacked_dirzr,r,r- install_wheel_s&   r@)r/)TTN)TTNN)X__doc__ __future__rrr rrloggingos.pathr&rrrr>rbase64r itertoolsrzipfiler pip._vendorrpip._vendor.distlib.scriptsrZpip._vendor.distlib.utilrZpip._vendor.sixr pip._internal.exceptionsr pip._internal.locationsr pip._internal.models.direct_urlr r pip._internal.utils.filesystemrrpip._internal.utils.miscrrrpip._internal.utils.temp_dirrpip._internal.utils.typingrpip._internal.utils.unpackingrrpip._internal.utils.wheelr email.messagertypingrrrrrrrr r!r"pip._internal.models.schemer#r$r5ZInstalledCSVRow getLoggerrrr.r9rBrTrYrwrrr Exceptionrrrr9r@r,r,r,r-st              0      #G$  F