
    )h_                         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rd dlmZ  e j&                  e      Z G d	 d
e
      Zy)    N)TYPE_CHECKINGIterableOptionalSetTuple)BuildEnvironment)AbstractDistribution)InstallationError)BaseDistribution)runner_with_spinner_message)PackageFinderc                       e Zd ZdZedee   fd       ZdefdZ	ddde
de
dd	fd
ZddZdee   fdZdee   fdZddZdedeeeef      dd	fdZdee   dd	fdZy	)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                 r    | j                   j                  sJ | j                   j                  j                  S )z/Identify this requirement uniquely by its link.)reqlinkurl_without_fragmentselfs    T/var/www/html/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   finderr   build_isolationcheck_build_depsNc                 &   | j                   j                          | j                   j                  xr |}|r<| j                  |       | j                   j	                          | j                  |       | j                   j                  xr |}|ri| j                   j                  }|J | j                   j                  j                  |      \  }}|r| j                  d|       |r| j                  |       | j                   j                          y )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missings	            r   prepare_distribution_metadataz0SourceDistribution.prepare_distribution_metadata    s     	$$& ,,@ ''/ HH335$$V, HH//D4D!%!<!<%111#'88#5#5#H#H"$ K %%&@+N((1!!#r   c                    | j                   j                  }|J t               | j                   _        | j                   j                  j	                  ||dd       | 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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/   r0   s        r   r$   z)SourceDistribution._prepare_build_backendG   s     "XX88!----///&	8L 	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_wheela   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_editablerB   s      r   _get_build_requires_editablez/SourceDistribution._get_build_requires_editablei   s    XX 	A08F hh--G&&&**62 A>>@A A	A 	AA A A	A 	A 	ArF   c                    | j                   j                  r=| j                   j                  r'| j                   j                  r| j	                         }n| j                         }| j                   j                  j                  |      \  }}|r| j                  d|       | j                   j                  j                  ||dd       y )Nr!   normalzbackend dependenciesr4   )
r   editablepermit_editable_wheelssupports_pyproject_editablerI   rE   r(   r)   r*   r6   )r   r   
build_reqsr/   r0   s        r   r&   z&SourceDistribution._install_build_reqss   s    
 HH//44::<J779J#xx11DDZPW!!"<kJ//GX,B 	0 	
r   conflicting_withconflicting_reqsc           
          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   )requirementrP   description)formatr   r:   r=   r
   )r   rP   rQ   format_stringerror_messages        r   r*   z#SourceDistribution._raise_conflicts   sY    ? 	 &,,-		 ")/0@)A"  - 
  ..r   r0   c                     d}|j                  | j                  dj                  t        t        t        |                        }t        |      )NzASome build dependencies for {requirement} are missing: {missing}.rS   )rZ   r0   )r\   r   r:   r;   r<   r=   r
   )r   r0   r]   r^   s       r   r+   z&SourceDistribution._raise_missing_reqs   sK    O 	 &,,$))CfWo4N*O - 
  ..r   )r   r   r   N)__name__
__module____qualname____doc__propertyr   strr   r   r   boolr1   r$   r   rE   rI   r&   r   r   r*   r+   rU   r   r   r   r      s     2(3- 2 2
#+; #%$%$ %$ 	%$
 
%$N4>8C= >Ahsm A
&/ #/7:5c?7K/	/"/3s8 / /r   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   	getLoggerr`   r8   r   rU   r   r   <module>rp      sD     @ @ 4 A 6 3 F@			8	$N/- N/r   