
    $wLf~                        d Z ddlZddlmZ ddlm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  ed
          Zeedf         ZeZej        Zdede
eef         de	ee         eeee         f         f         fdZde
eef         de
eee         f         fdZdede
eee         f         de	ee         eeee         f         f         fdZd Zd Zd Zd Zd Zd Z dS )aS  Helper code used to generate ``requires.txt`` files in the egg-info directory.

The ``requires.txt`` file has an specific format:
    - Environment markers need to be part of the section headers and
      should not be part of the requirement spec itself.

See https://setuptools.pypa.io/en/latest/deprecated/python_eggs.html#requires-txt
    N)defaultdict)filterfalse)DictListTupleMappingTypeVar   )_reqs)yield_lines)Requirement_Tinstall_requiresextras_requirereturnc                 @    t          |          }t          | |          S )zGiven values for ``install_requires`` and ``extras_require``
    create modified versions in a way that can be written in ``requires.txt``
    )_convert_extras_requirements"_move_install_requirements_markers)r   r   extrass      ?lib/python3.11/site-packages/setuptools/command/_requirestxt.py_preparer      s"     *.99F-.>GGG    c                     t          t                    }|                                 D ]O\  }}||          t          j        |          D ]-}||t          |          z                                |           .P|S )z
    Convert requirements in `extras_require` of the form
    `"extra": ["barbazquux; {marker}"]` to
    `"extra:{marker}": ["barbazquux"]`.
    )r   dictitemsr   parse_suffix_for
setdefault)r   outputsectionvrs        r   r   r   %   s     3>d2C2CF$**,, ; ;
wQ 	; 	;A7[^^+,77::::	; Mr   c                    t          t          j        |                     }t          t          |          }t          t          |          }t          t          t          |                    }|D ]2}|dt          |j                  z            	                    |           3t          d |                                D                       }||fS )a+  
    The ``requires.txt`` file has an specific format:
        - Environment markers need to be part of the section headers and
          should not be part of the requirement spec itself.

    Move requirements in ``install_requires`` that are using environment
    markers ``extras_require``.
    :c              3      K   | ]M\  }}|t          t                              d  t          t          |          D                                 fV  NdS )c              3   4   K   | ]}t          |          V  d S N)str).0r"   s     r   	<genexpr>z?_move_install_requirements_markers.<locals>.<genexpr>.<genexpr>P   s(      BB!s1vvBBBBBBr   N)listr   fromkeysmap
_clean_req)r)   kr!   s      r   r*   z5_move_install_requirements_markers.<locals>.<genexpr>N   sn         Aq 
DBBs:q/A/ABBBBBCCD     r   )r+   r   r   filter
_no_markerr   r-   r(   markerr   r   r   )r   r   	inst_reqssimple_reqscomplex_reqssimple_install_requiresr"   expanded_extrass           r   r   r   7   s     U[!12233IY//Kz955L"3sK#8#899 : :sS]]*+66q9999   #((**    O #O33r   c                 B    | j         rdt          | j                   z   ndS )z;Return the 'extras_require' suffix for a given requirement.r$    )r2   r(   reqs    r   r   r   W   s!    $'J63SZ  B6r   c                 L    t          t          |                     }d|_        |S )z=Given a Requirement, remove environment markers and return itN)r   r(   r2   )r;   r"   s     r   r.   r.   \   s!    CHHAAHHr   c                     | j          S r'   )r2   r:   s    r   r1   r1   c   s    z>r   c                 x    t          |pd          }d }t          ||          }|                     |           d S )N c                     | dz   S )N
r?   )lines    r   	append_crz&_write_requirements.<locals>.append_crj   s    d{r   )r   r-   
writelines)streamreqslinesrC   s       r   _write_requirementsrH   g   sM    
##E   	5!!E
er   c           	         | j         }t          j                    }t          |j        pd|j        pi           \  }}t          ||           t          |          D ]D}|                     dj	        di t                                 t          |||                    E|                     d||                                           d S )Nr?   z
[{extra}]
requirements)distributionioStringIOr   r   r   rH   sortedwriteformatvarswrite_or_delete_filegetvalue)cmdbasenamefilenamedistdatar   r   extras           r   write_requirementsrZ   q   s    D;==D'/#T%8%>B( ($n .///'' 9 9

)?)33DFF33444D."78888^Xt}}GGGGGr   c                     t          j                    }t          || j        j                   |                     d||                                           d S )Nzsetup-requirements)rL   rM   rH   rK   setup_requiresrR   rS   )rT   rU   rV   rX   s       r   write_setup_requirementsr]   ~   sJ    ;==Dc.=>>>18T]]__MMMMMr   )!__doc__rL   collectionsr   	itertoolsr   typingr   r   r   r   r	   r9   r   extern.jaraco.textr   extern.packaging.requirementsr   r   _Orderedr   _ordered
_StrOrIterr(   r   r   r   r   r.   r1   rH   rZ   r]   r?   r   r   <module>rg      s    
			 # # # # # # ! ! ! ! ! ! 6 6 6 6 6 6 6 6 6 6 6 6 6 6       , , , , , , 7 7 7 7 7 7 WT]]D>
H H29#z/2JH
49d3S	>**+H H H HCO,S(;''(   $4 429#x?T:T2U4
49d3S	>**+4 4 4 4@7 7 7
      
H 
H 
HN N N N Nr   