o
    5e5                     @   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dee fddZdefddZ	de
ded	edd
fddZde
dd
fddZdee fddZdee fddZde
dd
fddZdedeeeef  dd
fddZdee dd
fddZd
S )SourceDistributionzRepresents 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J | j jjS )z/Identify this requirement uniquely by its link.)reqlinkurl_without_fragmentself r   T/var/www/html/venv/lib/python3.10/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_distributionfinderbuild_isolationcheck_build_depsNc           	      C   s   | j   | j jo
|}|r| | | j   | | | j jo!|}|rF| j j}|d us.J | j j|\}}|r?| 	d| |rF| 
| | j   d S )Nthe backend dependencies)r   load_pyproject_toml
use_pep517_prepare_build_backendisolated_editable_sanity_check_install_build_reqspyproject_requires	build_envcheck_requirements_raise_conflicts_raise_missing_reqsprepare_metadata)	r   r   r   r   should_isolateshould_check_depsr!   conflictingmissingr   r   r   prepare_distribution_metadata   s$   




z0SourceDistribution.prepare_distribution_metadatac              	   C   s   | j j}|d us
J t | j _| j jj||ddd | j j| j j\}}|r-| d| |rFt	d| j  t	dd
ttt| d S 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"   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      | 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   r7   )Nz&Getting requirements to build editable)r   r"   r   r8   r9   get_requires_for_build_editabler;   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|\}}|r'| 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   
build_reqsr)   r*   r   r   r   r    q   s   

z&SourceDistribution._install_build_reqsconflicting_withconflicting_reqsc                 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>)requirementrF   description)formatr   r3   r6   r   )r   rF   rG   format_stringerror_messager   r   r   r$      s   
z#SourceDistribution._raise_conflictsr*   c                 C   s,   d}|j | jdttt|d}t|)NzASome build dependencies for {requirement} are missing: {missing}.rH   )rM   r*   )rO   r   r3   r4   r5   r6   r   )r   r*   rP   rQ   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      s4    
'

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   	getLoggerrR   r1   r   r   r   r   r   <module>   s    
