o EcB@sdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z ddl mZddlmZddlmZdd lmZdd lmZmZdd lmZdd lmZdd lmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8ddl9m:Z:e;e<Z=GdddeZ>Gdddee>Z?e8j@e8jAe8jBgZCd&dd ZDd!e de fd"d#ZEGd$d%d%e?ZFdS)'aContains the Command base classes that depend on PipSession. The classes in this module are in a separate module so the commands not needing download / PackageFinder capability don't unnecessarily import the PackageFinder machinery and all its vendored dependencies, etc. N)partial)Values)AnyListOptionalTuple) WheelCache) cmdoptions)Command)CommandContextMixIn) CommandErrorPreviousBuildDirError) LinkCollector) PackageFinder)SelectionPreferences) TargetPython) PipSession)RequirementPreparer)install_req_from_editableinstall_req_from_line#install_req_from_parsed_requirementinstall_req_from_req_string)parse_requirements)InstallRequirement)RequirementTracker) BaseResolver)pip_self_version_check) deprecated) TempDirectoryTempDirectoryTypeRegistry tempdir_kinds)running_under_virtualenvc szeZdZdZdfdd Zededeee fddZ dede fd d Z  dded ee d ee de fd dZZS)SessionCommandMixinzE A class mixin for command classes needing _build_session(). returnNcstd|_dSN)super__init___session)self __class__P/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/cli/req_command.pyr&6s  zSessionCommandMixin.__init__optionscCsLg}t|ddst|dd}|r||t|dd}|r"|||p%dS)z7Return a list of index urls from user-provided options.no_indexFZ index_urlNZextra_index_urls)getattrappendextend)clsr- index_urlsurlZurlsr+r+r,_get_index_urls:s     z#SessionCommandMixin._get_index_urlscCs0|jdur||||_|jdusJ|jS)zGet a default-managed session.N)r' enter_context_build_session)r(r-r+r+r,get_default_sessionHs z'SessionCommandMixin.get_default_sessionretriestimeoutcCs|jr tj|js Jt|jrtj|jdnd|dur|n|j|j||d}|j r1|j |_ |j r8|j |_ |j s=|rG|durC|n|j |_ |j rR|j |j d|_|j |j_|S)Nhttp)cacher9 trusted_hostsr3)r;https)Z cache_dirospathisabsrjoinr9r=r5ZcertZverifyZ client_certr:proxyZproxiesZno_inputZauthZ prompting)r(r-r9r:sessionr+r+r,r7Rs&   z"SessionCommandMixin._build_sessionr#NNN)__name__ __module__ __qualname____doc__r& classmethodrrrstrr5rr8intr7 __classcell__r+r+r)r,r"0s"  r"c@s"eZdZdZdeddfddZdS)IndexGroupCommandz Abstract base class for commands with the index_group options. This also corresponds to the commands that permit the pip version check. r-r#NcCsjt|dsJ|js |jrdS|j|dtd|jd}|t||WddS1s.wYdS)z Do the pip version check if not disabled. This overrides the default behavior of not doing the check. r.Nr)r9r:)hasattrZdisable_pip_version_checkr.r7minr:r)r(r-rDr+r+r,handle_pip_version_checks  "z*IndexGroupCommand.handle_pip_version_check)rGrHrIrJrrSr+r+r+r,rO{srOr#cCsNtrdSttds dStjdkstjdkrdStdkr dStddS)zOutput a warning for sudo users on Unix. In a virtual environment, sudo pip still writes to virtualenv. On Windows, users may run pip as Administrator without issues. This warning only applies to Unix root users outside of virtualenv. NgetuidZwin32cygwinrzRunning pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv)r!rQr?sysplatformrTloggerwarningr+r+r+r,warn_if_run_as_roots  rZfuncc s>dtddfdddtdtdttdttffd d }|S) zNDecorator for common logic related to managing temporary directories. registryr#NcSstD]}||dqdS)NF)KEEPABLE_TEMPDIR_TYPESZ set_delete)r\tr+r+r,configure_tempdir_registrysz0with_cleanup..configure_tempdir_registryr(r-argscsH|jdusJ|jr|jz|||WSty#|jwr$)Ztempdir_registryno_cleanr )r(r-r`r_r[r+r,wrappers   zwith_cleanup..wrapper)rRequirementCommandrrrrrM)r[rcr+rbr, with_cleanupsrecsBeZdZdededdffdd Zededefdd Ze d'd e ded e d e d e dedeedefddZe        d(ded e dedeededededededeedeeedfdefddZdeeded e d e deef d d!Zed e ddfd"d#Z  d)ded e d$eedeede f d%d&ZZS)*rdr`kwr#Ncs&tj|i||jtdSr$)r%r&Zcmd_optsZ add_optionr ra)r(r`rfr)r+r,r&szRequirementCommand.__init__r-cCsd|jvrdSdS)zEDetermines which resolver should be used, based on the given options.zlegacy-resolverlegacy 2020-resolver)deprecated_features_enabledr-r+r+r,determine_resolver_variants z-RequirementCommand.determine_resolver_varianttemp_build_dir req_trackerrDfinder use_user_site download_dirc Cs|j}|dus J||} | dkrd|jv} | rtdn d} d|jvr+tdd|jv} d|jvrsz6RequirementCommand.get_requirements..namezXYou must give at least one requirement to {name} (maybe you meant "pip {name} {links}"?) )ZlinkszHYou must give at least one requirement to {name} (see "pip help {name}")r+)Z constraintsrrrr0rrZ editablesr requirementsanyrurZ find_linksr formatdictrB) r(r`r-rnrDrfilenameZ parsed_reqZ req_to_addrZoptsr+r+r,get_requirementsas           z#RequirementCommand.get_requirementscCs$|j}|}|rt|dSdS)zE Trace basic information about the provided objects. N) search_scopeZget_formatted_locationsrXinfo)rnrZ locationsr+r+r,trace_basic_infos z#RequirementCommand.trace_basic_info target_pythoncCs6tj||d}td|j|j|j|d}tj|||dS)z Create a package finder appropriate to this requirement command. :param ignore_requires_python: Whether to ignore incompatible "Requires-Python" values in links. Defaults to False. rjT)Z allow_yankedformat_controlZallow_all_prereleases prefer_binaryr~)link_collectorselection_prefsr)rZcreaterrZprerr)r(r-rDrr~rrr+r+r,_build_package_finders z(RequirementCommand._build_package_finderr$)NFTFFrzNNrF)rGrHrIrr& staticmethodrrLrkrKrrrrboolrrryrrrMrrrrrrrrrNr+r+r)r,rds  ?     : OrdrE)GrJZloggingr?rV functoolsrZoptparsertypingrrrrZpip._internal.cacherZpip._internal.clir Zpip._internal.cli.base_commandr Z!pip._internal.cli.command_contextr Zpip._internal.exceptionsr r Zpip._internal.index.collectorrZ"pip._internal.index.package_finderrZ$pip._internal.models.selection_prefsrZ"pip._internal.models.target_pythonrZpip._internal.network.sessionrZ pip._internal.operations.preparerZpip._internal.req.constructorsrrrrZpip._internal.req.req_filerZpip._internal.req.req_installrZpip._internal.req.req_trackerrZpip._internal.resolution.baserZ!pip._internal.self_outdated_checkrZpip._internal.utils.deprecationrZpip._internal.utils.temp_dirrrr Zpip._internal.utils.virtualenvr!Z getLoggerrGrXr"rOZ BUILD_ENVZEPHEM_WHEEL_CACHEZ REQ_BUILDr]rZrerdr+r+r+r,sJ                    K