a  ze@@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/m0Z0ddl1m2Z2ddl3m4Z4m5Z5m6Z6ddl7m8Z8e9e:Z;GdddeZe6j?e6j@gZAddddZBe e d d!d"ZCGd#d$d$e=ZDdS)%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) 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___/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/cli/req_command.pyr&5s 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_urls9s     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_sessionGs 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_hostsr6)r?https) cache_dirospathisabsrjoinr=rAr9certverify client_certr>proxyproxiesno_inputauth prompting)r(r.r=r>sessionr+r+r,r;Qs&   z"SessionCommandMixin._build_session)NN)__name__ __module__ __qualname____doc__r& classmethodrrrstrr9rr<intr; __classcell__r+r+r)r,r!/s  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. r/Nr)r=r>)hasattrdisable_pip_version_checkr/r;minr>r)r(r.rPr+r+r,handle_pip_version_checks z*IndexGroupCommand.handle_pip_version_check)rQrRrSrTrr^r+r+r+r,rYzsrYr"cCsbtr dSttdsdStjdks,tjdkr0dStjdksDtjdkrTtdkrTdStddS) 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. Ngetuidwin32cygwindarwinlinuxrzRunning 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[rDsysplatformr_loggerwarningr+r+r+r,warn_if_run_as_roots  rh)funcr#cs6tddddttttttdfdd }|S)zNDecorator for common logic related to managing temporary directories. N)registryr#cSstD]}||dqdS)NF)KEEPABLE_TEMPDIR_TYPES set_delete)rjtr+r+r,configure_tempdir_registrysz0with_cleanup..configure_tempdir_registry)r(r.argsr#csP|jdusJ|jr|jz|||WStyJ|jYn0dSr$)tempdir_registryno_cleanr )r(r.rornrir+r,wrappers   zwith_cleanup..wrapper)rRequirementCommandrrrrrW)rirsr+rrr, with_cleanups  rucseZdZeeddfdd ZeeedddZe de ee e e eeeedd d Ze dee eeeeeeeeeeeeedfed ddZeeee e eedddZee ddddZdee eeeee dddZZS)rtN)rokwr#cs&tj|i||jtdSr$)r%r&cmd_opts add_optionr rq)r(rorvr)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_trackerrPfinder use_user_site download_dirr#c Cs|j}|dusJ||} | dkr>d|jv} | rVtdnd} d|jvrVtdt||j||j|||j||j || d|jvd S) zQ Create a RequirementPreparer instance for the given parameters. Nrzz 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.z in-tree-build) build_dirsrc_dirrbuild_isolationrrP progress_barrrequire_hashesr lazy_wheel in_tree_build) rEr}features_enabledrfrgrrrrr) r5r~r.rrPrrrtemp_build_dir_pathresolver_variantrr+r+r,make_requirement_preparers8    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. )isolatedrrzrN) rrrmake_install_reqrignore_dependenciesrrrrr) rr isolated_moder},pip._internal.resolution.resolvelib.resolver _internal resolution resolvelibresolverResolverr(pip._internal.resolution.legacy.resolverry)r5rrr.rrrrrrrrrrpipr+r+r, make_resolversF    z RequirementCommand.make_resolver)ror.rrPr#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}")) constraintsrrrr3rr editablesr requirementsanyrr find_linksr formatdictrG) r(ror.rrPrfilename parsed_req req_to_addroptsr+r+r,get_requirementsQsv         z#RequirementCommand.get_requirements)rr#cCs |j}|}|rt|dS)zE Trace basic information about the provided objects. N) search_scopeget_formatted_locationsrfinfo)rr locationsr+r+r,trace_basic_infosz#RequirementCommand.trace_basic_info)r.rP 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.rPrrrrr+r+r,_build_package_finders z(RequirementCommand._build_package_finder)N)NFTFFrNN)NN)rQrRrSrr& staticmethodrrVr}rUrrrrboolrrrrrrWrrrrrrrrrXr+r+r)r,rtsn 1< Ort)ErTloggingrDrd 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.temp_dirrrrpip._internal.utils.virtualenvr getLoggerrQrfr!rY BUILD_ENVEPHEM_WHEEL_CACHE REQ_BUILDrkrhrurtr+r+r+r,sF                   K