o
    ©„jg  ã                   @  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
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 erHd dl	mZ e e¡ZG dd„ deƒZdS )é    )ÚannotationsN)ÚIterable)Únullcontext)ÚTYPE_CHECKING)ÚBuildIsolationModeÚNoOpBuildEnvironmentÚVenvBuildEnvironmentÚVirtualBuildEnvironment)ÚAbstractDistribution)ÚInstallationError)ÚBaseDistribution)Úrunner_with_spinner_message)ÚBuildEnvironmentInstallerc                   @  sx   e Zd ZdZed)dd„ƒZd*dd„Zd+dd„Zd,dd„Zd-dd„Z	d.dd„Z
d.dd„Zd/dd„Zd0d"d#„Zd1d&d'„Zd(S )2ÚSourceDistributionzRepresents a source distribution.

    The preparation step for these needs metadata for the packages to be
    generated.
    Úreturnú
str | Nonec                 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   ú_/var/www/html/django_cbt/venv/lib/python3.10/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_distributionÚbuild_env_installerr   Úbuild_isolationr   Úcheck_build_depsÚboolÚallow_editablesÚNonec                 C  s¦   | j  ¡  |  ||¡ |dkr"|  |¡ | j  ¡  | j|||d� n| j  ¡  |rK| j j}|d us3J ‚| j j |¡\}}|rD|  	d|¡ |rK|  
|¡ | j  |¡ d S )NÚoff)r    úthe backend dependencies)r   Úload_pyproject_tomlÚ_prepare_build_envÚ_prepare_build_backendÚeditable_sanity_checkÚ_install_build_reqsÚpyproject_requiresÚ	build_envÚcheck_requirementsÚ_raise_conflictsÚ_raise_missing_reqsÚprepare_metadata)r   r   r   r   r    r)   ÚconflictingÚmissingr   r   r   Úprepare_distribution_metadata)   s(   


ÿ
ÿ
z0SourceDistribution.prepare_distribution_metadatac                 C  s@   |dkrt |ƒ| j_n
|dkrt|ƒ| j_| j | jjj¡ d S )NÚvirtualÚvenv)r	   r   r*   r   Úconfigure_backendÚpython_executable)r   r   r   r   r   r   r%   S   s
   z%SourceDistribution._prepare_build_envc              	   C  sÔ   | j j}|d us
J ‚t| j jtƒrJ ‚|dkr| j jntƒ }|� | j jj|dd| j d� W d   ƒ n1 s7w   Y  | j j | j j¡\}}|rO|  	d|¡ |rht
 d| j ¡ t
 dd ttt|ƒƒ¡¡ d S d S )	Nr3   Úoverlayzbuild dependencies©ÚkindÚ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)   Ú
isinstancer*   r   r   Úinstall_requirementsr+   Úrequirements_to_checkr,   ÚloggerÚwarningÚjoinÚmapÚreprÚsorted)r   r   r)   Úcontextr/   r0   r   r   r   r&   _   s6   üÿÿþýûz)SourceDistribution._prepare_build_backendúIterable[str]c              	   C  óŠ   | j j�7 tdƒ}| j j}|d usJ ‚| |¡� | ¡ W  d   ƒ W  d   ƒ S 1 s.w   Y  W d   ƒ d S 1 s>w   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_wheel}   s   
ÿü"üz,SourceDistribution._get_build_requires_wheelc              	   C  rE   )Nz&Getting requirements to build editable)r   r*   r   rF   rG   Úget_requires_for_build_editablerI   r   r   r   Ú_get_build_requires_editable…   s   
ÿÿú"úz/SourceDistribution._get_build_requires_editablec                 C  s    | j jr|r| j jr|  ¡ }n|  ¡ }| j j |¡\}}|r$|  d|¡ |dkr,| j jntƒ }|� | j jj	|dd| j d� W d   ƒ d S 1 sIw   Y  d S )Nr#   r3   Únormalzbackend dependenciesr7   )
r   ÚeditableÚsupports_pyproject_editablerN   rL   r*   r+   r,   r   r;   )r   r   r   r    Ú
build_reqsr/   r0   rC   r   r   r   r(   �   s"   
ÿþý

ÿ"ÿz&SourceDistribution._install_build_reqsÚconflicting_withÚstrÚconflicting_reqsúset[tuple[str, str]]c                 C  s2   d}|j | j|d dd„ t|ƒD ƒ¡d�}t|ƒ‚)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>)ÚrequirementrS   Údescription)Úformatr   r?   rB   r   )r   rS   rU   Úformat_stringÚerror_messager   r   r   r,   ©   s   ÿ
þýz#SourceDistribution._raise_conflictsr0   úset[str]c                 C  s,   d}|j | jd ttt|ƒƒ¡d�}t|ƒ‚)NzASome build dependencies for {requirement} are missing: {missing}.rW   )r\   r0   )r^   r   r?   r@   rA   rB   r   )r   r0   r_   r`   r   r   r   r-   º   s   ÿÿz&SourceDistribution._raise_missing_reqsN)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   rD   )r   r   r   r   r    r   r   r!   )rS   rT   rU   rV   r   r!   )r0   ra   r   r!   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r1   r%   r&   rL   rN   r(   r,   r-   r   r   r   r   r      s    


*





r   )Ú
__future__r   ÚloggingÚcollections.abcr   Ú
contextlibr   Útypingr   Úpip._internal.build_envr   r   r   r	   Ú pip._internal.distributions.baser
   Úpip._internal.exceptionsr   Úpip._internal.metadatar   Úpip._internal.utils.subprocessr   r   Ú	getLoggerrb   r=   r   r   r   r   r   Ú<module>   s    
