o 7]hH@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__?/usr/lib/python3/dist-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_indexF index_urlNextra_index_urls)getattrappendextend)clsr- index_urlsurlurlsr+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)cacher< trusted_hostsr5)r>https) cache_dirospathisabsrjoinr<r@r8certverify client_certr=proxyproxiesno_inputauth prompting)r(r-r<r=sessionr+r+r,r:Rs&   z"SessionCommandMixin._build_sessionr#NNN)__name__ __module__ __qualname____doc__r& classmethodrrrstrr8rr;intr: __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)r<r=)hasattrdisable_pip_version_checkr.r:minr=r)r(r-rOr+r+r,handle_pip_version_checks  "z*IndexGroupCommand.handle_pip_version_check)rRrSrTrUrr_r+r+r+r,rZ{srZr#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. Ngetuidwin32cygwinrzRunning 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!r\rCsysplatformr`loggerwarningr+r+r+r,warn_if_run_as_roots  rgfuncc s>dtddfdddtdtdttdttffd d }|S) zNDecorator for common logic related to managing temporary directories. registryr#NcSstD]}||dqdS)NF)KEEPABLE_TEMPDIR_TYPES set_delete)ritr+r+r,configure_tempdir_registrysz0with_cleanup..configure_tempdir_registryr(r-argscsH|jdusJ|jr|jz|||WSty#|jwr$)tempdir_registryno_cleanr )r(r-rnrmrhr+r,wrappers   zwith_cleanup..wrapper)rRequirementCommandrrrrrX)rhrrr+rqr, with_cleanupsrtcs^eZdZdededdffdd Zededefdd Zedede fd d Z e  d+d e dede dedede deededefddZe        d,dedededeede de de de dedee d eeed!fdefd"d#Zdeededededeef d$d%Zededdfd&d'Z  d-deded(eedee def d)d*ZZS).rsrnkwr#Ncs&tj|i||jtdSr$)r%r&cmd_opts add_optionr rp)r(rnrur)r+r,r&szRequirementCommand.__init__r-cCsd|jvrdSdS)zEDetermines which resolver should be used, based on the given options.legacy-resolverlegacy 2020-resolver)deprecated_features_enabledr-r+r+r,determine_resolver_variants z-RequirementCommand.determine_resolver_variantcCs6d|jvrdSd|jvrtdtdddddd d S) zJDetermines whether build failures should be suppressed and backtracked on.zbacktrack-on-build-failuresFrxz&Cannot backtrack with legacy resolver.zBacktracking on build failures can mask issues related to how a package generates metadata or builds a wheel. This flag will be removed in pip 22.2.Nzavoiding known-bad versions by explicitly telling pip to ignore them (either directly as requirements, or via a constraints file)i))reasongone_in replacement feature_flagissueT)r{r rr|r+r+r,#determine_build_failure_suppressions  z6RequirementCommand.determine_build_failure_suppressionrtemp_build_dir req_trackerrOfinder use_user_site download_dir verbosityc Cs|j} | dus J||} | dkrd|jv} | rtdn d} d|jvr+tdd|jv} d|jvronoffz)Custom progress bar styles are deprecatedz&to use the default progress bar style.) build_dirsrc_dirrbuild_isolationrrO progress_barrrequire_hashesr lazy_wheelr in_tree_build) rDr}features_enabledrerfr{rrrrrr) r4rr-rrOrrrrtemp_build_dir_pathresolver_variantrrr+r+r,make_requirement_preparersb        z,RequirementCommand.make_requirement_preparerFTto-satisfy-onlypreparer wheel_cacheignore_installedignore_requires_pythonforce_reinstallupgrade_strategy use_pep517py_version_info.c Cstt|j| d} ||} ||}|dkr0ddl}|jjjj j |||| ||j |||| | | d Sddl }|jjj j j |||| ||j |||| | d S)zF Create a Resolver instance for the given parameters. )isolatedrrzrN) rrrmake_install_reqrignore_dependenciesrrrrrsuppress_build_failures) rrrrrrrrrrr)rr isolated_moderr},pip._internal.resolution.resolvelib.resolver _internal resolution resolvelibresolverResolverr(pip._internal.resolution.legacy.resolverry)r4rrr-rrrrrrrrrrrpipr+r+r, make_resolverHsJ    z RequirementCommand.make_resolverc CsJg}|jD]}t|d|||dD]}t||jdd}||qq|D]} t| d|j|jdd}||q#|jD]} t| d|j|jd}||q9|j D]}t||||dD]}t||j|jdd}||qXqNt d d |Drwd|_ |s|js|j sd |j i} |j rtd jdit| d |j dtdjdi| |S)zS Parse command-line arguments into the corresponding requirements. T) constraintrr-rOF)r user_suppliedN)rrr)rrr)rr-rOcss|]}|jVqdSr$)has_hash_options).0reqr+r+r, sz6RequirementCommand.get_requirements..namezXYou must give at least one requirement to {name} (maybe you meant "pip {name} {links}"?) )linkszHYou must give at least one requirement to {name} (see "pip help {name}")r+) constraintsrrrr2rr editablesr requirementsanyrr find_linksr formatdictrF) r(rnr-rrOrfilename parsed_req req_to_addroptsr+r+r,get_requirementss           z#RequirementCommand.get_requirementscCs$|j}|}|rt|dSdS)zE Trace basic information about the provided objects. N) search_scopeget_formatted_locationsreinfo)rr locationsr+r+r,trace_basic_infos z#RequirementCommand.trace_basic_info target_pythoncCs>tj||d}td|j|j|j|d}tj|||d|jvdS)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. r|T) allow_yankedformat_controlallow_all_prereleases prefer_binaryrhtml5lib)link_collectorselection_prefsruse_deprecated_html5lib)rcreaterrprerrr{)r(r-rOrrrrr+r+r,_build_package_finders z(RequirementCommand._build_package_finder)Nr)NFTFFrNNrQ)rRrSrTrr& staticmethodrrWr}boolrrVrrrrrrXrrrrrrrrrrrrrYr+r+r)r,rss   H     < OrsrP)GrUloggingrCrc functoolsroptparsertypingrrrrpip._internal.cacherpip._internal.clir pip._internal.cli.base_commandr !pip._internal.cli.command_contextr pip._internal.exceptionsr r pip._internal.index.collectorr"pip._internal.index.package_finderr$pip._internal.models.selection_prefsr"pip._internal.models.target_pythonrpip._internal.network.sessionr pip._internal.operations.preparerpip._internal.req.constructorsrrrrpip._internal.req.req_filerpip._internal.req.req_installrpip._internal.req.req_trackerrpip._internal.resolution.baser!pip._internal.self_outdated_checkrpip._internal.utils.deprecationrpip._internal.utils.temp_dirrrr pip._internal.utils.virtualenvr! getLoggerrRrer"rZ BUILD_ENVEPHEM_WHEEL_CACHE REQ_BUILDrjrgrtrsr+r+r+r,sJ                    K