<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    .e                     @   sL  d dl mZ 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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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/m0Z0 d dl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= d dl>m?Z? d dl@mAZA d dlBmCZCmDZD d dlEmFZF d dlGmHZH d dlImJZJ d dlKmLZL eHr.d dlMmNZNmOZOmPZPmQZQmRZRmSZSmTZT d dlmUZU d dlVmWZW d d lXmYZY d d!lZm[Z[ d d"l\m]Z] d d#l^m_Z_ e`eaZbG d$d% d%ecZddS )&    )absolute_importN)change_root)pkg_resourcessix)Requirement)canonicalize_name)Version)parse)Pep517HookCaller)
pep425tagswheel)NoOpBuildEnvironment)InstallationError)Link)get_metadata_generator)load_pyproject_tomlmake_pyproject_path)UninstallPathSet)
native_str)Hashes)
indent_log)PIP_DELETE_MARKER_FILENAMEhas_delete_marker_file)_make_build_dirask_path_exists
backup_dirdisplay_pathdist_in_install_pathdist_in_site_packagesdist_in_usersite
ensure_dirget_installed_versionhide_urlredact_auth_from_urlrmtree)get_metadata)make_setuptools_shim_args)call_subprocessrunner_with_spinner_message)TempDirectory)MYPY_CHECK_RUNNING)running_under_virtualenv)vcs)AnyDictIterableListOptionalSequenceUnion)BuildEnvironment)
WheelCache)PackageFinder)Distribution)SpecifierSet)Markerc                
   @   sp  e Zd ZdZdPd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dQddZe	dd ZdRddZdd Zd d! Zd"d# Zd$d% Zd&d' Ze	d(d) ZdSd*d+Ze	d,d- Ze	d.d/ Ze	d0d1 Zd2d3 Zd4d5 Zd6d7 Ze	d8d9 Zd:d; Zd<d= Z d>d? Z!dTd@dAZ"dUdBdCZ#dVdDdEZ$dFdG Z%dHdI Z&dJdK Z'dWdLdMZ(dNdO Z)dS )X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.
    NF c                 C   s  || _ || _|| _|d kr"d | _ntjtj|| _|| _|
| _	|d kr`|r`|j
r`t|j
}| | _| _|rx|| _n |rdd |jD | _nt | _|d kr|r|j}|| _d | _d | _d | _d | _d | _|	r|	ni | _d| _d| _|| _t | _d | _d | _g | _d | _ || _!d S )Nc                 S   s   h | ]}t |qS r;   )r   Z
safe_extra.0extrar;   r;   A/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py	<setcomp>w   s    z.InstallRequirement.__init__.<locals>.<setcomp>F)"req
comes_from
constraint
source_dirospathnormpathabspatheditable_wheel_cacheurlr   linkoriginal_linkextrassetmarkermarkerssatisfied_byconflicts_with_temp_build_dir_ideal_build_dirinstall_succeededoptionsZpreparedZ	is_directisolatedr   	build_envmetadata_directorypyproject_requiresrequirements_to_checkpep517_backend
use_pep517)selfrA   rB   rD   rI   rL   rQ   r^   rX   rW   Zwheel_cacherC   rN   r;   r;   r?   __init__T   sH    

zInstallRequirement.__init__c                 C   s   | j r,t| j }| jrD|dt| jj 7 }n| jr@t| jj}nd}| jd k	rb|dt| jj 7 }| jrt	| jt
jr~| j}n
| j }|r|d| 7 }|S )Nz from %sz<InstallRequirement>z in %sz
 (from %s))rA   strrL   r#   rK   rR   r   locationrB   
isinstancer   string_types	from_pathr_   srB   r;   r;   r?   __str__   s     


zInstallRequirement.__str__c                 C   s   d| j jt| | jf S )Nz<%s object: %s editable=%r>)	__class____name__ra   rI   r_   r;   r;   r?   __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)format)r=   attrZ
attributesr;   r?   	<genexpr>   s    z2InstallRequirement.format_debug.<locals>.<genexpr>z<{name} object: {{{state}}}>z, )namestate)varssortedrm   ri   rj   join)r_   namesrr   r;   ro   r?   format_debug   s    
zInstallRequirement.format_debugc                 C   sh   | j dkr|| || _ | jdk	rd|sd| j }t }| jj| j | j|d| _ || j krdtd| j  dS )a  Ensure that if a link can be found for this, that it is found.

        Note that self.link may still be None - if Upgrade is False and the
        requirement is already installed.

        If require_hashes is True, don't use the wheel cache, because cached
        wheels, always built locally, have different hashes than the files
        downloaded from the index server and thus throw false hash mismatches.
        Furthermore, cached wheels at present have undeterministic contents due
        to file modification times.
        N)rL   Zpackage_namesupported_tagszUsing cached wheel link: %s)	rL   Zfind_requirementrJ   r   Zget_supportedgetrq   loggerdebug)r_   finderZupgradeZrequire_hashesZold_linkrx   r;   r;   r?   populate_link   s    

z InstallRequirement.populate_linkc                 C   s    | j d krd S tt| j jS N)rA   r   r   Z	safe_namerq   rk   r;   r;   r?   rq      s    
zInstallRequirement.namec                 C   s   | j jS r~   )rA   	specifierrk   r;   r;   r?   r      s    zInstallRequirement.specifierc                 C   s$   | j }t|dko"tt|jdkS )zReturn 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)r_   Z
specifiersr;   r;   r?   	is_pinned   s    zInstallRequirement.is_pinnedc                 C   s
   t | jS r~   )r!   rq   rk   r;   r;   r?   installed_version  s    z$InstallRequirement.installed_versionc                    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 )r>   N)rQ   Zevaluater<   rk   r;   r?   rp     s   z3InstallRequirement.match_markers.<locals>.<genexpr>T)rQ   any)r_   Zextras_requestedr;   rk   r?   match_markers  s    
z InstallRequirement.match_markersc                 C   s   t | jdi S )zReturn whether any known-good hashes are specified as options.

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

        hashes)boolrW   ry   rk   r;   r;   r?   has_hash_options  s    	z#InstallRequirement.has_hash_optionsTc                 C   sJ   | j di  }|r| jn| j}|rB|jrB||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()

        r   )
rW   ry   copyrL   rM   hash
setdefaultZ	hash_nameappendr   )r_   Ztrust_internetZgood_hashesrL   r;   r;   r?   r   #  s
    
zInstallRequirement.hashesc                 C   sR   | j dkrdS t| j }| jrNt| jtjr4| j}n
| j }|rN|d| 7 }|S )z@Format a nice indicator to show where this "comes from"
        Nz->)rA   ra   rB   rc   r   rd   re   rf   r;   r;   r?   re   9  s    


zInstallRequirement.from_pathc                 C   s|   | j d k	r| j jS | jd kr6tdd| _ || _| j jS | jrH| j }n| j}tj	|snt
d| t| tj||S )Nz	req-buildkindzCreating directory %s)rT   rF   rA   r)   rU   rI   rq   lowerrE   existsrz   r{   r   ru   )r_   	build_dirrq   r;   r;   r?   ensure_build_locationI  s    

z(InstallRequirement.ensure_build_locationc                 C   s   | j dk	rdS | j}d| _| | j}tj|rBtdt| t	
d| t|jt| t|j| tjtj|| _ t|dd| _| jr| j}tjj||jd}tj||}tjtj|}|| _d| _dS )a  Move self._temp_build_dir to "self._ideal_build_dir/self.req.name"

        For some requirements (e.g. a path to a directory), the name of the
        package is not available until we run egg_info, so the build_location
        will return a temporary directory and store the _ideal_build_dir.

        This is only called to "fix" the build directory after generating
        metadata.
        Nz<A package already exists in %s; please remove it to continuez,Moving package %s from %s to new location %szreq-install)rF   r   )start)rD   rT   r   rU   rE   rF   r   r   r   rz   r{   shutilmoverG   rH   r)   rZ   relpathru   )r_   Zold_locationZnew_locationZold_metaZrelZnew_metar;   r;   r?   move_to_correct_build_directoryf  s<    
   z2InstallRequirement.move_to_correct_build_directoryc                 C   sR   | j r(t| j r(td| j  t| j  d| _ | jrD| j  d| _| j  dS )zVRemove the source files from this requirement, if they are marked
        for deletionzRemoving source in %sN)rD   r   rz   r{   r$   rT   cleanuprY   rk   r;   r;   r?   remove_temporary_source  s    

z*InstallRequirement.remove_temporary_sourcec                 C   s   | j dkrdS zHtt| j }d|_tt|| _| jrT| jrT| j| _d| _W dS W n tj	k
rn   Y dS  tj
k
r   t| j j}|rt|r|| _qt rt|rtd|j|jf nt|r|| _Y nX dS )zFind an installed distribution that satisfies or conflicts
        with this requirement, and set self.satisfied_by or
        self.conflicts_with appropriately.
        NFTzVWill not install to the user site because it will lack sys.path precedence to %s in %s)rA   r   ra   rP   r   Zget_distributionrR   rI   rS   ZDistributionNotFoundZVersionConflictrq   r   r+   r   r   project_namerb   r   )r_   use_user_siteZ	no_markerZexisting_distr;   r;   r?   check_if_exists  s<    


z"InstallRequirement.check_if_existsc                 C   s   | j s
dS | j jS )NF)rL   is_wheelrk   r;   r;   r?   r     s    zInstallRequirement.is_wheelc                 C   s(   t j| j| j||||||| j|d
 d S )N)userhomerootprefix	pycompilerX   warn_script_location)r   move_wheel_filesrq   rA   rX   )r_   Zwheeldirr   r   r   r   r   r   r;   r;   r?   r     s      z#InstallRequirement.move_wheel_filesc                 C   s   t j| j| jr| jjpdS )Nr   )rE   rF   ru   rD   rL   Zsubdirectory_fragmentrk   r;   r;   r?   unpacked_source_directory  s    z,InstallRequirement.unpacked_source_directoryc                 C   s4   t j| jd}tjr0t|tjr0|t	
 }|S )Nzsetup.py)rE   rF   ru   r   r   ZPY2rc   Z	text_typeencodesysgetfilesystemencoding)r_   Zsetup_pyr;   r;   r?   setup_py_path  s    z InstallRequirement.setup_py_pathc                 C   s
   t | jS r~   )r   r   rk   r;   r;   r?   pyproject_toml_path  s    z&InstallRequirement.pyproject_toml_pathc                 C   sX   t | j| j| jt| }|dkr*d| _dS d| _|\}}}|| _|| _t| j|| _	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)
r   r^   r   r   ra   r\   r[   r
   r   r]   )r_   Zpyproject_toml_dataZrequiresbackendZcheckr;   r;   r?   r     s"    	
 z&InstallRequirement.load_pyproject_tomlc              	   C   s   t | }t  || | _W 5 Q R X | jsttt| jd trDd}nd}td	| jd || jd g| _| 
  n<t| jd }t| jj|krtd| j|| j t|| _dS )zEnsure that project metadata is available.

        Under PEP 517, call the backend hook to prepare the metadata.
        Under legacy processing, call setup.py egg-info.
        r   r   r   r   NamezeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.N)r   r   rZ   rA   rc   parse_versionmetadatar   r   ru   r   r   rq   rz   warning)r_   Zmetadata_generatoropZmetadata_namer;   r;   r?   prepare_metadata)  s0    	
  z#InstallRequirement.prepare_metadatac              
   C   sj   t dd}t|j |j}| j4 td}| j}|| |	|}W 5 Q R X W 5 Q R X t
j||S )Nzmodern-metadatar   zPreparing wheel metadata)r)   atexitregisterr   rF   rY   r(   r]   Zsubprocess_runnerZ prepare_metadata_for_build_wheelrE   ru   )r_   Zmetadata_tmpdirZmetadata_dirrunnerr   Zdistinfo_dirr;   r;   r?   prepare_pep517_metadataN  s    
z*InstallRequirement.prepare_pep517_metadatac                 C   s   t | dst|  | _| jS )N	_metadata)hasattrr%   get_distr   rk   r;   r;   r?   r   e  s    
zInstallRequirement.metadatac                 C   s`   | j tj}|dr tj}ntj}tj	|\}}tj
|d }t||}||||dS )z8Return a pkg_resources.Distribution for this requirement	.egg-infor   )r   r   )rZ   rstriprE   sependswithr   r7   ZDistInfoDistributionrF   splitsplitextZPathMetadata)r_   Zdist_dirZdist_clsZbase_dirZdist_dir_nameZ	dist_namer   r;   r;   r?   r   m  s    
zInstallRequirement.get_distc                 C   sH   | j d }| jjr.|| jjkr.td| | ntdt| j||  d S )Nversionz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s)r   rA   r   rz   r   r{   r   rD   )r_   r   r;   r;   r?   assert_source_matches_version  s    
z0InstallRequirement.assert_source_matches_versionc                 C   s   | j dkr| || _ 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)rD   r   )r_   Z
parent_dirr;   r;   r?   ensure_has_source_dir  s    
z(InstallRequirement.ensure_has_source_dirc              
   C   s   t d| j |r*d|g}t|| }t| j|| jd}t 6 | j	$ t
|ddg t| | jd W 5 Q R X W 5 Q R X d| _d S )NzRunning setup.py develop for %sz--prefix={})global_optionsno_user_configZdevelopz	--no-deps)cwdT)rz   inforq   rm   listr&   r   rX   r   rY   r'   r   rV   )r_   install_optionsr   r   Zprefix_paramZbase_cmdr;   r;   r?   install_editable  s(    z#InstallRequirement.install_editablec                 C   s   | j std| j d S | j jdkr(d S | j jdd\}}t|}|r~t	| j j}|rl|j
| j|d q~|j| j|d n d S )Nz>Cannot update repository at %s; repository location is unknownfile+r   )rK   )rL   rz   r{   rD   ZschemerK   r   r,   Zget_backendr"   obtainZexport)r_   r   Zvc_typerK   Zvcs_backendZ
hidden_urlr;   r;   r?   update_editable  s     
z"InstallRequirement.update_editablec                 C   sB   |  |std| j dS | jp&| j}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.N)	r   rz   r   rq   rR   rS   r   Z	from_distremove)r_   Zauto_confirmverboser   ZdistZuninstalled_pathsetr;   r;   r?   	uninstall  s    

zInstallRequirement.uninstallc                 C   s(   |t |d d  }|tjjd}|S )Nr   /)r   replacerE   rF   r   )r_   rq   r   r;   r;   r?   _clean_zip_name  s    z"InstallRequirement._clean_zip_namec                 C   s(   t j||}| ||}| jd | S )Nr   )rE   rF   ru   r   rq   )r_   rF   	parentdirrootdirrq   r;   r;   r?   _get_archive_name   s    z$InstallRequirement._get_archive_namec              	   C   s  d}d| j | jd f }tj||}tj|rtdt| d}|dkrRd}nj|dkrvt	d	t| t
| nF|d
krt|}t	dt|t| t|| n|dkrtd |sdS tj|dtjdd}| tjtj| j}t|D ]\}	}
}d|
kr|

d |
D ]6}| j||	|d}t|d }d|_||d q |D ]>}|tkrnq\| j||	|d}tj|	|}||| q\qW 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`.
        Tz	%s-%s.zipr   z8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )iwbar   Fr   zDeleting %sr   zBacking up %s to %sr   N)Z
allowZip64zpip-egg-info)r   r   r   i  r   zSaved %s)rq   r   rE   rF   ru   r   r   r   rz   r   r   r   r   r   r   exitzipfileZZipFileZZIP_DEFLATEDnormcaserH   r   walkr   ZZipInfoZexternal_attrZwritestrr   writer   )r_   r   Zcreate_archiveZarchive_nameZarchive_pathZresponseZ	dest_fileZ
zip_outputdirdirpathZdirnames	filenamesdirnameZdir_arcnameZzipdirfilenameZfile_arcnamer;   r;   r?   archive  sx    
   

  
  zInstallRequirement.archivec	                    sh  |d k	r|ng }| j r*| j|||d d S | jrnt| j}	t|	| j | j| j |||||d d| _	d S t
|| jdg  }t
|| jdg  }tdd}
tj|
jd}| || ||}td	| j}t * | j ||| | jd
 W 5 Q R X W 5 Q R X tj|s8td| W 5 Q R  d S d| _	 fdd}t|\}|D ],}tj|}|drX||} qqXtd|  W 5 Q R  W 5 Q R  d S W 5 Q R X g }t|L}|D ]@}| }tj|r|tjj 7 }|!tj"||| qW 5 Q R X |#  t$| tj|d}t|d}|%d|d  W 5 Q R X W 5 Q R X d S )N)r   )r   r   r   r   r   r   Tr   r   recordr   zinstall-record.txtzRunning setup.py install for {})cmdr   zRecord file %s not foundc                    s&    d kst j| s| S t | S d S r~   )rE   rF   isabsr   )rF   r   r;   r?   prepend_root  s    z0InstallRequirement.install.<locals>.prepend_rootr   z;Could not find .egg-info directory in install record for %szinstalled-files.txtr   
)&rI   r   r   r   Zwheel_versionrD   Zcheck_compatibilityrq   r   rV   r   rW   ry   r)   rE   rF   ru   get_install_argsr(   rm   r   rY   r   r   rz   r{   openr   r   r   stripisdirr   r   r   sortr    r   )r_   r   r   r   r   r   r   r   r   r   Ztemp_dirrecord_filenameinstall_argsr   r   flineZ	directoryZegg_info_dirZ	new_linesr   Zinst_files_pathr;   r   r?   installE  s              


"
zInstallRequirement.installc              	   C   s   t | j|| jdd}|dd|g7 }|dg7 }|d k	r@|d|g7 }|d k	rT|d|g7 }|rd|dg7 }n
|d	g7 }t rd
t  }|dtjt	j
dd|| jg7 }|S )NT)r   r   Zunbuffered_outputr   z--recordz#--single-version-externally-managedz--rootz--prefixz	--compilez--no-compilepythonz--install-headersZincludeZsite)r&   r   rX   r+   	sysconfigZget_python_versionrE   rF   ru   r   r   rq   )r_   r   r   r   r   r   r   Z
py_ver_strr;   r;   r?   r     s0    	

 z#InstallRequirement.get_install_args)
NFNNNFNNFr;   )N)T)NNNTFT)r;   N)T)FFF)NNNNTFT)*rj   
__module____qualname____doc__r`   rh   rl   rw   r}   propertyrq   r   r   r   r   r   r   re   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r;   r;   r?   r:   M   s   
          
W








8+
	      



%
  

  
	B       
`r:   )eZ
__future__r   r   ZloggingrE   r   r   r   r   Zdistutils.utilr   Zpip._vendorr   r   Z"pip._vendor.packaging.requirementsr   Zpip._vendor.packaging.utilsr   Zpip._vendor.packaging.versionr   r	   r   Zpip._vendor.pep517.wrappersr
   Zpip._internalr   r   Zpip._internal.build_envr   Zpip._internal.exceptionsr   Zpip._internal.models.linkr   Z*pip._internal.operations.generate_metadatar   Zpip._internal.pyprojectr   r   Zpip._internal.req.req_uninstallr   Zpip._internal.utils.compatr   Zpip._internal.utils.hashesr   Zpip._internal.utils.loggingr   Z pip._internal.utils.marker_filesr   r   Zpip._internal.utils.miscr   r   r   r   r   r   r   r    r!   r"   r#   r$   Zpip._internal.utils.packagingr%   Z$pip._internal.utils.setuptools_buildr&   Zpip._internal.utils.subprocessr'   r(   Zpip._internal.utils.temp_dirr)   Zpip._internal.utils.typingr*   Zpip._internal.utils.virtualenvr+   Zpip._internal.vcsr,   typingr-   r.   r/   r0   r1   r2   r3   r4   Zpip._internal.cacher5   Zpip._internal.indexr6   Zpip._vendor.pkg_resourcesr7   Z pip._vendor.packaging.specifiersr8   Zpip._vendor.packaging.markersr9   Z	getLoggerrj   rz   objectr:   r;   r;   r;   r?   <module>   sV   8$
