o
    ñ‘Oj^  ã                   @   s‚   d dl Z d dl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ÚSetÚTuple)ÚBuildEnvironment)ÚAbstractDistribution)ÚInstallationError)ÚPackageFinder)ÚBaseDistribution)Úrunner_with_spinner_messagec                   @   s¸   e Zd Z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 )Ú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  ¡ S )N)ÚreqÚget_dist)Úself© r   úg/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/pip/_internal/distributions/sdist.pyÚ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   ?   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_wheelY   s   
ÿü"üz,SourceDistribution._get_build_requires_wheelc              	   C   r2   )Nz&Getting requirements to build editable)r   r   r
   r3   r4   Úget_requires_for_build_editabler6   r   r   r   Ú_get_build_requires_editablea   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;   r9   r   r   r   r*   )r   r   Ú
build_reqsr$   r%   r   r   r   r   k   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>)ÚrequirementrA   Údescription)Úformatr   r.   r1   r   )r   rA   rB   Ú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}.rC   )rH   r%   )rJ   r   r.   r/   r0   r1   r   )r   r%   rK   rL   r   r   r   r    �   s   ÿÿz&SourceDistribution._raise_missing_reqs)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   Úboolr&   r   r   Ústrr9   r;   r   r   r   r   r    r   r   r   r   r      s0    þýü
û'
ÿÿ
þr   )ÚloggingÚtypingr   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
   Ú	getLoggerrM   r,   r   r   r   r   r   Ú<module>   s    
