a
    ñ»jã  ã                   @  s–   d dl mZ d dl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 erxd d
lmZ e e¡ZG dd„ de
ƒZdS )é    )ÚannotationsN)ÚIterable)ÚTYPE_CHECKING)ÚBuildEnvironment)ÚAbstractDistribution)ÚInstallationError)ÚBaseDistribution)Úrunner_with_spinner_message)ÚBuildEnvironmentInstallerc                   @  s¢   e Zd ZdZeddœdd„ƒZddœdd„Zd	d
d
ddœdd„Zd	ddœdd„Zddœdd„Z	ddœdd„Z
d	ddœdd„Zddddœdd„Zdddœd d!„Zd"S )#ÚSourceDistributionzRepresents a source distribution.

    The preparation step for these needs metadata for the packages to be
    generated.
    z
str | None)Úreturnc                 C  s   | j jsJ ‚| j jjS )z/Identify this requirement uniquely by its link.)ÚreqÚlinkÚurl_without_fragment©Úself© r   úGE:\soccer\ml_env\Lib\site-packages\pip/_internal/distributions/sdist.pyÚbuild_tracker_id   s    z#SourceDistribution.build_tracker_idr   c                 C  s
   | j  ¡ S )N)r   Úget_distr   r   r   r   Úget_metadata_distribution    s    z,SourceDistribution.get_metadata_distributionr
   ÚboolÚNone)Úbuild_env_installerÚbuild_isolationÚcheck_build_depsr   c                 C  sŽ   | j  ¡  |r.|  |¡ | j  ¡  |  |¡ n
| j  ¡  |r€| j j}|d usPJ ‚| j j |¡\}}|rr|  d|¡ |r€|  	|¡ | j  
¡  d S )Núthe backend dependencies)r   Úload_pyproject_tomlÚ_prepare_build_backendZeditable_sanity_checkÚ_install_build_reqsÚpyproject_requiresÚ	build_envÚcheck_requirementsÚ_raise_conflictsÚ_raise_missing_reqsÚprepare_metadata)r   r   r   r   r    ÚconflictingÚmissingr   r   r   Úprepare_distribution_metadata#   s"    



ÿ
z0SourceDistribution.prepare_distribution_metadata)r   r   c              	   C  s�   | j j}|d usJ ‚t|ƒ| j _| j jj|dd| j d� | j j | j j¡\}}|r^|  d|¡ |rŒt 	d| j ¡ t 	dd 
ttt|ƒƒ¡¡ d S )NÚoverlayzbuild dependencies©ÚkindZfor_reqz"PEP 517/518 supported requirementsz4Missing build requirements in pyproject.toml for %s.z`The project does not specify a build backend, and pip cannot fall back to setuptools without %s.z and )r   r    r   r!   Úinstall_requirementsr"   Úrequirements_to_checkr#   ÚloggerÚwarningÚjoinÚmapÚreprÚsorted)r   r   r    r&   r'   r   r   r   r   I   s(    
ÿÿþýz)SourceDistribution._prepare_build_backendzIterable[str]c              	   C  sˆ   | j j�l tdƒ}| j j}|d us&J ‚| |¡�& | ¡ W  d   ƒ W  d   ƒ S 1 s\0    Y  W d   ƒ n1 sz0    Y  d S )Nz#Getting requirements to build wheel)r   r!   r	   Úpep517_backendÚsubprocess_runnerÚget_requires_for_build_wheel©r   ÚrunnerÚbackendr   r   r   Ú_get_build_requires_wheele   s    
z,SourceDistribution._get_build_requires_wheelc              	   C  sˆ   | j j�l tdƒ}| j j}|d us&J ‚| |¡�& | ¡ W  d   ƒ W  d   ƒ S 1 s\0    Y  W d   ƒ n1 sz0    Y  d S )Nz&Getting requirements to build editable)r   r!   r	   r4   r5   Úget_requires_for_build_editabler7   r   r   r   Ú_get_build_requires_editablem   s    
ÿz/SourceDistribution._get_build_requires_editablec                 C  sh   | j jr"| j jr"| j jr"|  ¡ }n|  ¡ }| j j |¡\}}|rL|  d|¡ | j jj	|dd| j d� d S )Nr   Únormalzbackend dependenciesr*   )
r   ÚeditableÚpermit_editable_wheelsÚsupports_pyproject_editabler<   r:   r!   r"   r#   r,   )r   r   Ú
build_reqsr&   r'   r   r   r   r   w   s    ÿþý

ÿz&SourceDistribution._install_build_reqsÚstrzset[tuple[str, str]])Úconflicting_withÚconflicting_reqsr   c                 C  s6   d}|j | j|d dd„ t|ƒD ƒ¡d�}t|ƒ‚d S )NzZSome build dependencies for {requirement} conflict with {conflicting_with}: {description}.ú, c                 s  s    | ]\}}|› d |› �V  qdS )z is incompatible with Nr   )Ú.0Ú	installedÚwantedr   r   r   Ú	<genexpr>–   s   ÿz6SourceDistribution._raise_conflicts.<locals>.<genexpr>)ÚrequirementrC   Údescription)Úformatr   r0   r3   r   )r   rC   rD   Úformat_stringÚerror_messager   r   r   r#   Œ   s    ÿ
þýz#SourceDistribution._raise_conflictszset[str])r'   r   c                 C  s0   d}|j | jd ttt|ƒƒ¡d�}t|ƒ‚d S )NzASome build dependencies for {requirement} are missing: {missing}.rE   )rJ   r'   )rL   r   r0   r1   r2   r3   r   )r   r'   rM   rN   r   r   r   r$   �   s    ÿÿz&SourceDistribution._raise_missing_reqsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r(   r   r:   r<   r   r#   r$   r   r   r   r   r      s   &
r   )Ú
__future__r   ÚloggingÚcollections.abcr   Útypingr   Úpip._internal.build_envr   Ú pip._internal.distributions.baser   Úpip._internal.exceptionsr   Úpip._internal.metadatar   Úpip._internal.utils.subprocessr	   r
   Ú	getLoggerrO   r.   r   r   r   r   r   Ú<module>   s   
