U
    
Ha                     @   s~   d dl Z d dl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)SetTuple)Distribution)BuildEnvironment)AbstractDistribution)InstallationError)PackageFinder)runner_with_spinner_messagec                   @   s@   e Zd ZdZedddZeeddddZ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  S N)reqget_dist)self r   E/tmp/pip-unpacked-wheel-tx790h60/pip/_internal/distributions/sdist.pyget_pkg_resources_distribution   s    z1SourceDistribution.get_pkg_resources_distributionN)finderbuild_isolationr   c                 C   s2   | j   | j jo|}|r$| | | j   d S r   )r   load_pyproject_toml
use_pep517_setup_isolationprepare_metadata)r   r   r   should_isolater   r   r   prepare_distribution_metadata   s
    

z0SourceDistribution.prepare_distribution_metadata)r   r   c              
      s0  t ttt t f  d d fdd}jj}|d k	s8tt j_jj||dd jj	jj
\ } rz|d  |rtdj tdd	ttt| jj@ td
}jj}|d k	st|| | }W 5 Q R X W 5 Q R X jj	|\ } r|d  jj||dd d S )N)conflicting_withconflicting_reqsr   c                    s6   d}|j j| ddd t D d}t|d S )NzZSome build dependencies for {requirement} conflict with {conflicting_with}: {description}.z, c                 s   s    | ]\}}| d | V  qdS )z is incompatible with Nr   ).0	installedwantedr   r   r   	<genexpr>1   s   zPSourceDistribution._setup_isolation.<locals>._raise_conflicts.<locals>.<genexpr>)requirementr   description)formatr   joinsortedr   )r   r   format_stringerror_messageconflictingr   r   r   _raise_conflicts'   s    
z=SourceDistribution._setup_isolation.<locals>._raise_conflictsoverlayzInstalling build dependenciesz"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 z#Getting requirements to build wheelzthe backend dependenciesnormalzInstalling backend dependencies)strr   r   r   pyproject_requiresAssertionErrorr   	build_envinstall_requirementscheck_requirementsrequirements_to_checkloggerwarningr$   mapreprr%   r	   pep517_backendsubprocess_runnerget_requires_for_build_wheel)r   r   r*   r.   missingrunnerbackendreqsr   r(   r   r   &   sT     
   


   z#SourceDistribution._setup_isolation)
__name__
__module____qualname____doc__r   r   r   boolr   r   r   r   r   r   r
      s    r
   )loggingtypingr   r   Zpip._vendor.pkg_resourcesr   pip._internal.build_envr    pip._internal.distributions.baser   pip._internal.exceptionsr   "pip._internal.index.package_finderr   pip._internal.utils.subprocessr	   	getLoggerr?   r4   r
   r   r   r   r   <module>   s   
