3 igB@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:ej;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(). N)returncstjd|_dS)N)super__init___session)self) __class__.configure_tempdir_registry)r'r+argsr#c sP|jdk st|jr|jy |||Stk rJ|jYnXdS)N)Ztempdir_registryr9no_cleanr )r'r+rj)rirer)r*wrappers   zwith_cleanup..wrapper)rRequirementCommandrrrrrU)rerlr))rirer* with_cleanups rncseZdZeeddfdd ZeeedddZe de ee e e eeeedd d Ze dee eeeeeeeeeeeeedfed ddZeeee e eedddZee ddddZdee eeeee dddZZS)rmN)rjkwr#cs"tj|||jjtjdS)N)r$r%cmd_opts add_optionr rk)r'rjro)r(r)r*r%szRequirementCommand.__init__)r+r#cCsd|jkrdSdS)zEDetermines which resolver should be used, based on the given options.zlegacy-resolverlegacyz 2020-resolver)deprecated_features_enabled)r+r)r)r*determine_resolver_variants z-RequirementCommand.determine_resolver_variant)temp_build_dirr+ req_trackerrNfinder use_user_site download_dirr#c Cs|j}|dk st|j|} | dkr>d|jk} | rVtjdnd} d|jkrVtjdd|jk} d|jkrxtd d d d d|jkrtd dd d t||j ||j |||j ||j || | d S)zQ Create a RequirementPreparer instance for the given parameters. Nz 2020-resolverz 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 replacementZgone_inz"Out-of-tree builds are deprecated.) build_dirsrc_dirrybuild_isolationrvrN progress_barrwrequire_hashesrx lazy_wheel in_tree_build) rCr9rtZfeatures_enabledrbrcrsrrr}r~rr) r2rur+rvrNrwrxryZtemp_build_dir_pathresolver_variantrrr)r)r*make_requirement_preparersH       z,RequirementCommand.make_requirement_preparerFTto-satisfy-only.) preparerrwr+ wheel_cacherxignore_installedignore_requires_pythonforce_reinstallupgrade_strategy use_pep517py_version_infor#c  Cstt|j| d} |j|} | dkrTddl}|jjjjj |||| ||j |||| | d Sddl }|jjj jj |||| ||j |||| | d S)zF Create a Resolver instance for the given parameters. )isolatedrz 2020-resolverrN) rrwrmake_install_reqrxignore_dependenciesrrrrr) rr isolated_modertZ,pip._internal.resolution.resolvelib.resolverZ _internal resolutionZ resolvelibresolverZResolverrZ(pip._internal.resolution.legacy.resolverrr)r2rrwr+rrxrrrrrrrrpipr)r)r* make_resolver&s@   z RequirementCommand.make_resolver)rjr+rwrNr#c Csfg}xD|jD]:}x4t|d|||dD]}t||jdd}|j|q$Wq Wx,|D]$} t| d|j|jdd}|j|qPWx,|jD]"} t| d|j|jd}|j|qWxF|j D]<}x6t||||dD]"}t||j|jdd}|j|qWqWt d d |Drd|_ |p|jp|j sbd |j i} |j rRtd jft| d j|j dntdjf| |S)zS Parse command-line arguments into the corresponding requirements. T) constraintrwr+rNF)r user_suppliedN)rrr)rrr)rwr+rNcss|] }|jVqdS)N)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}")) constraintsrrrr0rr editablesr requirementsanyrr find_linksr formatdictrE) r'rjr+rwrNrfilenameZ parsed_reqZ req_to_addroptsr)r)r*get_requirementsasb        z#RequirementCommand.get_requirements)rwr#cCs |j}|j}|rtj|dS)zE Trace basic information about the provided objects. N) search_scopeZget_formatted_locationsrbinfo)rwr locationsr)r)r*trace_basic_infosz#RequirementCommand.trace_basic_info)r+rN 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)Z allow_yankedformat_controlallow_all_prereleases prefer_binaryr)link_collectorselection_prefsr)rcreaterrprerr)r'r+rNrrrrr)r)r*_build_package_finders z(RequirementCommand._build_package_finder)N)NFTFFrNN)NN)rOrPrQrr% staticmethodrrTrtrSrrrrboolrrrrrrUrrrrrrrrrVr)r))r(r*rms4 6,/Irm)GrRloggingrBr` functoolsroptparserZtypingrrrrZpip._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! getLoggerrOrbr"rWZ BUILD_ENVZEPHEM_WHEEL_CACHEZ REQ_BUILDrgrdrnrmr)r)r)r*sF                    K