U
    8h/                     @   s^  d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0m1Z1 e2e3Z4e1j5e1j6e1j7gZ8eedddZ9G dd deZ:dS )zContains the RequirementCommand base class.

This class is in a separate module so the commands that do not always
need PackageFinder capability don't unnecessarily import the
PackageFinder machinery and all its vendored dependencies, etc.
    N)partial)Values)AnyListOptionalTuple)
WheelCache)
cmdoptions)IndexGroupCommand)SessionCommandMixin)CommandErrorPreviousBuildDirError)LinkCollector)PackageFinder)SelectionPreferences)TargetPython)
PipSession)BuildTracker)RequirementPreparer)install_req_from_editableinstall_req_from_line#install_req_from_parsed_requirementinstall_req_from_req_string)parse_requirements)InstallRequirement)BaseResolver)TempDirectoryTempDirectoryTypeRegistrytempdir_kinds)funcreturnc                    s6   t dddd tttt tt d fdd}|S )zNDecorator for common logic related to managing temporary
    directories.
    N)registryr    c                 S   s   t D ]}| |d qd S )NF)KEEPABLE_TEMPDIR_TYPESZ
set_delete)r!   t r$   [C:\Users\jeffr\AppData\Local\Temp\pip-install-hfyjq797\pip\pip\_internal\cli\req_command.pyconfigure_tempdir_registry7   s    z0with_cleanup.<locals>.configure_tempdir_registry)selfoptionsargsr    c                    sR   | j d k	st|jr | j  z| ||W S  tk
rL    | j   Y nX d S N)Ztempdir_registryAssertionErrorno_cleanr   )r'   r(   r)   r&   r   r$   r%   wrapper;   s    

zwith_cleanup.<locals>.wrapper)r   RequirementCommandr   r   r   r   int)r   r.   r$   r-   r%   with_cleanup2   s      r1   c                       s   e Zd Zeedd fddZeeedddZe	de
eeeeeee eed		d
dZe	deeeee eeeeeee eeedf  edddZee eeeee dddZeeddddZdeeee ee edddZ  ZS )r/   N)r)   kwr    c                    s"   t  j|| | jt  d S r*   )super__init__cmd_opts
add_optionr	   r,   )r'   r)   r2   	__class__r$   r%   r4   O   s    zRequirementCommand.__init__)r(   r    c                 C   s   d| j krdS dS )zEDetermines which resolver should be used, based on the given options.zlegacy-resolverlegacy
resolvelib)Zdeprecated_features_enabledr(   r$   r$   r%   determine_resolver_variantT   s    
z-RequirementCommand.determine_resolver_variantr   )	temp_build_dirr(   build_trackersessionfinderuse_user_sitedownload_dir	verbosityr    c	                 C   s   |j }	|	dk	std}
| |}|dkrBd|jk}|r^td nd}
d}d|jkr^td t|	|j||j|j	|||j
||j||||
dS )	zQ
        Create a RequirementPreparer instance for the given parameters.
        NFr:   z	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.Tz;fast-deps has no effect when used with the legacy resolver.)	build_dirsrc_dirrB   build_isolationcheck_build_depsr>   r?   progress_barr@   require_hashesrA   
lazy_wheelrC   legacy_resolver)pathr+   r<   Zfeatures_enabledloggerwarningr   rE   rF   rG   rH   rI   )clsr=   r(   r>   r?   r@   rA   rB   rC   Ztemp_build_dir_pathrK   resolver_variantrJ   r$   r$   r%   make_requirement_preparer\   s@    


z,RequirementCommand.make_requirement_preparerFTto-satisfy-only.)preparerr@   r(   wheel_cacherA   ignore_installedignore_requires_pythonforce_reinstallupgrade_strategy
use_pep517py_version_infor    c                 C   s   t t|j|
d}| |}|dkrTddl}|jjjjj	||||||j
||||	|dS ddl}|jjjjj	||||||j
||||	|dS )zF
        Create a Resolver instance for the given parameters.
        )isolatedrY   r:   r   N)rS   r@   rT   make_install_reqrA   ignore_dependenciesrU   rV   rW   rX   rZ   )r   r   isolated_moder<   Z,pip._internal.resolution.resolvelib.resolver	_internal
resolutionr:   resolverResolverr]   Z(pip._internal.resolution.legacy.resolverr9   )rO   rS   r@   r(   rT   rA   rU   rV   rW   rX   rY   rZ   r\   rP   pipr$   r$   r%   make_resolver   sF    
z RequirementCommand.make_resolver)r)   r(   r@   r?   r    c                 C   sv  g }|j D ]6}t|d|||dD ]}t||jdd}|| q q
|D ].}	t|	d|j|jdt|ddd}|| qF|jD ],}	t	|	d|j|jt|ddd}|| q||j
D ]L}t||||d	D ]6}t||j|jd|jr|jdndd
}|| qqtdd |D rd|_|sr|jsr|j
srd| ji}
|jrbtdjf t|
d|jdntdjf |
|S )zS
        Parse command-line arguments into the corresponding requirements.
        T)
constraintr@   r(   r?   F)r[   user_suppliedNconfig_settings)
comes_fromr[   rY   rf   rg   )rf   r[   rY   rg   )r@   r(   r?   )r[   rY   rf   rg   c                 s   s   | ]}|j V  qd S r*   )has_hash_options).0reqr$   r$   r%   	<genexpr>  s     z6RequirementCommand.get_requirements.<locals>.<genexpr>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}"))constraintsr   r   r^   appendr   rY   getattr	editablesr   requirementsr(   getanyrI   rm   
find_linksr   formatdictjoin)r'   r)   r(   r@   r?   rt   filenameZ
parsed_req
req_to_addrk   optsr$   r$   r%   get_requirements   s    






   

z#RequirementCommand.get_requirements)r@   r    c                 C   s    | j }| }|rt| dS )zE
        Trace basic information about the provided objects.
        N)search_scopeget_formatted_locationsrM   info)r@   r   	locationsr$   r$   r%   trace_basic_info$  s    z#RequirementCommand.trace_basic_info)r(   r?   target_pythonrV   r    c                 C   s6   t j||d}td|j|j|j|d}tj|||dS )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_yankedformat_controlallow_all_prereleasesprefer_binaryrV   )link_collectorselection_prefsr   )r   creater   r   prer   r   )r'   r(   r?   r   rV   r   r   r$   r$   r%   _build_package_finder/  s    z(RequirementCommand._build_package_finder)Nr   )NFTFFrR   NN)NN)__name__
__module____qualname__r   r4   staticmethodr   strr<   classmethodr   r   r   r   boolr   r0   r   rQ   r   r   r   rd   r   r   r~   r   r   r   __classcell__r$   r$   r7   r%   r/   N   sr   	  6        <V  r/   );__doc__logging	functoolsr   optparser   typingr   r   r   r   pip._internal.cacher   Zpip._internal.clir	   Zpip._internal.cli.index_commandr
   r   pip._internal.exceptionsr   r   Zpip._internal.index.collectorr   Z"pip._internal.index.package_finderr   $pip._internal.models.selection_prefsr   "pip._internal.models.target_pythonr   Zpip._internal.network.sessionr   Z,pip._internal.operations.build.build_trackerr    pip._internal.operations.preparer   pip._internal.req.constructorsr   r   r   r   Zpip._internal.req.req_filer   Zpip._internal.req.req_installr   Zpip._internal.resolution.baser   pip._internal.utils.temp_dirr   r   r   	getLoggerr   rM   Z	BUILD_ENVZEPHEM_WHEEL_CACHEZ	REQ_BUILDr"   r1   r/   r$   r$   r$   r%   <module>   s8   
