Bu_c@@sddlmZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZdd lmZ ddl!m"Z#ddl$m%Z%ddl$m&Z'ddl(m)Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAddlBmCZCddlDmEZEmFZFddlGmHZHddlImJZJddlKmLZLeHrddlMmNZNmOZOmPZPmQZQmRZRmSZSmTZTddlmUZUdd lVmWZWdd!lXmYZYdd"lZm[Z[nej\e]Z^d#Z_d$e`fd%YZad&ZbdS('i(tabsolute_importN(t pkg_resourcestsix(t Requirement(tcanonicalize_name(tVersion(tparse(tPep517HookCaller(tNoOpBuildEnvironment(tInstallationError(t get_scheme(tLink(tgenerate_metadata(tinstall_editable(tLegacyInstallFailure(tinstall(t install_wheel(tload_pyproject_tomltmake_pyproject_path(tUninstallPathSet(t deprecated(tdirect_url_from_link(tHashes(t indent_log( task_path_existst backup_dirt display_pathtdist_in_install_pathtdist_in_site_packagestdist_in_usersitetget_distributiontget_installed_versionthide_urltredact_auth_from_url(t get_metadata(t TempDirectoryt tempdir_kinds(tMYPY_CHECK_RUNNING(trunning_under_virtualenv(tvcs(tAnytDicttIterabletListtOptionaltSequencetUnion(tBuildEnvironment(t Distribution(t SpecifierSet(tMarkercC@s|jtj}tjj|\}}tj||}|jdrmtj}tjj |d}nA|jdst tj }tjj |djdd}||d|d|S(sQReturn a pkg_resources.Distribution for the provided metadata directory. s .egg-infois .dist-infot-t project_nametmetadata( trstriptostseptpathtsplitRt PathMetadatatendswithR0tsplitexttAssertionErrortDistInfoDistribution(tmetadata_directorytdist_dirtbase_dirt dist_dir_nameR5tdist_clst dist_name((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt _get_distEs  #tInstallRequirementc B@seZdZed!d!d!ed!d!d!ed"ed ZdZdZdZe dZ e dZ e dZ e dZ d!d Ze d Zed Zd Zd ZdZdZdZe dZe dZe dZe dZdZdZdZe dZdZdZ eedZ!edZ"eedZ#dZ$dZ%d!d!d!d!eeed Z&RS(#s Represents something that may be installed later on, may have information about where to fetch the relevant requirement and also contains logic for installing the said requirement. cC@sC|dks't|ts't|||_||_| |_||_d|_d|_ |jr|srt|j rt j j t j j|j|_ qn|dkr|r|jrt|j}n||_|_t|_d|_|jr|jj r|jj|_n| r-| |_n+|rLd|jD|_n t|_|dkrv|rv|j}n||_d|_t|_d|_d|_|r|ng|_| r| ng|_ | r| ni|_!t|_"| |_#t|_$||_%t&|_'d|_(d|_)g|_*d|_+||_,dS(NcS@sh|]}tj|qS((Rt safe_extra(t.0textra((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pys s (-tNonet isinstanceRR>treqt comes_fromt constraintteditabletlegacy_install_reasont source_dirtis_fileR7R9tnormpathtabspatht file_pathturlR tlinkt original_linktFalsetoriginal_link_is_in_wheel_cachetlocal_file_pathtextrastsettmarkertmarkerst satisfied_bytshould_reinstallt_temp_build_dirtinstall_succeededtinstall_optionstglobal_optionst hash_optionstpreparedt user_suppliedtsuccessfully_downloadedtisolatedRt build_envR@tpyproject_requirestrequirements_to_checktpep517_backendt use_pep517(tselfRMRNRPRXR`RpRkReRfRgROR]Ri((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt__init__gsX'          !                  cC@s|jrFt|j}|jrj|djt|jj7}qjn$|jrdt|jj}nd}|jdk r|djt|jj 7}n|j rt |j t j r|j }n|j j}|r|dj|7}qn|S(Ns from {}ss in {}s (from {})(RMtstrRXtformatR!RWRaRKRtlocationRNRLRt string_typest from_path(RqtsRN((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt__str__s   % "  cC@s"dj|jjt||jS(Ns<{} object: {} editable={!r}>(Rtt __class__t__name__RsRP(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt__repr__sc@sYt|t}fdt|D}djd|jjddj|S(s>An un-tested helper for getting state, for debugging. c3@s%|]}dj||VqdS(s{}={!r}N(Rt(RItattr(t attributes(sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pys ss<{name} object: {{{state}}}>tnametstates, (tvarstsortedRtRzR{tjoin(RqtnamesR((R~sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt format_debugs     cC@s/|jdkrdStjtj|jjS(N(RMRKRt ensure_strRt safe_nameR(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRscC@s |jjS(N(RMt specifier(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyR scC@s:|j}t|dko9tt|jddhkS(sReturn whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. is==s===(Rtlentnexttitertoperator(Rqt specifiers((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt is_pinneds cC@s t|jS(N(RR(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytinstalled_versionsc@s@|sd}njdk r8tfd|DStSdS(Ntc3@s(|]}jji|d6VqdS(RJN(R`tevaluate(RIRJ(Rq(sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pys (s(R(R`RKtanytTrue(Rqtextras_requested((RqsN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt match_markers s   cC@s t|jS(sReturn whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. (tboolRg(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pythas_hash_options-s cC@sb|jj}|r|jn|j}|rX|jrX|j|jgj|jnt|S(sReturn a hash-comparer that considers my option- and URL-based hashes to be known-good. Hashes in URLs--ones embedded in the requirements file, not ones downloaded from an index server--are almost peers with ones from flags. They satisfy --require-hashes (whether it was implicitly or explicitly activated) but do not activate it. md5 and sha224 are not allowed in flags, which should nudge people toward good algos. We always OR all hashes together, even ones from URLs. :param trust_internet: Whether to trust URL-based (#md5=...) hashes downloaded from the internet, as by populate_link() ( RgtcopyRXRYthasht setdefaultt hash_nametappendR(Rqttrust_internett good_hashesRX((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pythashes8s "cC@sy|jdkrdSt|j}|jrut|jtjrL|j}n|jj}|ru|d|7}qun|S(s@Format a nice indicator to show where this "comes from" s->N(RMRKRsRNRLRRvRw(RqRxRN((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRwNs  c C@s"|dk st|jdk r=|jjs3t|jjS|jdkrqtdtjdt|_|jjSt |j }|rdj |t j j}ntjj|stjd|tj|ntjj||}|rdnt}td|d|dtjdtjS(Ntkindtglobally_manageds{}_{}sCreating directory %sR9tdelete(RKR>RcR9RMR#R$t REQ_BUILDRRRRttuuidtuuid4thexR7texiststloggertdebugtmakedirsRRZ(Rqt build_dirt autodeletetparallel_buildstdir_nametactual_build_dirt delete_arg((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytensure_build_location^s*   cC@s|jdkst|jdk s*t|jdk s?ttt|jdtrdd}nd}tdj |jd||jdg|_dS(s3Set requirement after generating metadata. Rs==s===RtNameN( RMRKR>R5RRRLt parse_versionRRR(Rqtop((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt_set_requirements  cC@s^t|jd}t|jj|kr/dStjd|j||jt||_dS(NRseGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.(RR5RMRRtwarningR(Rqt metadata_name((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytwarn_on_mismatching_namescC@s|jdkrdSt|jj}|s/dS|j}|jjj|dtsd|_|rt |rzt|_ qt rt |rt dj|j|jqqt|rt|_ qn'|jrt|_ d|_n ||_dS(sFind an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately. Nt prereleasessVWill not install to the user site because it will lack sys.path precedence to {} in {}(RMRKRRtparsed_versionRtcontainsRRaRRbR&RR RtR4RuRRP(Rqt use_user_sitet existing_disttexisting_version((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytcheck_if_existss,          cC@s|js tS|jjS(N(RXRZtis_wheel(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRs cC@s+tjj|j|jr$|jjp'dS(NR(R7R9RRRRXtsubdirectory_fragment(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytunpacked_source_directorys cC@sm|jstdj|tjj|jd}tjrit |tj ri|j t j }n|S(NsNo source dir for {}ssetup.py(RRR>RtR7R9RRRtPY2RLt text_typetencodetsystgetfilesystemencoding(Rqtsetup_py((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt setup_py_paths cC@s+|jstdj|t|jS(NsNo source dir for {}(RRR>RtRR(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytpyproject_toml_pathscC@st|j|j|jt|}|dkr=t|_dSt|_|\}}}}||_||_ t |j |d||_ dS(sALoad the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. Nt backend_path( RRpRRRsRKRZRRnRmRRRo(Rqtpyproject_toml_datatrequirestbackendtcheckR((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRs      c C@s|js^|jsttd|jd|jd|jd|jd|jpZdj|j S|j dk sstt d|jd|j S( sKInvokes metadata generator functions, with the required arguments. RlRRRRktdetailssfrom {}RN( RpRR>tgenerate_metadata_legacyRlRRkRRtRXRoRKR (Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt_generate_metadata s      cC@s\|jstt|j|_WdQX|jsD|jn |j|jdS(sEnsure that project metadata is available. Under PEP 517, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info. N( RRR>RRR@RRRtassert_source_matches_version(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytprepare_metadata"s    cC@s.t|ds't|j|_n|jS(Nt _metadata(thasattrR"tget_distR(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyR56scC@s t|jS(N(RFR@(Rq((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyR>scC@ss|jst|jd}|jjrP||jjkrPtjd||ntjdt|j||dS(Ntversions'Requested %s, but installing version %ss;Source in %s has version %s, which satisfies requirement %s( RRR>R5RMRRRRR(RqR((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRBs   cC@s4|jdkr0|j|d|d||_ndS(sAEnsure that a source_dir is set. This will create a temporary build dir if the name of the requirement isn't known yet. :param parent_dir: The ideal pip parent_dir for the source_dir. Generally src_dir for editables and build_dir for sdists. :return: self.source_dir RRN(RRRKR(Rqt parent_dirRR((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytensure_has_source_dirUs cC@s|js tjd|jdS|js/t|js>t|jjdkrTdSd|jjks~tdjt |jjj dd\}}t j |}|r\|jj sdj|jj}d}|jjjdrd}nt||d d d d nt|jj}|rC|j|jd |q}|j|jd |n!ds}tdj|j|dS(Ns>Cannot update repository at %s; repository location is unknowntfilet+sbad url: {self.link.url!r}is5This form of VCS requirement is being deprecated: {}.sgit+git@smgit+https://git@example.com/..., git+ssh://git@example.com/..., or the insecure git+git://git@example.com/...tgone_ins21.0tissueiRWis+Unexpected version control type (in {}): {}(RXRRRRRPR>tschemeRWRttlocalsR:R't get_backendtis_vcsRKt startswithRR tobtaintexport(RqRtvc_typeRWt vcs_backendtreasont replacementt hidden_url((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytupdate_editablems8     cC@sq|jstt|jj}|s>tjd|jdStjd|tj |}|j |||S(s Uninstall the distribution currently satisfying this requirement. Prompts before removing or modifying files unless ``auto_confirm`` is True. Refuses to delete or modify files outside of ``sys.prefix`` - thus uninstallation within a virtual environment can only modify that virtual environment, even if the virtualenv is linked to global site-packages. s#Skipping %s as it is not installed.sFound existing installation: %sN( RMR>RRRRRKtinfoRt from_disttremove(Rqt auto_confirmtverbosetdisttuninstalled_pathset((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt uninstallscC@s<d}tjj||}|||}|jd|S(NcS@sa|j|tjjs1tdjt|t|d}|jtjjd}|S(Ns2name {name!r} doesn't start with prefix {prefix!r}it/( RR7R9R8R>RtRRtreplace(Rtprefix((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt_clean_zip_names R(R7R9RR(RqR9t parentdirtrootdirRR((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyt_get_archive_names c C@sb|jstt}dj|j|jd}tjj||}tjj |r&t djt |d}|dkrt }q&|dkrt jdt |tj|q&|dkrt|}t jd t |t |tj||q&|dkr&tjd q&n|s0d Stj|dtjd t}|tjjtjj|j}xtj|D]\} } } xU| D]M} |j| d | d|} tj| d}d|_|j|dqWxN| D]F}|j|d | d|}tjj| |}|j ||qWqWWd QXt j!dt |d S(s}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. s {}-{}.zipRs8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort titwtbtas Deleting %ssBacking up %s to %siNt allowZip64RRRiiRsSaved %s(RRRRi("RRR>RRtRR5R7R9RRRRRZRRRRtshutiltmoveRtexittzipfiletZipFilet ZIP_DEFLATEDtnormcaseRURtwalkRtZipInfot external_attrtwritestrtwriteR(RqRtcreate_archivet archive_namet archive_pathtresponset dest_filet zip_outputtdirtdirpathtdirnamest filenamestdirnamet dir_arcnametzipdirtfilenamet file_arcname((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytarchivesV              c C@syt|jd|d|d|d|jd|} |dk rB|ng}|jrt||d|d|d|d|jd|jd|jd |jd |jt |_ dS|j r?|j st d} |jrt|j|j|j} nt|j|j d | d t|jd |d|d| d|jt |_ dSt||j}t||j}yytd|d|d|d|d|d|d |d | d|jd|jd|jd |jd |jd t|j} WnHtk r } t|_ tj| jntk r(t |_ nX| |_ | ru|j dkrut!ddj"|jddddddndS(NtuserthometrootRkRRRRRlRRtreq_descriptiont pycompiletwarn_script_locationt direct_urlt requestedReRftreq_namei Rsg{} was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.Rs+to fix the wheel build issue reported aboveRs21.0R(#R RRkRKRPtinstall_editable_legacyRRlRRRdRR\R>RYRRRR[RRsRMRitlistRfRetinstall_legacyRRZRtreraisetparentt ExceptionRQRRt( RqReRfRRRR!RR RR"tsuccesstexc((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRs                           N(('R{t __module__t__doc__RZRKRrRyR|RtpropertyRRRRRRRRRwRRRRRRRRRRRR5RRRRRRRR(((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyRG`sd e        &   %        ,  @c C@shd}|jsd}n$|jr*d}n|jr<d}n|rdtddddd dd d n|S( NRs3Unnamed requirements are not allowed as constraintss$Links are not allowed as constraintssConstraints cannot have extrasRsConstraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms.Rs,replacing the constraint with a requirement.RRi (RRXR]RRK(RMtproblem((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pytcheck_invalid_constraint_typems       (ct __future__RtloggingR7RRRRt pip._vendorRRt"pip._vendor.packaging.requirementsRtpip._vendor.packaging.utilsRtpip._vendor.packaging.versionRRRtpip._vendor.pep517.wrappersRtpip._internal.build_envRtpip._internal.exceptionsR tpip._internal.locationsR tpip._internal.models.linkR t'pip._internal.operations.build.metadataR t.pip._internal.operations.build.metadata_legacyRt0pip._internal.operations.install.editable_legacyR R%t'pip._internal.operations.install.legacyRRR't&pip._internal.operations.install.wheelRtpip._internal.pyprojectRRtpip._internal.req.req_uninstallRtpip._internal.utils.deprecationRt&pip._internal.utils.direct_url_helpersRtpip._internal.utils.hashesRtpip._internal.utils.loggingRtpip._internal.utils.miscRRRRRRRRR R!tpip._internal.utils.packagingR"tpip._internal.utils.temp_dirR#R$tpip._internal.utils.typingR%tpip._internal.utils.virtualenvR&tpip._internal.vcsR'ttypingR(R)R*R+R,R-R.R/tpip._vendor.pkg_resourcesR0t pip._vendor.packaging.specifiersR1tpip._vendor.packaging.markersR2t getLoggerR{RRFtobjectRGR1(((sN/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.pyts^      F 4