a ReB@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@e8jAe8jBgZCdddd ZDe e d!d"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_virtualenvcspeZdZdZddfdd Zeeeee dddZ ee dd d Z deee ee e d d d ZZS)SessionCommandMixinzE A class mixin for command classes needing _build_session(). Nreturncstd|_dSN)super__init___session)self __class__/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/cli/req_command.pyr'6s zSessionCommandMixin.__init__optionsr$cCsLg}t|dds*t|dd}|r*||t|dd}|rD|||pJdS)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*||||_|jdus*J|jS)zGet a default-managed session.N)r( enter_context_build_session)r)r/r,r,r-get_default_sessionHs z'SessionCommandMixin.get_default_session)r/retriestimeoutr$cCs|jrtj|jsJt|jr0tj|jdnd|dur>|n|j|j||d}|j rb|j |_ |j rp|j |_ |j sz|r|dur|n|j |_ |j r|j |j d|_|j |j_|S)Nhttp)cacher> trusted_hostsr7)r@https) cache_dirospathisabsrjoinr>rBr:certverify client_certr?proxyproxiesno_inputauth prompting)r)r/r>r?sessionr,r,r-r<Rs&   z"SessionCommandMixin._build_session)NN)__name__ __module__ __qualname____doc__r' classmethodrrrstrr:rr=intr< __classcell__r,r,r*r-r"0s  r"c@s eZdZdZeddddZdS)IndexGroupCommandz Abstract base class for commands with the index_group options. This also corresponds to the commands that permit the pip version check. Nr.cCsht|dsJ|js|jrdS|j|dtd|jd}|t||Wdn1sZ0YdS)z Do the pip version check if not disabled. This overrides the default behavior of not doing the check. r0Nr)r>r?)hasattrdisable_pip_version_checkr0r<minr?r)r)r/rQr,r,r-handle_pip_version_checks z*IndexGroupCommand.handle_pip_version_check)rRrSrTrUrr_r,r,r,r-rZ{srZr#cCsNtr dSttdsdStjdks,tjdkr0dStdkr@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\rEsysplatformr`loggerwarningr,r,r,r-warn_if_run_as_roots  rg)funcr$cs6tddddttttttdfdd }|S)zNDecorator for common logic related to managing temporary directories. N)registryr$cSstD]}||dqdS)NF)KEEPABLE_TEMPDIR_TYPES set_delete)ritr,r,r-configure_tempdir_registrysz0with_cleanup..configure_tempdir_registry)r)r/argsr$csP|jdusJ|jr|jz|||WStyJ|jYn0dSr%)tempdir_registryno_cleanr )r)r/rnrmrhr,r-wrappers   zwith_cleanup..wrapper)rRequirementCommandrrrrrX)rhrrr,rqr- with_cleanups  rtcseZdZeeddfdd ZeeedddZe de ee e e eeeedd d Ze dee eeeeeeeeeeeeedfed ddZeeee e eedddZee ddddZdee eeeee dddZZS)rsN)rnkwr$cs&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.zlegacy-resolverlegacy 2020-resolver)deprecated_features_enabledr/r,r,r-determine_resolver_variants z-RequirementCommand.determine_resolver_variant)temp_build_dirr/ req_trackerrQfinder use_user_site download_dirr$c Cs|j}|dusJ||} | dkr>d|jv} | rVtdnd} d|jvrVtdd|jv} d|jvrxtd d d d d|jvrtd dd d t||j||j |||j ||j || | d S)zQ Create a RequirementPreparer instance for the given parameters. Nryz fast-depszpip is using lazily downloaded wheels using HTTP range requests to obtain dependency information. This experimental feature is enabled through --use-feature=fast-deps and it is not ready for production.Fz;fast-deps has no effect when used with the legacy resolver.zout-of-tree-buildz in-tree-buildz#In-tree builds are now the default.z.to remove the --use-feature=in-tree-build flagz22.1)reason replacementgone_inz"Out-of-tree builds are deprecated.) build_dirsrc_dirrbuild_isolationr~rQ progress_barrrequire_hashesr lazy_wheel in_tree_build) rFr|features_enabledrerfrzrrrrrr) r6r}r/r~rQrrrtemp_build_dir_pathresolver_variantrrr,r,r-make_requirement_preparersR       z,RequirementCommand.make_requirement_preparerFTto-satisfy-only.) preparerrr/ wheel_cacherignore_installedignore_requires_pythonforce_reinstallupgrade_strategy use_pep517py_version_infor$c  Cstt|j| d} ||} | dkrTddl}|jjjjj |||| ||j |||| | d Sddl }|jjj jj |||| ||j |||| | d S)zF Create a Resolver instance for the given parameters. )isolatedrryrN) rrrmake_install_reqrignore_dependenciesrrrrr) rr isolated_moder|,pip._internal.resolution.resolvelib.resolver _internal resolution resolvelibresolverResolverr(pip._internal.resolution.legacy.resolverrx)r6rrr/rrrrrrrrrrpipr,r,r- make_resolver&sF    z RequirementCommand.make_resolver)rnr/rrQr$c CsTg}|jD]6}t|d|||dD]}t||jdd}||q q |D]$} t| d|j|jdd}||qF|jD]"} t| d|j|jd}||qr|j D]8}t||||dD]"}t||j|jdd}||qqt d d |Drd|_ |sP|jsP|j sPd |j i} |j rz6RequirementCommand.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}")) constraintsrrrr4rr editablesr requirementsanyrr find_linksr formatdictrH) r)rnr/rrQrfilename parsed_req req_to_addroptsr,r,r-get_requirementsasv         z#RequirementCommand.get_requirements)rr$cCs |j}|}|rt|dS)zE Trace basic information about the provided objects. N) search_scopeget_formatted_locationsreinfo)rr locationsr,r,r-trace_basic_infosz#RequirementCommand.trace_basic_info)r/rQ target_pythonrr$cCs6tj||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) allow_yankedformat_controlallow_all_prereleases prefer_binaryr)link_collectorselection_prefsr)rcreaterrprerr)r)r/rQrrrrr,r,r-_build_package_finders z(RequirementCommand._build_package_finder)N)NFTFFrNN)NN)rRrSrTrr' staticmethodrrWr|rVrrrrboolrrrrrrXrrrrrrrrrYr,r,r*r-rssn ?< Ors)GrUloggingrErc functoolsroptparsertypingrrrrpip._internal.cacherZpip._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.constructorsrrrrZpip._internal.req.req_filerZpip._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-sH                    K