U ʗRe@s4ddlZddlZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZmZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZm Z dd l!m"Z"m#Z#dd l$m%Z%dd l&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m2Z6ddl7m8Z9ddl:m;Z<ddl=m>Z>ddl?m@Z@mAZAddlBmCZCddlDmEZEddlFmGZGmHZHddlImJZJddlKmLZLmMZMmNZNmOZOmPZPmQZQddlRmSZSddlTmUZUddlVmWZWmXZXddlYmZZZdd l[m\Z\e]e^Z_Gd!d"d"Z`e`ead#d$d%ZbdS)&N)Any CollectionDictIterableListOptionalSequenceUnion)Marker) Requirement) SpecifierSet)canonicalize_name)Version)parse)Pep517HookCaller)BuildEnvironmentNoOpBuildEnvironment)InstallationErrorLegacyInstallFailure) get_scheme)BaseDistributionget_default_environmentget_directory_distributionget_wheel_distribution)FilesystemWheel) DirectUrl)Link)generate_metadata)generate_editable_metadata)install_editable)install) install_wheel)load_pyproject_tomlmake_pyproject_path)UninstallPathSet) deprecated)direct_url_for_editabledirect_url_from_link)Hashes)ConfiguredPep517HookCallerask_path_exists backup_dir display_pathhide_urlredact_auth_from_url safe_extra)runner_with_spinner_message) TempDirectory tempdir_kinds)running_under_virtualenv)vcsc@seZdZdZdSeeeeedfeee ee eeeee eee eee ee efee eefee eeeddddZedd d Zedd d Zedd dZeeedddZeedddZeedddZeedddZdTeeeedddZeedddZdUeedddZeedd d!Zeeeed"d#d$Z ddd%d&Z!ddd'd(Z"edd)d*d+Z#eedd,d-Z$eedd.d/Z%eedd0d1Z&eedd2d3Z'eedd4d5Z(ddd6d7Z)ddd8d9Z*ddd:d;Z+ee,ddd?Z/ddd@dAZ0dVeeeddBdCdDZ1dddEdFZ2dWeeee3dGdHdIZ4eeeedJdKdLZ5eeddMdNdOZ6dXe eee7eeeeeeeeeeddP dQdRZ8dS)YInstallRequirementz 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. FN)req comes_fromeditablelinkmarkers use_pep517isolatedinstall_optionsglobal_options hash_optionsconfig_settings constraintextras user_suppliedpermit_editable_wheelsreturncCs|dkst|tst|||_||_| |_||_||_d|_d|_ |jrp|sRt|j rpt j t j |j|_ |dkr|r|jrt|j}||_|_d|_d|_d|_|jr|jj r|jj|_| r| |_n |rdd|jD|_nt|_|dkr|r|j}||_d|_d|_d|_d|_|r,|ng|_| r<| ng|_ | rL| ni|_!| |_"d|_#||_$||_%t&|_'d|_(d|_)g|_*d|_+||_,d|_-dS)NFcSsh|] }t|qSr7r/.0extrar7r7/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/req/req_install.py sz.InstallRequirement.__init__..). isinstancer AssertionErrorr8r9rCr:rFlegacy_install_reason source_diris_fileospathnormpathabspath file_pathurlrr; original_linkoriginal_link_is_in_wheel_cache download_infolocal_file_pathrDsetmarkerr< satisfied_byshould_reinstall_temp_build_dirinstall_succeededr?r@rArBpreparedrEr>r build_envmetadata_directorypyproject_requiresrequirements_to_checkpep517_backendr=needs_more_preparation)selfr8r9r:r;r<r=r>r?r@rArBrCrDrErFr7r7rK__init__Ks\   zInstallRequirement.__init__)rGcCs|jr.t|j}|jrF|dt|jj7}n|jrBt|jj}nd}|jdk rf|dt|jj7}|j rt |j tr|j }n |j }|r|d|d7}|S)Nz from {}zz in {}z (from )) r8strr;formatr.rWr^r,locationr9rM from_pathrisr9r7r7rK__str__s     zInstallRequirement.__str__cCsd|jjt||jS)Nz<{} object: {} editable={!r}>)rm __class____name__rlr:rir7r7rK__repr__s zInstallRequirement.__repr__cs>t|t}fddt|D}dj|jjd|dS)z5An un-tested helper for getting state, for debugging.c3s|]}d||VqdS)z{}={!r}N)rm)rIattr attributesr7rK sz2InstallRequirement.format_debug..z<{name} object: {{{state}}}>z, )namestate)varssortedrmrsrtjoin)rinamesr|r7rxrK format_debugszInstallRequirement.format_debugcCs|jdkrdS|jjSN)r8r{rur7r7rKr{s zInstallRequirement.namec Csl|js dS|jst|jHtd}|j|(d|jkW5QRW5QRSQRXW5QRXdS)NFz1Checking if build backend supports build_editablebuild_editable)r=rgrNrcr1subprocess_runner_supported_features)rirunnerr7r7rKsupports_pyproject_editables z.InstallRequirement.supports_pyproject_editablecCs|jjSr)r8 specifierrur7r7rKrszInstallRequirement.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. >=====)rlennextiteroperator)ri specifiersr7r7rK is_pinnedszInstallRequirement.is_pinned)extras_requestedrGcs0|sd}jdk r(tfdd|DSdSdS)N)c3s|]}jd|iVqdS)rJN)r<evaluaterHrur7rKrzsz3InstallRequirement.match_markers..T)r<any)rirr7rurK match_markerss  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. )boolrArur7r7rKhas_hash_options sz#InstallRequirement.has_hash_optionsT)trust_internetrGcCsB|j}|r|jn|j}|r:|jr:||jg|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() ) rAcopyr;rXhash setdefault hash_nameappendr()rir good_hashesr;r7r7rKhashess   zInstallRequirement.hashescCsP|jdkrdSt|j}|jrLt|jtr2|j}n |j}|rL|d|7}|S)z8Format a nice indicator to show where this "comes from" Nz->)r8rlr9rMrorpr7r7rKro)s     zInstallRequirement.from_path) build_dir autodeleteparallel_buildsrGcCs|dk s t|jdk r*|jjs"t|jjS|jdkrLttjdd|_|jjSt|j}|rn|dt j }t j |std|t |t j||}|rdnd}t||tjddjS)NT)kindglobally_managed_zCreating directory %sF)rSdeleterr)rNr`rSr8r2r3 REQ_BUILDr r{uuiduuid4hexrRexistsloggerdebugmakedirsr)rirrrdir_nameactual_build_dir delete_argr7r7rKensure_build_location7s0         z(InstallRequirement.ensure_build_locationcCsn|jdkst|jdk st|jdk s*ttt|jdtrDd}nd}td|jd||jdg|_dS)z*Set requirement after generating metadata.NrrrrName) r8rNmetadatarPrM parse_versionrr r)riopr7r7rK_set_requirementbsz#InstallRequirement._set_requirementcCsDt|jd}t|jj|kr"dStd|j||jt||_dS)NrzeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.)r rr8r{rwarningr )ri metadata_namer7r7rKwarn_on_mismatching_namexsz+InstallRequirement.warn_on_mismatching_name) use_user_siterGcCs|jdkrdSt|jj}|s&dS|jjj|jdd}|sd|_|r||jrVd|_ qt r|j rt d|j d|jq|jrd|_ 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) prereleaseszNWill not install to the user site because it will lack sys.path precedence to z in )r8rget_distributionr{rcontainsversionr^ in_usersiter_r4in_site_packagesrraw_namernin_install_pathr:)rir existing_distversion_compatibler7r7rKcheck_if_existss0  z"InstallRequirement.check_if_existscCs|js dS|jjS)NF)r;is_wheelrur7r7rKrszInstallRequirement.is_wheelcCstj|j|jr|jjpdS)Nr)rRrSrrPr;subdirectory_fragmentrur7r7rKunpacked_source_directorysz,InstallRequirement.unpacked_source_directorycCs(|jstd|tj|jd}|S)NNo source dir for zsetup.pyrPrNrRrSrr)risetup_pyr7r7rK setup_py_pathsz InstallRequirement.setup_py_pathcCs(|jstd|tj|jd}|S)Nrz setup.cfgr)ri setup_cfgr7r7rKsetup_cfg_pathsz!InstallRequirement.setup_cfg_pathcCs|jstd|t|jS)Nr)rPrNr#rrur7r7rKpyproject_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) r"r=rrrlrfrer)rrg)ripyproject_toml_datarequiresbackendcheckrr7r7rKr"s& z&InstallRequirement.load_pyproject_tomlcCsD|jr@|jr@|s@tj|js@tj|js@td|ddS)zCheck that an editable requirement if valid for use with PEP 517/518. This verifies that an editable that has a pyproject.toml either supports PEP 660 or as a setup.py or a setup.cfg zProject z has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.N) r:r=rrRrSisfilerrrrur7r7rKisolated_editable_sanity_checks   z1InstallRequirement.isolated_editable_sanity_checkcCs|js t|jpd|j}|jrp|jdk s0t|jrZ|jrZ|rZt |j |j|d|_ qt |j |j|d|_ nt |j |j|j|j|d|_ |js|n||dS)zEnsure that project metadata is available. Under PEP 517 and PEP 660, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info. zfrom N)rcrdetails)rcrrPr>r)rPrNr{r;r=rgr:rFrrrcrdrgenerate_metadata_legacyrrr>rrassert_source_matches_version)rirr7r7rKprepare_metadatas>     z#InstallRequirement.prepare_metadatacCst|ds|j|_|jS)N _metadata)hasattrget_distrrrur7r7rKr+s  zInstallRequirement.metadatacCsF|jrt|jS|jr2|jr2tt|jt|jStd|ddS)NzInstallRequirement zC has no metadata directory and no wheel: can't make a distribution.) rdrr[rrrr r{rNrur7r7rKr2s   zInstallRequirement.get_distcCsR|js t|jd}|jjr8||jjkr8td||ntdt|j||dS)Nrz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s) rPrNrr8rrrrr,)rirr7r7rKr>s  z0InstallRequirement.assert_source_matches_version) parent_dirrrrGcCs |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)rPr)rirrrr7r7rKensure_has_source_dirPs  z(InstallRequirement.ensure_has_source_dircCs|jstd|jdS|js"t|js,t|jjdkrCannot update repository at %s; repository location is unknownfilezUnsupported VCS URL r)rW verbosity) r;rrrPr:rNschemer5get_backend_for_schemerWr-obtain)ri vcs_backend hidden_urlr7r7rKupdate_editablegs    z"InstallRequirement.update_editable) auto_confirmverboserGcCsV|js tt|jj}|s0td|jdStd|t |}| |||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) r8rNrrr{rrinfor$ from_distremove)rirrdistuninstalled_pathsetr7r7rK uninstall{s    zInstallRequirement.uninstall)rS parentdirrootdirrGcCs8tttddd}tj||}|||}|jd|S)N)r{prefixrGcSsN||tjjs&td|d||t|dd}|tjjd}|S)Nzname z doesn't start with prefix r/) startswithrRrSseprNrreplace)r{rr7r7rK_clean_zip_names z=InstallRequirement._get_archive_name.._clean_zip_namer)rlrRrSrr{)rirSrrrr{r7r7rK_get_archive_names z$InstallRequirement._get_archive_name)rrGc Cs|js t|dkrdSd}d|j|jd}tj||}tj|rt dt |d}|dkrjd}nj|d krt d t |t |nF|d krt|}t d t |t |t||n|d krtd|sdStj|d tjdd}|tjtj|j}t|D]~\} } } | D]6} |j| | |d} t| d}d|_||dq$| D]0}|j|| |d}tj| |}|||q`qW5QRXt dt |dS)z}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. NTz {}-{}.ziprz8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )iwbarFrz Deleting %srzBacking up %s to %sr) allowZip64)rrrirzSaved %s) rPrNrmr{rrRrSrrr*r,rrrr+shutilmovesysexitzipfileZipFile ZIP_DEFLATEDnormcaserUrwalkrZipInfo external_attrwritestrwriter)rircreate_archive archive_name archive_pathresponse dest_file zip_outputdirdirpathdirnames filenamesdirname dir_arcnamezipdirfilename file_arcnamer7r7rKarchivesr    zInstallRequirement.archive) r?r@roothomerwarn_script_locationr pycompilerGc Cst|j||||j|d} |dk r$|ng}|jrd|jsdt||||||j|j|j|j|jd d|_ dS|jr|j stt d} |jrt |j} n|j rt|j |j|j} t|j|j | t|j||| |jdd|_ dSt||j}t||j}z8t|||||||| |j|j|j|j|jt|jd} WnJtk rR} zd|_ | W5d} ~ XYntk rnd|_ YnX| |_ | r|jdkrtd|jd ddd dS) N)userrrr>r)rrrr{rr>rcrT)rreq_descriptionr!r  direct_url requested)r?r@rrrrr!rrr>req_namercrr#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 abovereason replacementgone_inissue)rr{r>r:rinstall_editable_legacyrrcrrar[rNr&rXr'rPrYr!rlr8rElistr@r?install_legacyr ExceptionrOr%rm) rir?r@rrrr rr!rr$successexcr7r7rKr s         zInstallRequirement.install) FNNNFNNNNFr7FF)N)T)FF)FF)NNNNTFT)9rt __module__ __qualname____doc__rr r rlrrr rrrrjrrrvrpropertyr{ functools lru_cacherr rrrrrr(rrorrrrrrrrrr"rrrrrrrrrr$rrrrr r7r7r7rKr6Ds    o     +&,    F r6)r8rGcCs>d}|jsd}n|jrd}n |jr&d}|r:tddddd|S) Nrz3Unnamed requirements are not allowed as constraintsz4Editable requirements 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 requirementi r')r{r:rDr%)r8problemr7r7rKcheck_invalid_constraint_typeUsr9)cr6loggingrRrrrrtypingrrrrrrrr Zpip._vendor.packaging.markersr "pip._vendor.packaging.requirementsr Z pip._vendor.packaging.specifiersr pip._vendor.packaging.utilsr Zpip._vendor.packaging.versionrrrZpip._vendor.pep517.wrappersrpip._internal.build_envrrpip._internal.exceptionsrrpip._internal.locationsrpip._internal.metadatarrrrZpip._internal.metadata.baserpip._internal.models.direct_urlrpip._internal.models.linkr'pip._internal.operations.build.metadatar0pip._internal.operations.build.metadata_editabler.pip._internal.operations.build.metadata_legacyr0pip._internal.operations.install.editable_legacyrr,'pip._internal.operations.install.legacyr r.&pip._internal.operations.install.wheelr!pip._internal.pyprojectr"r#pip._internal.req.req_uninstallr$pip._internal.utils.deprecationr%&pip._internal.utils.direct_url_helpersr&r'pip._internal.utils.hashesr(pip._internal.utils.miscr)r*r+r,r-r.pip._internal.utils.packagingr0pip._internal.utils.subprocessr1pip._internal.utils.temp_dirr2r3pip._internal.utils.virtualenvr4pip._internal.vcsr5 getLoggerrtrr6rlr9r7r7r7rKs^(