3 Bu_@sDddlmZddlZddlZddlZddlZddlZddlZddlm 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;mZ>m?Z?m@Z@mAZAddlBmCZCddlDmEZEmFZFddlGmHZHddlImJZJddlKmLZLeHrddlMmNZNmOZOmPZPmQZQmRZRmSZSmTZTddlmUZUdd lVmWZWdd!lXmYZYdd"lZm[Z[ej\e]Z^d#d$Z_Gd%d&d&e`Zad'd(ZbdS)))absolute_importN) pkg_resourcessix) Requirement)canonicalize_name)Version)parse)Pep517HookCaller)NoOpBuildEnvironment)InstallationError) get_scheme)Link)generate_metadata)install_editable)LegacyInstallFailure)install) install_wheel)load_pyproject_tomlmake_pyproject_path)UninstallPathSet) deprecated)direct_url_from_link)Hashes) indent_log) ask_path_exists backup_dir display_pathdist_in_install_pathdist_in_site_packagesdist_in_usersiteget_distributionget_installed_versionhide_urlredact_auth_from_url) get_metadata) TempDirectory tempdir_kinds)MYPY_CHECK_RUNNING)running_under_virtualenv)vcs)AnyDictIterableListOptionalSequenceUnion)BuildEnvironment) Distribution) SpecifierSet)MarkercCs|jtj}tjj|\}}tj||}|jdrJtj}tjj |d}n.|jdsXt tj }tjj |djdd}||||dS)zQReturn a pkg_resources.Distribution for the provided metadata directory. z .egg-inforz .dist-info-) project_namemetadata) rstriposseppathsplitr PathMetadataendswithr2splitextAssertionErrorDistInfoDistribution)metadata_directorydist_dirbase_dir dist_dir_namer7dist_cls dist_namerH/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-1.el7.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_install.py _get_distEs   rJc @s\eZdZdZdddddddddfdf ddZddZdd Zd d Zed d Z eddZ eddZ eddZ dEddZ eddZdFddZddZddZdd Zd!d"Zd#d$Zed%d&Zed'd(Zed)d*Zed+d,Zd-d.Zd/d0Zd1d2Zed3d4Zd5d6Zd7d8ZdGd9d:ZdHd;d<Z dId=d>Z!d?d@Z"dAdBZ#dJdCdDZ$dS)KInstallRequirementz 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. FNcCs|dkst|tst|||_||_| |_||_d|_d|_|jrj|sLt|j rjt j j t j j |j|_|dkr|r|jrt|j}||_|_d|_d|_|jr|jj r|jj|_| r| |_n |rdd|jD|_nt|_|dkr|r|j}||_d|_d|_d|_d|_|r|ng|_| r,| ng|_| r<| ni|_d|_ | |_!d|_"||_#t$|_%d|_&d|_'g|_(d|_)||_*dS)NFcSsh|]}tj|qSrH)r safe_extra).0extrarHrHrI sz.InstallRequirement.__init__..)+ isinstancerr@req comes_from constrainteditablelegacy_install_reason source_diris_filer9r;normpathabspath file_pathurlr link original_linkoriginal_link_is_in_wheel_cachelocal_file_pathextrassetmarkermarkers satisfied_byshould_reinstall_temp_build_dirinstall_succeededinstall_optionsglobal_options hash_optionsprepared user_suppliedsuccessfully_downloadedisolatedr build_envrBpyproject_requiresrequirements_to_checkpep517_backend use_pep517)selfrQrRrTr\rcrsrnrhrirjrSr`rlrHrHrI__init__gsZ     zInstallRequirement.__init__cCs|jr.t|j}|jrF|djt|jj7}n|jrBt|jj}nd}|jdk rf|djt|jj7}|j rt |j t j r|j }n |j j }|r|dj|7}|S)Nz from {}zz in {}z (from {}))rQstrr\formatr#r[rdrlocationrRrPr string_types from_path)rtsrRrHrHrI__str__s    zInstallRequirement.__str__cCsdj|jjt||jS)Nz<{} object: {} editable={!r}>)rw __class____name__rvrT)rtrHrHrI__repr__szInstallRequirement.__repr__cs>t|t}fddt|D}dj|jjdj|dS)z>An un-tested helper for getting state, for debugging. c3s|]}dj||VqdS)z{}={!r}N)rw)rMattr) attributesrHrI sz2InstallRequirement.format_debug..z<{name} object: {{{state}}}>z, )namestate)varssortedrwr}r~join)rtnamesrrH)rrI format_debugs zInstallRequirement.format_debugcCs"|jdkrdStjtj|jjS)N)rQr ensure_strr safe_namer)rtrHrHrIrs zInstallRequirement.namecCs|jjS)N)rQ specifier)rtrHrHrIr szInstallRequirement.specifiercCs$|j}t|dko"tt|jdkS)zReturn whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. =====>rr)rlennextiteroperator)rt specifiersrHrHrI is_pinneds zInstallRequirement.is_pinnedcCs t|jS)N)r!r)rtrHrHrIinstalled_versionsz$InstallRequirement.installed_versioncs0|sd}jdk r(tfdd|DSdSdS)Nc3s|]}jjd|iVqdS)rNN)rcevaluate)rMrN)rtrHrIr(sz3InstallRequirement.match_markers..T)r)rcany)rtextras_requestedrH)rtrI match_markers s   z InstallRequirement.match_markerscCs t|jS)zReturn whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. )boolrj)rtrHrHrIhas_hash_options-s z#InstallRequirement.has_hash_optionsTcCsB|jj}|r|jn|j}|r:|jr:|j|jgj|jt|S)aReturn 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() ) rjcopyr\r]hash setdefault hash_nameappendr)rttrust_internet good_hashesr\rHrHrIhashes8s   zInstallRequirement.hashescCsR|jdkrdSt|j}|jrNt|jtjr4|j}n |jj}|rN|d|7}|S)z@Format a nice indicator to show where this "comes from" Nz->)rQrvrRrPrryrz)rtr{rRrHrHrIrzNs    zInstallRequirement.from_pathcCs|dk s t|jdk r*|jjs"t|jjS|jdkrLttjdd|_|jjSt|j}|rldj |t j j }t jj|stjd|t j|t jj||}|rdnd}t||tjddjS)NT)kindglobally_managedz{}_{}zCreating directory %sF)r;deleterr)r@rfr;rQr%r& REQ_BUILDrrrwuuiduuid4hexr9existsloggerdebugmakedirsr)rt build_dir autodeleteparallel_buildsdir_nameactual_build_dir delete_argrHrHrIensure_build_location^s*         z(InstallRequirement.ensure_build_locationcCsn|jdkst|jdk st|jdk s*ttt|jdtrDd}nd}tdj|jd||jdg|_dS)z3Set requirement after generating metadata. Nrz==z===rName) rQr@r7rVrP parse_versionrrr)rtoprHrHrI_set_requirementsz#InstallRequirement._set_requirementcCsDt|jd}t|jj|kr"dStjd|j||jt||_dS)NrzeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.)rr7rQrrwarningr)rt metadata_namerHrHrIwarn_on_mismatching_namesz+InstallRequirement.warn_on_mismatching_namecCs|jdkrdSt|jj}|s"dS|j}|jjj|ddsd|_|rxt|rTd|_qt rt |rt dj |j |jqt|rd|_n|jrd|_d|_n||_dS)zFind an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately. NT) prereleaseszVWill not install to the user site because it will lack sys.path precedence to {} in {})rQr rparsed_versionrcontainsrdrrer(rr rwr6rxrrT)rt use_user_site existing_distexisting_versionrHrHrIcheck_if_existss,  z"InstallRequirement.check_if_existscCs|js dS|jjS)NF)r\is_wheel)rtrHrHrIrszInstallRequirement.is_wheelcCstjj|j|jr|jjpdS)Nr)r9r;rrVr\subdirectory_fragment)rtrHrHrIunpacked_source_directorysz,InstallRequirement.unpacked_source_directorycCsH|jstdj|tjj|jd}tjrDt |tj rD|j t j }|S)NzNo source dir for {}zsetup.py)rVr@rwr9r;rrrPY2rP text_typeencodesysgetfilesystemencoding)rtsetup_pyrHrHrI setup_py_paths z InstallRequirement.setup_py_pathcCs|jstdj|t|jS)NzNo source dir for {})rVr@rwrr)rtrHrHrIpyproject_toml_pathsz&InstallRequirement.pyproject_toml_pathcCs^t|j|j|jt|}|dkr*d|_dSd|_|\}}}}||_||_t|j||d|_ dS)aALoad 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. NFT) backend_path) rrsrrrvrqrpr rrr)rtpyproject_toml_datarequiresbackendcheckrrHrHrIrs   z&InstallRequirement.load_pyproject_tomlcCsV|js8|jstt|j|j|j|j|jp2dj|j dS|j dk sFtt |j|j dS)zKInvokes metadata generator functions, with the required arguments. zfrom {})rorrVrndetailsN)ror) rsrr@generate_metadata_legacyrorrnrrwr\rrr)rtrHrHrI_generate_metadata s z%InstallRequirement._generate_metadatac CsJ|js tt|j|_WdQRX|js6|jn|j|jdS)zEnsure 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) rVr@rrrBrrrassert_source_matches_version)rtrHrHrIprepare_metadata"s  z#InstallRequirement.prepare_metadatacCst|dst|j|_|jS)N _metadata)hasattrr$get_distr)rtrHrHrIr76s zInstallRequirement.metadatacCs t|jS)N)rJrB)rtrHrHrIr>szInstallRequirement.get_distcCsR|js t|jd}|jjr8||jjkr8tjd||ntjdt|j||dS)Nversionz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s) rVr@r7rQrrrrr)rtrrHrHrIrBs  z0InstallRequirement.assert_source_matches_versioncCs |jdkr|j|||d|_dS)aAEnsure 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 N)rr)rVr)rt parent_dirrrrHrHrIensure_has_source_dirUs  z(InstallRequirement.ensure_has_source_dircCs|jstjd|jdS|js"t|js,t|jjdkrCannot update repository at %s; repository location is unknownfile+zbad url: {self.link.url!r}rz5This form of VCS requirement is being deprecated: {}.zgit+git@zmgit+https://git@example.com/..., git+ssh://git@example.com/..., or the insecure git+git://git@example.com/...z21.0i)gone_inissue)r[rz+Unexpected version control type (in {}): {})r\rrrVrTr@schemer[rwlocalsr<r) get_backendis_vcs startswithrr"obtainexport)rtrvc_typer[ vcs_backendreason replacement hidden_urlrHrHrIupdate_editablems8      z"InstallRequirement.update_editablecCsR|js tt|jj}|s,tjd|jdStjd|tj|}|j |||S)a 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. z#Skipping %s as it is not installed.NzFound existing installation: %s) rQr@r rrrinfor from_distremove)rt auto_confirmverbosedistuninstalled_pathsetrHrHrI uninstalls     zInstallRequirement.uninstallcCs.dd}tjj||}|||}|jd|S)NcSsL|j|tjjs$tdjft|t|dd}|jtjjd}|S)Nz2name {name!r} doesn't start with prefix {prefix!r}r/) rr9r;r:r@rwrrreplace)rprefixrHrHrI_clean_zip_names  z=InstallRequirement._get_archive_name.._clean_zip_namer)r9r;rr)rtr; parentdirrootdirrrrHrHrI_get_archive_names  z$InstallRequirement._get_archive_namecCs|js td}dj|j|jd}tjj||}tjj|rt djt |d}|dkr^d }nj|dkrt j d t |tj |nF|dkrt|}t j d t |t |tj||n|dkrtjd|sd Stj|dtjdd}|tjjtjj|j}xtj|D]\} } } x>| D]6} |j| | |d} tj| d}d|_|j|dqWx8| D]0}|j|| |d}tjj| |}|j||q\Wq WWd QRXt jdt |d S)z}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. Tz {}-{}.ziprz8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort iwbaFz Deleting %szBacking up %s to %srN) allowZip64)rrrirzSaved %s)rrrri) rVr@rwrr7r9r;rrrrrrrrshutilmoverexitzipfileZipFile ZIP_DEFLATEDnormcaserYrwalkrZipInfo external_attrwritestrwriter)rtrcreate_archive archive_name archive_pathresponse dest_file zip_outputdirdirpathdirnames filenamesdirname dir_arcnamezipdirfilename file_arcnamerHrHrIarchivesV         "zInstallRequirement.archivec Cst|j||||j|d} |dk r$|ng}|jr^t||||||j|j|j|j|jd d|_dS|j r|j snt d} |j rt |j |j|j} t|j|j | t|j||| |jdd|_dSt||j}t||j}y8t|||||||| |j|j|j|j|jt|jd} WnRtk rB} zd|_tj| jWYdd} ~ Xntk r^d|_YnX| |_| r|jdkrtdj|jd d dd dS) N)userhomerootrnr)rr%rrrrnrorT)rreq_description pycompilewarn_script_location direct_url requested)rhrir&r%rrr(rrrnreq_namerorr'Fi zg{} was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.z+to fix the wheel build issue reported abovez21.0)rrrr) r rrnrTinstall_editable_legacyrrorrgrr_r@r]rrVr^rrvrQrllistrirhinstall_legacyrrreraiseparent ExceptionrUrrw) rtrhrir&r%rr)rr(rr*successexcrHrHrIrs     zInstallRequirement.install)N)T)FF)T)FF)NNNNTFT)%r~ __module__ __qualname____doc__rur|rrpropertyrrrrrrrrzrrrrrrrrrrrr7rrrrrrr#rrHrHrHrIrK`sd e    &%      , @rKcCs>d}|jsd}n|jrd}n |jr&d}|r:tddddd|S) Nrz3Unnamed requirements are not allowed as constraintsz$Links are not allowed as constraintszConstraints cannot have extrasaConstraints 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.z,replacing the constraint with a requirement.i )rrrr)rr\r`r)rQproblemrHrHrIcheck_invalid_constraint_typemsr:)c __future__rloggingr9rrrr  pip._vendorrrZ"pip._vendor.packaging.requirementsrZpip._vendor.packaging.utilsrpip._vendor.packaging.versionrrrpip._vendor.pep517.wrappersr pip._internal.build_envr pip._internal.exceptionsr pip._internal.locationsr pip._internal.models.linkr 'pip._internal.operations.build.metadatar.pip._internal.operations.build.metadata_legacyr0pip._internal.operations.install.editable_legacyrr-'pip._internal.operations.install.legacyrrr/&pip._internal.operations.install.wheelrpip._internal.pyprojectrrpip._internal.req.req_uninstallrpip._internal.utils.deprecationr&pip._internal.utils.direct_url_helpersrpip._internal.utils.hashesrpip._internal.utils.loggingrpip._internal.utils.miscrrrrrrr r!r"r#pip._internal.utils.packagingr$pip._internal.utils.temp_dirr%r&pip._internal.utils.typingr'pip._internal.utils.virtualenvr(pip._internal.vcsr)typingr*r+r,r-r.r/r0r1Zpip._vendor.pkg_resourcesr2Z pip._vendor.packaging.specifiersr3Zpip._vendor.packaging.markersr4 getLoggerr~rrJobjectrKr:rHrHrHrIsd                     0    $