o
    ­—Žjö2  ã                   @  sB  d dl mZ d dlZd dlZd dl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mZmZ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$ erŒ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. e /e0¡Z1G dd„ dƒZ2G dd„ dƒZ3dS )é    )ÚannotationsN)ÚIterableÚSequence)ÚAbstractContextManager)Únullcontext)ÚStringIO)ÚTYPE_CHECKING)ÚPrefix)Úopen_rich_spinnerÚopen_spinner)ÚBuildDependencyInstallErrorÚDiagnosticPipErrorÚInstallWheelBuildErrorÚPipError)Úget_environment)ÚVERBOSEÚcapture_logging)Úget_runnable_pip)Úcall_subprocess)ÚTempDirectory)Ú
WheelCache)ÚPackageFinder)ÚBuildTracker)ÚInstallRequirement)ÚBaseResolverc                   @  s(   e Zd ZdZ	ddd	d
„Zddd„ZdS )Ú#SubprocessBuildEnvironmentInstallerzD
    Install build dependencies by calling pip in a subprocess.
    NÚfinderr   Úbuild_constraintsúlist[str] | NoneÚreturnÚNonec                 C  s   || _ |pg | _d S ©N)r   Ú_build_constraints)Úselfr   r   © r$   ú^/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pip/_internal/build_env/installer.pyÚ__init__*   s   z,SubprocessBuildEnvironmentInstaller.__init__ÚrequirementsúIterable[str]Úprefixr	   ÚkindÚstrÚfor_reqúInstallRequirement | Nonec             
   C  s²  | j }tƒ dd|jddddddg
}|jr| d	|j¡ n| d	tj¡ | d
¡ t 	¡ t
jkr5| d¡ nt 	¡ tkr@| d¡ dD ]}t|j|ƒ}| d| dd¡ d t|pZdhƒ¡f¡ qB|jd ur||j ¡ D ]\}	}
| d|	 dd¡ |
f¡ qj|j}|r›| d|d	 g¡ |dd … D ]	}| d|g¡ q�n| d¡ |jD ]	}| d|g¡ q£|jd urº| d|jg¡ |jrÂ| d¡ |jD ]	}| d|g¡ qÅ|jrÚ| d|jg¡ |jrå| d|jg¡ |jrí| d¡ |jrû| dd |j¡g¡ | jD ]	}| d|g¡ qþ|j�r| d |j  ¡ g¡ | d¡ | |¡ |�r-|j!�r-d!|j!› �nd}t"d"|› �ƒ�}t#|d#|› |› �|d$d%id&� W d   ƒ d S 1 �sRw   Y  d S )'NÚinstallz--prefixz	--no-userz--no-warn-script-locationz--disable-pip-version-checkz--no-compilez--targetÚ r   z--ignore-installedz-vvz-v)Ú	no_binaryÚonly_binaryz--Ú_ú-ú,z:none:z-ié   z--extra-index-urlz
--no-indexz--find-linksz--proxyz--no-proxy-envz--trusted-hostz--certz--client-certz--prefer-binaryz--refresh-packagez--build-constraintz--uploaded-prior-toz for úInstalling zinstalling Ú _PIP_IN_BUILD_IGNORE_CONSTRAINTSÚ1)Úcommand_descÚspinnerÚextra_environ)$r   r   ÚpathÚvenv_executableÚinsertÚsysÚ
executableÚappendÚloggerÚgetEffectiveLevelÚloggingÚDEBUGr   ÚgetattrÚformat_controlÚextendÚreplaceÚjoinÚsortedÚrelease_controlÚget_ordered_argsÚ
index_urlsÚ
find_linksÚproxyÚno_proxy_envÚtrusted_hostsÚcustom_certÚclient_certÚprefer_binaryÚrefresh_packager"   Úuploaded_prior_toÚ	isoformatÚnamer   r   )r#   r'   r)   r*   r,   r   ÚargsrG   ÚformatsÚ	attr_nameÚvaluerN   Úextra_indexÚlinkÚhostÚconstraint_fileÚidentify_requirementr:   r$   r$   r%   r.   2   sŠ   î

þÿ
ÿ








ÿü$ÿz+SubprocessBuildEnvironmentInstaller.installr!   )r   r   r   r   r   r    ©
r'   r(   r)   r	   r*   r+   r,   r-   r   r    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r&   r.   r$   r$   r$   r%   r   %   s
    ýr   c                   @  s@   e Zd ZdZdddœd#dd„Zd$dd„Zd%dd„Zd&d d!„Zd"S )'Ú"InprocessBuildEnvironmentInstallera  
    Install build dependencies via the already running pip process.

    This contains a stripped down version of the install command with
    only the logic necessary for installing build dependencies. The
    finder, session, build tracker, and wheel cache are reused, but new
    instances of everything else are created as needed.

    Options are inherited from the parent install command unless
    they don't make sense for build dependencies (in which case, they
    are hard-coded, see comments below).
    r$   r   )r   Ú	verbosityr   r   Úbuild_trackerr   Úwheel_cacher   r   úSequence[InstallRequirement]ri   Úintr   r    c                C  s¦   ddl m} || _|| _|| _d| _tddd�}|di d| “d|“d|jj“d	|j	“d
|“d|“dd“dd “dd“dd“dd“dd“dd“dd“dd“dd“Ž| _
d S )Nr   )ÚRequirementPreparerzbuild-env-installT)r*   Úglobally_managedÚbuild_isolation_installerr   ÚsessionÚ	build_dirrj   ri   Úsrc_dirr/   Údownload_dirÚbuild_isolationÚvirtualÚcheck_build_depsFÚprogress_barÚoffÚrequire_hashesÚuse_user_siteÚ
lazy_wheelÚlegacy_resolverÚallow_editablesr$   )Ú pip._internal.operations.preparern   Ú_finderr"   Ú_wheel_cacheÚ_levelr   Ú_link_collectorrq   r<   Ú	_preparer)r#   r   rj   rk   r   ri   rn   rr   r$   r$   r%   r&   ­   sN   	ÿýüûúù	÷õôóòïîíì
ëz+InprocessBuildEnvironmentInstaller.__init__r'   r(   r)   r	   r*   r+   r,   r-   c             
   C  s˜  t  t¡ o
| jdk}|rtƒ }td|› �ƒ}nttƒ ƒtƒ }}t  d|¡ zœz3|  jd7  _|�  |�}|  	||¡ W d  ƒ n1 sFw   Y  W d  ƒ n1 sUw   Y  W n^ t
yˆ }	 z!t  t | ¡ ¡¡ t jd|	ddid	� t  d
¡ t|||	dd�‚d}	~	w ty¹ }	 z&t | ¡ ¡ ¡ }
|s­d}
t|	tƒr¨t  d|	¡ nt  d¡ t|||	|
d�‚d}	~	ww W |  jd8  _dS |  jd8  _w )z@Install entrypoint. Manages output capturing and error handling.r   r6   zInstalling %s ...r5   Nz%sÚrichT)Úextrar/   )ÚcauseÚ	log_lineszpip crashed unexpectedly)rB   ÚisEnabledForr   r‚   r   r
   r   r   ÚinfoÚ_install_implr   ÚtextwrapÚdedentÚgetvalueÚerrorr   Ú	ExceptionÚ
splitlinesÚ
isinstancer   Ú	exception)r#   r'   r)   r*   r,   Úcapture_logsÚcapture_ctxr:   ÚstreamÚexcÚlogsr$   r$   r%   r.   Ö   sH   	ÿ€ €
ÿ€

ÿ€ö€"z*InprocessBuildEnvironmentInstaller.installc                   sú   ddl m} ddlm} ddlm‰  ddlm} ‡ fdd„|D ƒ}| | j	¡ |  
¡ }|j|dd	�}| j |j ¡ ¡ d
d„ |jD ƒ}	||	| jddd�\}
}|rTt|ƒ‚|| |¡|jdddddd|jd�	}tt|jƒƒ}|||ƒ }r{t |¡ dS dS )z$Core build dependency install logic.r   )Úinstalled_packages_summary)Úinstall_given_reqs©Úinstall_req_from_line)Úbuildc                   s   g | ]}ˆ |d d�‘qS )T)Úuser_suppliedr$   )Ú.0Úreqr›   r$   r%   Ú
<listcomp>  s    zDInprocessBuildEnvironmentInstaller._install_impl.<locals>.<listcomp>T)Úcheck_supported_wheelsc                 S  s   g | ]}|j s|‘qS r$   )Úis_wheel)rŸ   Úrr$   r$   r%   r¡     s
    ÿÿ)Úverifyr~   NFry   )r)   ÚrootÚhomeÚwarn_script_locationr{   Ú	pycompilerx   Úscript_executable)Úpip._internal.commands.installr™   Úpip._internal.reqrš   Úpip._internal.req.constructorsrœ   Úpip._internal.wheel_builderr�   rH   r"   Ú_make_resolverÚresolver„   Ú prepare_linked_requirements_morer'   ÚvaluesÚrequirements_to_installr�   r   Úget_installation_orderr<   r=   r   ÚlistÚlib_dirsrB   rŠ   )r#   r'   r)   r™   rš   r�   ÚireqsÚresolverÚresolved_setÚreqs_to_buildr2   Úbuild_failuresÚ	installedÚenvÚsummaryr$   r›   r%   r‹   
  sD   ÿÿ

ÿóÿz0InprocessBuildEnvironmentInstaller._install_implr   c                 C  s>   ddl m} ddlm} ||| j| j| jddddddddd�S )	z'Create a new resolver for one time use.r   )Úinstall_req_from_req_string)ÚResolverFTzto-satisfy-onlyN)Úmake_install_reqÚpreparerr   rk   Úignore_requires_pythonr{   Úignore_dependenciesÚonly_dependenciesÚignore_installedÚforce_reinstallÚupgrade_strategyÚpy_version_info)r­   r¿   Ú,pip._internal.resolution.resolvelib.resolverrÀ   r„   r€   r�   )r#   r¿   rÀ   r$   r$   r%   r¯   7  s    òz1InprocessBuildEnvironmentInstaller._make_resolverN)r   r   rj   r   rk   r   r   rl   ri   rm   r   r    rc   )r'   r(   r)   r	   r   r    )r   r   )rd   re   rf   rg   r&   r.   r‹   r¯   r$   r$   r$   r%   rh   ›   s    ù
)
4-rh   )4Ú
__future__r   rD   r?   rŒ   Úcollections.abcr   r   Ú
contextlibr   ÚContextManagerr   Úior   Útypingr   Úpip._internal.build_env.baser	   Úpip._internal.cli.spinnersr
   r   Úpip._internal.exceptionsr   r   r   r   Úpip._internal.metadatar   Úpip._internal.utils.loggingr   r   Úpip._internal.utils.miscr   Úpip._internal.utils.subprocessr   Úpip._internal.utils.temp_dirr   Úpip._internal.cacher   Ú"pip._internal.index.package_finderr   Ú,pip._internal.operations.build.build_trackerr   Úpip._internal.req.req_installr   Úpip._internal.resolution.baser   Ú	getLoggerrd   rB   r   rh   r$   r$   r$   r%   Ú<module>   s4    
v