U .ec,@sXdZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZmZmZdd lmZddlmZmZddlmZddlm Z e r"ddl!m"Z"ddl#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0GdddeZ1Gdddee1Z2Gddde2Z3dS)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)Command)CommandContextMixIn) CommandError) PackageFinder)Resolver)SelectionPreferences) PipSession)RequirementPreparer)install_req_from_editableinstall_req_from_lineinstall_req_from_req_string)parse_requirements)make_link_collectorpip_self_version_check)normalize_path)MYPY_CHECK_RUNNING)Values)ListOptionalTuple) WheelCache) TargetPython)RequirementSet)RequirementTracker) TempDirectorycs>eZdZdZfddZeddZddZd d d ZZ S) SessionCommandMixinzE A class mixin for command classes needing _build_session(). cstt|d|_dS)N)superr__init___session)self __class__A/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.pyr2szSessionCommandMixin.__init__cCsLg}t|dds*t|dd}|r*||t|dd}|rD|||pJdS)z7Return a list of index urls from user-provided options.no_indexFZ index_urlNZextra_index_urls)getattrappendextend)clsoptions index_urlsZurlZurlsr#r#r$_get_index_urls6s     z#SessionCommandMixin._get_index_urlscCs"|jdkr||||_|jS)zGet a default-managed session.N)r enter_context_build_session)r r*r#r#r$get_default_sessionDs z'SessionCommandMixin.get_default_sessionNcCst|jrttj|jdnd|dk r*|n|j|j||d}|j rN|j |_ |j r\|j |_ |j sf|rz|dk rr|n|j |_ |j r|j |j d|_|j |j_|S)Nhttp)cacheretries trusted_hostsr+)r0Zhttps)r cache_dirrospathjoinr2r3r,ZcertZverifyZ client_certtimeoutproxyZproxiesZno_inputZauthZ prompting)r r*r2r8sessionr#r#r$r.Ks*   z"SessionCommandMixin._build_session)NN) __name__ __module__ __qualname____doc__r classmethodr,r/r. __classcell__r#r#r!r$r-s   rc@seZdZdZddZdS)IndexGroupCommandz Abstract base class for commands with the index_group options. This also corresponds to the commands that permit the pip version check. c CsTt|dst|js|jrdS|j|dtd|jd}|t||W5QRXdS)z Do the pip version check if not disabled. This overrides the default behavior of not doing the check. r%Nr)r2r8)hasattrAssertionErrorZdisable_pip_version_checkr%r.minr8r)r r*r:r#r#r$handle_pip_version_checkzs  z*IndexGroupCommand.handle_pip_version_checkN)r;r<r=r>rFr#r#r#r$rArsrAc @s:eZdZed ddZedddZd d Zdd d ZdS)RequirementCommandNc Cs.|j}|dk stt||j|||j|j|dS)zQ Create a RequirementPreparer instance for the given parameters. N)Z build_dirsrc_dir download_dirwheel_download_dir progress_barbuild_isolation req_tracker)r6rDr rHrKrL)Ztemp_build_dirr*rMrIrJZtemp_build_dir_pathr#r#r$make_requirement_preparers  z,RequirementCommand.make_requirement_preparerFTto-satisfy-onlyc Cs2tt|j|| d} t|||| ||j|||| | d S)zF Create a Resolver instance for the given parameters. )isolated wheel_cache use_pep517) preparerr:findermake_install_req use_user_siteignore_dependenciesignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_info)rr isolated_moderrW) rSr:rTr*rQrVrXrYrZr[rRr\rUr#r#r$ make_resolvers&z RequirementCommand.make_resolverc Cs,|jD].}t|d||||dD]}d|_||qq|D]*} t| d|j|j|d}d|_||q:|jD](} t| |j|j|d}d|_||ql|j D]0}t||||||jdD]}d|_||qq|j |_ |s(|js(|j s(d|j i} |j rt dt| d|j d n t d | dS) z? Marshal cmd line args into a requirement set. T)Z constraintrTr*r:rQN)rPrRrQ)rTr*r:rQrRnamez^You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?) )ZlinkszLYou must give at least one requirement to %(name)s (see "pip help %(name)s"))Z constraintsrZ is_directZadd_requirementr r]rRZ editablesr Z requirementsZrequire_hashesr_Z find_linksrdictr7) r Zrequirement_setargsr*rTr:rQfilenameZ req_to_addZreqZoptsr#r#r$populate_requirement_setsn        z+RequirementCommand.populate_requirement_setcCs4t||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. )r*T)Z allow_yankedformat_controlZallow_all_prereleases prefer_binaryrY)link_collectorselection_prefs target_python)rrreZprerfrZcreate)r r*r:rirYrgrhr#r#r$_build_package_finders z(RequirementCommand._build_package_finder)NN)NFTFFrONN)NN)r;r<r= staticmethodrNr^rdrjr#r#r#r$rGs$  &GrG)4r>r5 functoolsrZpip._internal.cli.base_commandrZ!pip._internal.cli.command_contextrZpip._internal.exceptionsrZpip._internal.indexrZpip._internal.legacy_resolverZ$pip._internal.models.selection_prefsrZpip._internal.network.sessionr Z pip._internal.operations.preparer Zpip._internal.req.constructorsr r r Zpip._internal.req.req_filerZ!pip._internal.self_outdated_checkrrZpip._internal.utils.miscrZpip._internal.utils.typingrZoptparsertypingrrrZpip._internal.cacherZ"pip._internal.models.target_pythonrZpip._internal.req.req_setrZpip._internal.req.req_trackerrZpip._internal.utils.temp_dirrrrArGr#r#r#r$s4                   E