U
    +|jL~  ã                   @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
mZmZ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  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/Z0 d dl1m2Z2 d dl1m3Z4 d dl5m6Z6 d dl7m8Z8m9Z9 d dl:m;Z; d dl<m=Z= d dl>m?Z? d dl@mAZA d dlBmCZC d dlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZL d dlMmNZN d dlOmPZPmQZQ d dlRmSZS d dlTmUZU e  VeW¡ZXd d!„ ZYG d"d#„ d#ƒZZd$d%„ Z[dS )&é    N)ÚAnyÚDictÚIterableÚListÚOptionalÚSequenceÚUnion)Úpkg_resourcesÚsix)ÚMarker)ÚRequirement)ÚSpecifierSet)Úcanonicalize_name)ÚVersion)Úparse)ÚPep517HookCaller)ÚDistribution)ÚBuildEnvironmentÚNoOpBuildEnvironment)ÚInstallationError)Ú
get_scheme)ÚLink)Úgenerate_metadata)Úinstall_editable)ÚLegacyInstallFailure)Úinstall)Úinstall_wheel)Úload_pyproject_tomlÚmake_pyproject_path)ÚUninstallPathSet)Ú
deprecated)Údirect_url_from_link)ÚHashes)Ú
indent_log)Úask_path_existsÚ
backup_dirÚdisplay_pathÚdist_in_site_packagesÚdist_in_usersiteÚget_distributionÚhide_urlÚredact_auth_from_url)Úget_metadata)ÚTempDirectoryÚtempdir_kinds)Úrunning_under_virtualenv)Úvcsc                 C   s†   |   tj¡}tj |¡\}}t ||¡}| d¡rJtj}tj 	|¡d }n.| d¡sXt
‚tj}tj 	|¡d  d¡d }||||d�S )zQReturn a pkg_resources.Distribution for the provided
    metadata directory.
    z	.egg-infor   z
.dist-infoú-)Úproject_nameÚmetadata)ÚrstripÚosÚsepÚpathÚsplitr	   ÚPathMetadataÚendswithr   ÚsplitextÚAssertionErrorÚDistInfoDistribution)Úmetadata_directoryÚdist_dirÚbase_dirÚdist_dir_namer3   Údist_clsÚ	dist_name© rD   úeC:\Users\snmko\Desktop\web_content\django_cbt\venv\Lib\site-packages\pip/_internal/req/req_install.pyÚ	_get_dist<   s    
ýrF   c                   @   s8  e Zd ZdZdDdd„Zdd„ Zd	d
„ Zdd„ Zedd„ ƒZ	edd„ ƒZ
edd„ ƒZdEdd„Zedd„ ƒZdFdd„Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zed$d%„ ƒZed&d'„ ƒZed(d)„ ƒZed*d+„ ƒZd,d-„ Zd.d/„ Zd0d1„ Zed2d3„ ƒZd4d5„ Zd6d7„ ZdGd8d9„Zd:d;„ ZdHd<d=„Z d>d?„ Z!d@dA„ Z"dIdBdC„Z#dS )JÚInstallRequirementzÆ
    Represents something that may be installed later on, may have information
    about where to fetch the relevant requirement and also contains logic for
    installing the said requirement.
    FNrD   c                 C   s„  |d kst |tƒst|ƒ‚|| _|| _|| _|| _d | _d | _| jrj|sLt‚|j	rjt
j t
j |j¡¡| _|d kr†|r†|jr†t|jƒ}| | _| _d| _d | _| jr¶| jj	r¶| jj| _|rÂ|| _n |rÚdd„ |jD ƒ| _ntƒ | _|d krô|rô|j}|| _d | _d| _d | _d | _|�r|ng | _|	�r,|	ng | _|
�r<|
ni | _d| _ || _!|| _"t#ƒ | _$d | _%d | _&g | _'d | _(|| _)d| _*d S )NFc                 S   s   h | ]}t  |¡’qS rD   )r	   Ú
safe_extra©Ú.0ÚextrarD   rD   rE   Ú	<setcomp>‘   s    z.InstallRequirement.__init__.<locals>.<setcomp>)+Ú
isinstancer   r<   ÚreqÚ
comes_fromÚ
constraintÚeditableÚlegacy_install_reasonÚ
source_dirÚis_filer5   r7   ÚnormpathÚabspathÚ	file_pathÚurlr   ÚlinkÚoriginal_linkÚoriginal_link_is_in_wheel_cacheÚlocal_file_pathÚextrasÚsetÚmarkerÚmarkersÚsatisfied_byÚshould_reinstallÚ_temp_build_dirÚinstall_succeededÚinstall_optionsÚglobal_optionsÚhash_optionsÚpreparedÚuser_suppliedÚisolatedr   Ú	build_envr>   Úpyproject_requiresÚrequirements_to_checkÚpep517_backendÚ
use_pep517Úneeds_more_preparation)ÚselfrN   rO   rQ   rY   r`   ro   rj   re   rf   rg   rP   r]   ri   rD   rD   rE   Ú__init__^   s^    ÿ

ÿ
zInstallRequirement.__init__c                 C   s¢   | j r.t| j ƒ}| jrF|d t| jjƒ¡7 }n| jrBt| jjƒ}nd}| jd k	rf|d t| jjƒ¡7 }| j	ržt
| j	tƒr€| j	}n
| j	 ¡ }|rž|d|› d�7 }|S )Nz from {}z<InstallRequirement>z in {}z (from ú))rN   ÚstrrY   Úformatr+   rX   ra   r&   ÚlocationrO   rM   Ú	from_path©rq   ÚsrO   rD   rD   rE   Ú__str__Ë   s     


zInstallRequirement.__str__c                 C   s   d  | jjt| ƒ| j¡S )Nz<{} object: {} editable={!r}>)ru   Ú	__class__Ú__name__rt   rQ   ©rq   rD   rD   rE   Ú__repr__à   s
      ÿzInstallRequirement.__repr__c                    s>   t | ƒ‰ tˆ ƒ}‡ fdd„t|ƒD ƒ}dj| jjd |¡d�S )z>An un-tested helper for getting state, for debugging.
        c                 3   s   | ]}d   |ˆ | ¡V  qdS )z{}={!r}N)ru   )rJ   Úattr©Ú
attributesrD   rE   Ú	<genexpr>ì   s    z2InstallRequirement.format_debug.<locals>.<genexpr>z<{name} object: {{{state}}}>z, )ÚnameÚstate)ÚvarsÚsortedru   r{   r|   Újoin)rq   Únamesr„   rD   r€   rE   Úformat_debugå   s    
ÿþzInstallRequirement.format_debugc                 C   s   | j d krd S t | j j¡S ©N)rN   r	   Ú	safe_namerƒ   r}   rD   rD   rE   rƒ   õ   s    
zInstallRequirement.namec                 C   s   | j jS rŠ   )rN   Ú	specifierr}   rD   rD   rE   rŒ   ü   s    zInstallRequirement.specifierc                 C   s$   | j }t|ƒdko"tt|ƒƒjdkS )z„Return whether I am pinned to an exact version.

        For example, some-package==1.2 is pinned; some-package>1.2 is not.
        é   >   ú===ú==)rŒ   ÚlenÚnextÚiterÚoperator)rq   Ú
specifiersrD   rD   rE   Ú	is_pinned  s    ÿzInstallRequirement.is_pinnedc                    s0   |sd}ˆ j d k	r(t‡ fdd„|D ƒƒS dS d S )N)Ú c                 3   s   | ]}ˆ j  d |i¡V  qdS )rK   N)r`   ÚevaluaterI   r}   rD   rE   r‚     s   ÿz3InstallRequirement.match_markers.<locals>.<genexpr>T)r`   Úany)rq   Úextras_requestedrD   r}   rE   Úmatch_markers  s    
þz InstallRequirement.match_markersc                 C   s
   t | jƒS )z©Return whether any known-good hashes are specified as options.

        These activate --require-hashes mode; hashes specified as part of a
        URL do not.

        )Úboolrg   r}   rD   rD   rE   Úhas_hash_options  s    	z#InstallRequirement.has_hash_optionsTc                 C   sB   | j  ¡ }|r| jn| j}|r:|jr:| |jg ¡ |j¡ t|ƒS )a§  Return a hash-comparer that considers my option- and URL-based
        hashes to be known-good.

        Hashes in URLs--ones embedded in the requirements file, not ones
        downloaded from an index server--are almost peers with ones from
        flags. They satisfy --require-hashes (whether it was implicitly or
        explicitly activated) but do not activate it. md5 and sha224 are not
        allowed in flags, which should nudge people toward good algos. We
        always OR all hashes together, even ones from URLs.

        :param trust_internet: Whether to trust URL-based (#md5=...) hashes
            downloaded from the internet, as by populate_link()

        )	rg   ÚcopyrY   rZ   ÚhashÚ
setdefaultÚ	hash_nameÚappendr"   )rq   Útrust_internetÚgood_hashesrY   rD   rD   rE   Úhashes$  s
    

zInstallRequirement.hashesc                 C   sP   | j dkrdS t| j ƒ}| jrLt| jtƒr2| j}n
| j ¡ }|rL|d| 7 }|S )z@Format a nice indicator to show where this "comes from"
        Nz->)rN   rt   rO   rM   rw   rx   rD   rD   rE   rw   :  s    


zInstallRequirement.from_pathc                 C   s¾   |d k	st ‚| jd k	r*| jjs"t ‚| jjS | jd krLttjdd�| _| jjS t| jƒ}|rn|› dt	 
¡ j› �}tj |¡s�t d|¡ t |¡ tj ||¡}|r¦d nd}t||tjdd�jS )NT)ÚkindÚglobally_managedÚ_zCreating directory %sF)r7   Údeleter¥   r¦   )r<   rc   r7   rN   r-   r.   Ú	REQ_BUILDr   rƒ   ÚuuidÚuuid4Úhexr5   ÚexistsÚloggerÚdebugÚmakedirsr‡   )rq   Ú	build_dirÚ
autodeleteÚparallel_buildsÚdir_nameÚactual_build_dirÚ
delete_argrD   rD   rE   Úensure_build_locationJ  s0    

 ÿ

üz(InstallRequirement.ensure_build_locationc                 C   sn   | j dkst‚| jdk	st‚| jdk	s*t‚tt| jd ƒtƒrDd}nd}td | jd || jd g¡ƒ| _ dS )z3Set requirement after generating metadata.
        Nr   r�   rŽ   r–   ÚName)	rN   r<   r3   rS   rM   Úparse_versionr   r   r‡   )rq   ÚoprD   rD   rE   Ú_set_requirementt  s    ýÿz#InstallRequirement._set_requirementc                 C   sD   t | jd ƒ}t | jjƒ|kr"d S t d| j|| j¡ t|ƒ| _d S )Nr¸   zeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.)r   r3   rN   rƒ   r®   Úwarningr   )rq   Úmetadata_namerD   rD   rE   Úwarn_on_mismatching_nameŠ  s      üz+InstallRequirement.warn_on_mismatching_namec                 C   sª   | j dkrdS t| j jƒ}|s"dS |j}|dk	o@| j jj|dd�}|sŒd| _|r„t|ƒr`d| _qŠt	ƒ rŠt
|ƒrŠtd |j|j¡ƒ‚q¦d| _n| jr d| _d| _n|| _dS )z¬Find an installed distribution that satisfies or conflicts
        with this requirement, and set self.satisfied_by or
        self.should_reinstall appropriately.
        NT)ÚprereleaseszVWill not install to the user site because it will lack sys.path precedence to {} in {})rN   r)   rƒ   ÚversionrŒ   Úcontainsra   r(   rb   r/   r'   r   ru   r2   rv   rQ   )rq   Úuse_user_siteÚexisting_distÚexisting_versionÚversion_compatiblerD   rD   rE   Úcheck_if_existsš  s8    
þÿ þÿz"InstallRequirement.check_if_existsc                 C   s   | j s
dS | j jS )NF)rY   Úis_wheelr}   rD   rD   rE   rÇ   Ç  s    zInstallRequirement.is_wheelc                 C   s   t j | j| jr| jjpd¡S )Nr–   )r5   r7   r‡   rS   rY   Úsubdirectory_fragmentr}   rD   rD   rE   Úunpacked_source_directoryÏ  s    þz,InstallRequirement.unpacked_source_directoryc                 C   s(   | j std| › �ƒ‚tj | jd¡}|S )NúNo source dir for zsetup.py)rS   r<   r5   r7   r‡   rÉ   )rq   Úsetup_pyrD   rD   rE   Úsetup_py_pathÖ  s    z InstallRequirement.setup_py_pathc                 C   s   | j std| › �ƒ‚t| jƒS )NrÊ   )rS   r<   r   rÉ   r}   rD   rD   rE   Úpyproject_toml_pathÞ  s    z&InstallRequirement.pyproject_toml_pathc                 C   s^   t | j| j| jt| ƒƒ}|dkr*d| _dS d| _|\}}}}|| _|| _t| j||d�| _	dS )aA  Load the pyproject.toml file.

        After calling this routine, all of the attributes related to PEP 517
        processing for this requirement have been set. In particular, the
        use_pep517 attribute can be used to determine whether we should
        follow the PEP 517 or legacy (setup.py) code path.
        NFT)Úbackend_path)
r   ro   rÍ   rÌ   rt   rm   rl   r   rÉ   rn   )rq   Úpyproject_toml_dataÚrequiresÚbackendÚcheckrÎ   rD   rD   rE   r   ä  s$    	ü  ÿz&InstallRequirement.load_pyproject_tomlc                 C   sV   | j s8| jst‚t| j| j| j| j| jp2d| j› �d�S | j	dk	sFt‚t
| j| j	d�S )zKInvokes metadata generator functions, with the required arguments.
        zfrom )rk   rÌ   rS   rj   ÚdetailsN)rk   rÑ   )ro   rÉ   r<   Úgenerate_metadata_legacyrk   rÌ   rj   rƒ   rY   rn   r   r}   rD   rD   rE   Ú_generate_metadata   s    
ûþz%InstallRequirement._generate_metadatac              	   C   sJ   | j s
t‚tƒ � |  ¡ | _W 5 Q R X | js6|  ¡  n|  ¡  |  ¡  dS )z³Ensure that project metadata is available.

        Under PEP 517, call the backend hook to prepare the metadata.
        Under legacy processing, call setup.py egg-info.
        N)	rS   r<   r#   rÕ   r>   rƒ   r»   r¾   Úassert_source_matches_versionr}   rD   rD   rE   Úprepare_metadata  s    

z#InstallRequirement.prepare_metadatac                 C   s   t | dƒst|  ¡ ƒ| _| jS )NÚ	_metadata)Úhasattrr,   Úget_distrØ   r}   rD   rD   rE   r3   *  s    
zInstallRequirement.metadatac                 C   s
   t | jƒS rŠ   )rF   r>   r}   rD   rD   rE   rÚ   2  s    zInstallRequirement.get_distc                 C   sR   | j s
t‚| jd }| jjr8|| jjkr8t d| |¡ nt dt| j ƒ|| ¡ d S )NrÀ   z'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s)	rS   r<   r3   rN   rŒ   r®   r¼   r¯   r&   )rq   rÀ   rD   rD   rE   rÖ   6  s    

ýüz0InstallRequirement.assert_source_matches_versionc                 C   s    | j dkr| j|||d�| _ dS )aA  Ensure that a source_dir is set.

        This will create a temporary build dir if the name of the requirement
        isn't known yet.

        :param parent_dir: The ideal pip parent_dir for the source_dir.
            Generally src_dir for editables and build_dir for sdists.
        :return: self.source_dir
        N)r²   r³   )rS   r·   )rq   Ú
parent_dirr²   r³   rD   rD   rE   Úensure_has_source_dirI  s    
ýz(InstallRequirement.ensure_has_source_dirc                 C   s€   | j st d| j¡ d S | js"t‚| js,t‚| j jdkr<d S t | j j¡}|s`td| j j	› �ƒ‚t
| j j	ƒ}|j| j|d� d S )Nz>Cannot update repository at %s; repository location is unknownÚfilezUnsupported VCS URL )rX   )rY   r®   r¯   rS   rQ   r<   Úschemer0   Úget_backend_for_schemerX   r*   Úobtain)rq   Úvcs_backendÚ
hidden_urlrD   rD   rE   Úupdate_editablea  s    ý

z"InstallRequirement.update_editablec                 C   sR   | j s
t‚t| j jƒ}|s,t d| j¡ dS t d|¡ t |¡}| 	||¡ |S )a¥  
        Uninstall the distribution currently satisfying this requirement.

        Prompts before removing or modifying files unless
        ``auto_confirm`` is True.

        Refuses to delete or modify files outside of ``sys.prefix`` -
        thus uninstallation within a virtual environment can only
        modify that virtual environment, even if the virtualenv is
        linked to global site-packages.

        z#Skipping %s as it is not installed.NzFound existing installation: %s)
rN   r<   r)   rƒ   r®   r¼   Úinfor   Ú	from_distÚremove)rq   Úauto_confirmÚverboseÚdistÚuninstalled_pathsetrD   rD   rE   Ú	uninstallw  s    

zInstallRequirement.uninstallc                 C   s.   dd„ }t j ||¡}|||ƒ}| jd | S )Nc                 S   sN   |   |tjj ¡s&td| ›d|›�ƒ‚| t|ƒd d … } |  tjjd¡} | S )Nzname z doesn't start with prefix r�   ú/)Ú
startswithr5   r7   r6   r<   r�   Úreplace)rƒ   ÚprefixrD   rD   rE   Ú_clean_zip_name“  s    ÿz=InstallRequirement._get_archive_name.<locals>._clean_zip_namerì   )r5   r7   r‡   rƒ   )rq   r7   Ú	parentdirÚrootdirrð   rƒ   rD   rD   rE   Ú_get_archive_name�  s    	
z$InstallRequirement._get_archive_namec              	   C   s´  | j s
t‚|dkrdS d}d | j| jd ¡}tj ||¡}tj |¡rÔt	d t
|ƒ¡dƒ}|dkrjd}nj|d	krŽt d
t
|ƒ¡ t |¡ nF|dkrÂt|ƒ}t dt
|ƒt
|ƒ¡ t ||¡ n|dkrÔt d¡ |sÜdS tj|d	tjdd�}|�¦ tj tj | j¡¡}t |¡D ]~\}	}
}|
D ]6}| j||	|d�}t |d ¡}d|_| |d¡ �q$|D ]0}| j||	|d�}tj |	|¡}| ||¡ �q`�qW 5 Q R X t dt
|ƒ¡ dS )z}Saves archive to provided build_dir.

        Used for saving downloaded VCS requirements as part of `pip download`.
        NTz	{}-{}.ziprÀ   z8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )ÚiÚwÚbÚarô   Frõ   zDeleting %srö   zBacking up %s to %sr÷   éÿÿÿÿ)Ú
allowZip64)rñ   rò   rì   i  ír–   zSaved %s) rS   r<   ru   rƒ   r3   r5   r7   r‡   r­   r$   r&   r®   r¼   ræ   r%   ÚshutilÚmoveÚsysÚexitÚzipfileÚZipFileÚZIP_DEFLATEDÚnormcaserV   rÉ   Úwalkró   ÚZipInfoÚexternal_attrÚwritestrÚwriterä   )rq   r±   Úcreate_archiveÚarchive_nameÚarchive_pathÚresponseÚ	dest_fileÚ
zip_outputÚdirÚdirpathÚdirnamesÚ	filenamesÚdirnameÚdir_arcnameÚzipdirÚfilenameÚfile_arcnamerD   rD   rE   Úarchive   sv    
þüý
   ÿÿ  ÿ  ÿzInstallRequirement.archivec	                 C   s”  t | j|||| j|d�}	|d k	r$|ng }| jr^t|||||| j| j| j| j| jd�
 d| _d S | j	r¸| j
snt‚d }
| jrŠt| j| j| jƒ}
t| j| j
|	t| jƒ|||
| jd� d| _d S t|ƒ| j }t|ƒ| j }z8t||||||||	| j| j| j| j| jt| jƒd�}W nR tk
�rB } zd| _tj|jŽ  W 5 d }~X Y n tk
�r^   d| _‚ Y nX || _|�r�| jdk�r�td | j¡d	d dd
� d S )N)ÚuserÚhomeÚrootrj   rï   )rï   r  rÂ   rƒ   rÌ   rj   rk   rÉ   T)rÞ   Úreq_descriptionÚ	pycompileÚwarn_script_locationÚ
direct_urlÚ	requested)re   rf   r  r  rï   rÂ   r  rÞ   rÌ   rj   Úreq_namerk   rÉ   r  Fi°   zg{} was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.z+to fix the wheel build issue reported above©ÚreasonÚreplacementÚgone_inÚissue) r   rƒ   rj   rQ   Úinstall_editable_legacyrÌ   rk   rÉ   rd   rÇ   r\   r<   rZ   r!   rS   r[   r   rt   rN   ri   Úlistrf   re   Úinstall_legacyr   r
   ÚreraiseÚparentÚ	ExceptionrR   r    ru   )rq   re   rf   r  r  rï   r  rÂ   r  rÞ   r  ÚsuccessÚexcrD   rD   rE   r   ß  s     ú	ö
ýø
	ò
þøzInstallRequirement.install)FNNNFNNNFrD   F)N)T)FF)FF)NNNNTFT)$r|   Ú
__module__Ú__qualname__Ú__doc__rr   rz   r~   r‰   Úpropertyrƒ   rŒ   r•   rš   rœ   r¤   rw   r·   r»   r¾   rÆ   rÇ   rÉ   rÌ   rÍ   r   rÕ   r×   r3   rÚ   rÖ   rÜ   rã   rë   ró   r  r   rD   rD   rD   rE   rG   W   sz   
           ò
m







*-




  ü

B       ÷rG   c                 C   s>   d}| j sd}n| jrd}n
| jr&d}|r:tddd dd� |S )	Nr–   z3Unnamed requirements are not allowed as constraintsz4Editable requirements are not allowed as constraintszConstraints cannot have extrasa  Constraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms.z,replacing the constraint with a requirement.i   r   )rƒ   rQ   r]   r    )rN   ÚproblemrD   rD   rE   Úcheck_invalid_constraint_typeL  s    ór2  )\Úloggingr5   rú   rü   rª   rþ   Útypingr   r   r   r   r   r   r   Úpip._vendorr	   r
   Zpip._vendor.packaging.markersr   Z"pip._vendor.packaging.requirementsr   Z pip._vendor.packaging.specifiersr   Úpip._vendor.packaging.utilsr   Zpip._vendor.packaging.versionr   r   r¹   Zpip._vendor.pep517.wrappersr   Úpip._vendor.pkg_resourcesr   Úpip._internal.build_envr   r   Úpip._internal.exceptionsr   Úpip._internal.locationsr   Úpip._internal.models.linkr   Ú'pip._internal.operations.build.metadatar   Ú.pip._internal.operations.build.metadata_legacyrÔ   Ú0pip._internal.operations.install.editable_legacyr   r%  Ú'pip._internal.operations.install.legacyr   r   r'  Ú&pip._internal.operations.install.wheelr   Úpip._internal.pyprojectr   r   Úpip._internal.req.req_uninstallr   Úpip._internal.utils.deprecationr    Ú&pip._internal.utils.direct_url_helpersr!   Úpip._internal.utils.hashesr"   Úpip._internal.utils.loggingr#   Úpip._internal.utils.miscr$   r%   r&   r'   r(   r)   r*   r+   Úpip._internal.utils.packagingr,   Úpip._internal.utils.temp_dirr-   r.   Úpip._internal.utils.virtualenvr/   Úpip._internal.vcsr0   Ú	getLoggerr|   r®   rF   rG   r2  rD   rD   rD   rE   Ú<module>   sZ   $(

     z