U
    Ðvag5  ã                   @   s†   d dl 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 d dlmZ e  e¡ZG d	d
„ d
e	ƒZdS )é    N)ÚIterableÚOptionalÚSetÚTuple)ÚBuildEnvironment)ÚAbstractDistribution)ÚInstallationError)ÚPackageFinder)ÚBaseDistribution)Úrunner_with_spinner_messagec                   @   s¾   e Zd ZdZeee dœdd„ƒZedœdd„Z	e
eeddœd	d
„Ze
ddœdd„Zee dœdd„Zee dœdd„Ze
ddœdd„Zeeeeef  ddœdd„Zee 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, either using PEP 517 or using the legacy `setup.py egg_info`.
    )Úreturnc                 C   s   | j jst‚| j jjS )z/Identify this requirement uniquely by its link.)ÚreqÚlinkÚAssertionErrorÚurl_without_fragment©Úself© r   úU/var/www/html/myvenv/lib/python3.8/site-packages/pip/_internal/distributions/sdist.pyÚbuild_tracker_id   s    z#SourceDistribution.build_tracker_idc                 C   s
   | j  ¡ S )N)r   Úget_distr   r   r   r   Úget_metadata_distribution   s    z,SourceDistribution.get_metadata_distributionN)ÚfinderÚbuild_isolationÚcheck_build_depsr   c           	      C   sš   | j  ¡  | j jo|}|r8|  |¡ | j  ¡  |  |¡ | j joB|}|rŒ| j j}|d k	s\t‚| j j 	|¡\}}|r~|  
d|¡ |rŒ|  |¡ | j  ¡  d S )Núthe backend dependencies)r   Úload_pyproject_tomlÚ
use_pep517Ú_prepare_build_backendÚisolated_editable_sanity_checkÚ_install_build_reqsÚpyproject_requiresr   Ú	build_envÚcheck_requirementsÚ_raise_conflictsÚ_raise_missing_reqsÚprepare_metadata)	r   r   r   r   Zshould_isolateZshould_check_depsr"   ÚconflictingÚmissingr   r   r   Úprepare_distribution_metadata   s$    



ÿ
z0SourceDistribution.prepare_distribution_metadata)r   r   c              	   C   sŒ   | j j}|d k	st‚tƒ | j _| j jj||ddd� | j j | j j¡\}}|rZ|  d|¡ |rˆt	 
d| j ¡ t	 
dd ttt|ƒƒ¡¡ d S )NÚoverlayzbuild dependencies©Úkindz"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   r#   Úinstall_requirementsr$   Úrequirements_to_checkr%   ÚloggerÚwarningÚjoinÚmapÚreprÚsorted)r   r   r"   r(   r)   r   r   r   r   E   s.    
   ÿÿþýz)SourceDistribution._prepare_build_backendc                 C   sf   | j j�T tdƒ}| j j}|d k	s&t‚| |¡�" | ¡ W  5 Q R £ W  5 Q R £ S Q R X W 5 Q R X d S )Nz#Getting requirements to build wheel)r   r#   r   Úpep517_backendr   Úsubprocess_runnerÚget_requires_for_build_wheel©r   ÚrunnerÚbackendr   r   r   Ú_get_build_requires_wheel_   s    
z,SourceDistribution._get_build_requires_wheelc                 C   sf   | j j�T tdƒ}| j j}|d k	s&t‚| |¡�" | ¡ W  5 Q R £ W  5 Q R £ S Q R X W 5 Q R X d S )Nz&Getting requirements to build editable)r   r#   r   r6   r   r7   Úget_requires_for_build_editabler9   r   r   r   Ú_get_build_requires_editableg   s    
ÿz/SourceDistribution._get_build_requires_editablec                 C   sh   | j jr$| j jr$| j  ¡ r$|  ¡ }n|  ¡ }| j j |¡\}}|rN|  d|¡ | j jj	||ddd� d S )Nr   Únormalzbackend dependenciesr,   )
r   ÚeditableÚpermit_editable_wheelsÚsupports_pyproject_editabler>   r<   r#   r$   r%   r.   )r   r   Z
build_reqsr(   r)   r   r   r   r!   q   s"    ÿþý
   ÿz&SourceDistribution._install_build_reqs)Ú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Ú	installedZwantedr   r   r   Ú	<genexpr>Ž   s   ÿz6SourceDistribution._raise_conflicts.<locals>.<genexpr>)ÚrequirementrC   Údescription)Úformatr   r2   r5   r   )r   rC   rD   Úformat_stringÚerror_messager   r   r   r%   „   s    ÿ
þýz#SourceDistribution._raise_conflicts)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   )rI   r)   )rK   r   r2   r3   r4   r5   r   )r   r)   rL   rM   r   r   r   r&   •   s    ÿ ÿz&SourceDistribution._raise_missing_reqs)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   Ústrr   r
   r   r	   Úboolr*   r   r   r<   r>   r!   r   r   r%   r&   r   r   r   r   r      s$   û'
 þr   )ÚloggingÚtypingr   r   r   r   Úpip._internal.build_envr   Ú pip._internal.distributions.baser   Úpip._internal.exceptionsr   Ú"pip._internal.index.package_finderr	   Úpip._internal.metadatar
   Úpip._internal.utils.subprocessr   Ú	getLoggerrN   r0   r   r   r   r   r   Ú<module>   s   
