
    Gui                        d Z ddlZddlZddlmZ ddlmZmZmZm	Z	 ddl
mZ  e	de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      ZdedefdZdedefdZdee   deeddf   fdZdedefdZeeefZy)zThe purpose of this module is implement PEP 621 validations that are
difficult to express as a JSON Schema (or that are not supported by the current
JSON Schema library).
    N)cleandoc)	GeneratorIterableMappingTypeVar   )ValidationErrorT)boundc                       e Zd ZdZeZdZy)RedefiningStaticFieldAsDynamiczAccording to PEP 621:

    Build back-ends MUST raise an error if the metadata specifies a field
    statically as well as being listed in dynamic.
    zMhttps://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamicN__name__
__module____qualname___DESC__doc___URL     i/opt/pipecat/venv/lib/python3.12/site-packages/setuptools/config/_validate_pyproject/extra_validations.pyr   r      s    E
 GW 	r   r   c                       e Zd ZdZeZdZy) IncludedDependencyGroupMustExistzDAn included dependency group must exist and must not be cyclic.
    z!https://peps.python.org/pep-0735/Nr   r   r   r   r   r      s    EG.Dr   r   c                       e Zd ZdZeZdZy)ImportNameCollisionz\According to PEP 794:

    All import-names and import-namespaces items must be unique.
    !https://peps.python.org/pep-0794/Nr   r   r   r   r   r   #       E G.Dr   r   c                       e Zd ZdZeZdZy)ImportNameMissingzLAccording to PEP 794:

    An import name must have all parents listed.
    r   Nr   r   r   r   r   r   ,   r   r   r   	pyprojectreturnc           
          | j                  di       }|j                  dg       }|D ]N  }||v st        d| d|||   ddd|id| t        t        j                        t        j                  dd	
       | S )Nprojectdynamicz(You cannot provide a value for `project.z6` and list it under `project.dynamic` at the same timez...z # ...zdata.project.descriptionseezPEP 621messagevaluename
definitionrule)getr   r   r   r   )r    project_tabler$   fields       r   validate_project_dynamicr1   5   s    MM)R0M	2.G M!0B5' JC C =/8w
 %UG,#+,J,P,P#Q9>>  $ r   c           
      8   | j                  di       }|j                         D ]t  \  }}|D ]j  }t        |t              s|j                  d      x}s(||vs-t	        d| d|d| t        t        j                        t        j                  dd       v | S )	Nzdependency-groupszinclude-groupzThe included dependency group z doesn't existzdata.dependency_groups.r%   zPEP 735r(   )r.   items
isinstancedictr   r   r   r   )r    dependency_groupskeyr*   eachinclude_groups         r   validate_include_depenencyr:   N   s    !&92>'--/ 
U 	D4&&*hh&??]?!)::6<]O>Z23%8'/0P0V0V'W?DD  #	 		$ r   r3   c              #   b   K   | D ]&  }|j                  d      d   j                          ( y w)N;r   )	partitionrstrip)r3   items     r   _remove_privater@   e   s2      .nnS!!$++--.s   -/c           
         | j                  di       }t        j                  t        |j                  dg                   }t        j                  t        |j                  dg                   }||z   j	                         D cg c]  \  }}|dkD  s| }}}|r8t        d|dt        t
        j                        t
        j                  dd	      t        ||z         }|D ]l  }t        j                  |j                  d
      d d d       D ]>  }	|	|vst        d|dt        t        j                        t        j                  dd	       n | S c c}}w )Nr#   zimport-nameszimport-namespacesr   zBDuplicated names are not allowed in import-names/import-namespaceszdata.project.importnames(paces)r%   zPEP 794r(   .c                     |  d| S )NrB   r   )abs     r   <lambda>z-validate_import_name_issues.<locals>.<lambda>   s    !AaSz r   zRAll parents of an import name must also be listed in import-namespace/import-names)r.   collectionsCounterr@   r3   r   r   r   r   	frozenset	itertools
accumulatesplitr   )
r    r#   import_namesimport_namespaceskv
duplicatednamesr+   parents
             r   validate_import_name_issuesrU   j   sb   mmIr*G&&w{{>SU7V'WXL#++$7<= ".0A!A H H JT1aRSe!TJT!X2'(;(A(AB*// 	
 		
 l%667E **JJsOCR "9
 	F U"'p:'/0A0G0G'H055  #	 			  ? Us   EE)r   rH   rK   inspectr   typingr   r   r   r   error_reportingr	   r
   r   r   r   r   r1   r:   strr@   rU   EXTRA_VALIDATIONSr   r   r   <module>r[      s   
    8 8 ,Cw	_ 	/ /// // / a 2!  ..8C= .YsD$-G .
&1 & &T  r   