
    xi                        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
 d dlmZ d dlmZ d d	lmZ erd d
lmZ  ej$                  e      Z G d de
      Zy)    )annotationsN)Iterable)TYPE_CHECKING)BuildEnvironment)AbstractDistribution)InstallationError)BaseDistribution)runner_with_spinner_message)BuildEnvironmentInstallerc                      e Zd ZdZedd       ZddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZddZ	ddZ
	 	 	 	 ddZ	 	 	 	 	 	 dd	Zdd
Zy)SourceDistributionzRepresents a source distribution.

    The preparation step for these needs metadata for the packages to be
    generated.
    c                r    | j                   j                  sJ | j                   j                  j                  S )z/Identify this requirement uniquely by its link.)reqlinkurl_without_fragmentselfs    \/var/www/html/binance/venv/lib/python3.12/site-packages/pip/_internal/distributions/sdist.pybuild_tracker_idz#SourceDistribution.build_tracker_id   s(     xx}}}xx}}111    c                6    | j                   j                         S )N)r   get_distr   s    r   get_metadata_distributionz,SourceDistribution.get_metadata_distribution    s    xx  ""r   c                   | j                   j                          |r=| j                  |       | j                   j                          | j	                  |       n| j                   j                          |ri| j                   j
                  }|J | j                   j                  j                  |      \  }}|r| j                  d|       |r| j                  |       | j                   j                          y )Nthe backend dependencies)r   load_pyproject_toml_prepare_build_backendeditable_sanity_check_install_build_reqspyproject_requires	build_envcheck_requirements_raise_conflicts_raise_missing_reqsprepare_metadata)r   build_env_installerbuild_isolationcheck_build_depsr    conflictingmissings          r   prepare_distribution_metadataz0SourceDistribution.prepare_distribution_metadata#   s     	$$&  ''(;<
 HH**,$$%89 HH**,!%!<!<%111#'88#5#5#H#H"$ K %%&@+N((1!!#r   c                0   | j                   j                  }|J t        |      | j                   _        | j                   j                  j	                  |dd| j                          | j                   j                  j                  | j                   j                        \  }}|r| j                  d|       |r]t        j                  d| j                          t        j                  ddj                  t        t        t        |                         y y )N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    r   r!   install_requirementsr"   requirements_to_checkr#   loggerwarningjoinmapreprsorted)r   r&   r    r)   r*   s        r   r   z)SourceDistribution._prepare_build_backendI   s    
 "XX88!----.AB//	0Ddhh 	0 	
  $xx11DDHH** 
W !!"FTNNF NNASvg78 r   c                &   | j                   j                  5  t        d      }| j                   j                  }|J |j	                  |      5  |j                         cd d d        cd d d        S # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)Nz#Getting requirements to build wheel)r   r!   r
   pep517_backendsubprocess_runnerget_requires_for_build_wheelr   runnerbackends      r   _get_build_requires_wheelz,SourceDistribution._get_build_requires_wheele   s    XX 	>01VWFhh--G&&&**62 >;;=> >		> 	>> > >		> 	> 	>#   7BA1	B1A:	6BBc                &   | j                   j                  5  t        d      }| j                   j                  }|J |j	                  |      5  |j                         cd d d        cd d d        S # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)Nz&Getting requirements to build editable)r   r!   r
   r:   r;   get_requires_for_build_editabler=   s      r   _get_build_requires_editablez/SourceDistribution._get_build_requires_editablem   s    XX 	A08F hh--G&&&**62 A>>@A A	A 	AA A A	A 	A 	ArA   c                   | j                   j                  r=| j                   j                  r'| j                   j                  r| j	                         }n| j                         }| j                   j                  j                  |      \  }}|r| j                  d|       | j                   j                  j                  |dd| j                          y )Nr   normalzbackend dependenciesr.   )
r   editablepermit_editable_wheelssupports_pyproject_editablerD   r@   r!   r"   r#   r1   )r   r&   
build_reqsr)   r*   s        r   r   z&SourceDistribution._install_build_reqsw   s     HH//44::<J779J#xx11DDZPW!!"<kJ//X$:DHH 	0 	
r   c           
         d}|j                  | j                  |dj                  d t        |      D                    }t	        |      )NzZSome build dependencies for {requirement} conflict with {conflicting_with}: {description}., c              3  0   K   | ]  \  }}| d |   yw)z is incompatible with N ).0	installedwanteds      r   	<genexpr>z6SourceDistribution._raise_conflicts.<locals>.<genexpr>   s(      "%Iv +3F8<"s   )requirementconflicting_withdescription)formatr   r5   r8   r   )r   rT   conflicting_reqsformat_stringerror_messages        r   r#   z#SourceDistribution._raise_conflicts   sY    ? 	 &,,-		 ")/0@)A"  - 
  ..r   c                    d}|j                  | j                  dj                  t        t        t        |                        }t        |      )NzASome build dependencies for {requirement} are missing: {missing}.rL   )rS   r*   )rV   r   r5   r6   r7   r8   r   )r   r*   rX   rY   s       r   r$   z&SourceDistribution._raise_missing_reqs   sK    O 	 &,,$))CfWo4N*O - 
  ..r   N)returnz
str | None)r[   r	   )r&   r   r'   boolr(   r\   r[   None)r&   r   r[   r]   )r[   zIterable[str])rT   strrW   zset[tuple[str, str]]r[   r]   )r*   zset[str]r[   r]   )__name__
__module____qualname____doc__propertyr   r   r+   r   r@   rD   r   r#   r$   rN   r   r   r   r      s     2 2
#$$6$$ $$ 	$$
 
$$L#<	8>A
#<
	
*/ #/7K/	/"/r   r   )
__future__r   loggingcollections.abcr   typingr   pip._internal.build_envr    pip._internal.distributions.baser   pip._internal.exceptionsr   pip._internal.metadatar	   pip._internal.utils.subprocessr
   r   	getLoggerr_   r3   r   rN   r   r   <module>rn      sG    "  $   4 A 6 3 FA			8	$Q/- Q/r   