U
    cUh_                     @   s   d dl Z d dlmZ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 erpd dlmZ e eZG d	d
 d
e
ZdS )    N)TYPE_CHECKINGIterableOptionalSetTuple)BuildEnvironment)AbstractDistribution)InstallationError)BaseDistribution)runner_with_spinner_message)PackageFinderc                   @   s   e Zd ZdZeee dddZedddZ	de
e
dd	d
dZdddddZee dddZee dddZd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 )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t| j jjS )z/Identify this requirement uniquely by its link.)reqlinkAssertionErrorurl_without_fragmentself r   a/opt/bot/vods_filmes/script/venv/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_distributionr   N)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| |rt	
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    G   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_wheela   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   r7   r   r8   get_requires_for_build_editabler:   r   r   r   _get_build_requires_editablei   s    
z/SourceDistribution._get_build_requires_editablec                 C   sf   | j jr"| j jr"| j jr"|  }n|  }| j j|\}}|rL| 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"   s   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>)requirementrD   description)formatr   r3   r6   r	   )r   rD   rE   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}.rF   )rJ   r*   )rL   r   r3   r4   r5   r6   r	   )r   r*   rM   rN   r   r   r   r'      s     z&SourceDistribution._raise_missing_reqs)__name__
__module____qualname____doc__propertyr   strr   r
   r   boolr+   r    r   r=   r?   r"   r   r   r&   r'   r   r   r   r   r      s$   '
 r   )loggingtypingr   r   r   r   r   pip._internal.build_envr    pip._internal.distributions.baser   pip._internal.exceptionsr	   pip._internal.metadatar
   pip._internal.utils.subprocessr   "pip._internal.index.package_finderr   	getLoggerrO   r1   r   r   r   r   r   <module>   s   
