
    7f                        d Z ddlmZ ddlZddlmZ ddlm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  ed          Ze	edf         ZeZej        ZddZddZd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
    )annotationsN)defaultdict)filterfalse)DictMappingTypeVar   )_reqs)yield_lines)Requirement_Tinstall_requires
_StrOrIterextras_requireMapping[str, _StrOrIter]return&tuple[list[str], dict[str, list[str]]]c                @    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      ]/home/feoh/.local/pipx/shared/lib/python3.11/site-packages/setuptools/command/_requirestxt.py_preparer      s"     *.99F-.>GGG    #Mapping[str, _Ordered[Requirement]]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>R   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>P   sn         Aq 
DBBs:q/A/ABBBBBCCD     r   )r.   r
   r   filter
_no_markerr   r0   r+   markerr!   r   r   )r   r   	inst_reqssimple_reqscomplex_reqssimple_install_requiresr%   expanded_extrass           r   r   r   9   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'    )r5   r+   reqs    r   r    r    Y   s!    $'J63SZ  B6r   c                L    t          t          |                     }d|_        |S )z=Given a Requirement, remove environment markers and return itN)r   r+   r5   )r>   r%   s     r   r1   r1   ^   s!    CHHAAHHr   c                    | j          S r*   )r5   r=   s    r   r4   r4   e   s    z>r   c                x    t          |pd          }d }t          ||          }|                     |           d S )N c                    | dz   S )N
rB   )lines    r   	append_crz&_write_requirements.<locals>.append_crl   s    d{r   )r   r0   
writelines)streamreqslinesrF   s       r   _write_requirementsrK   i   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 )NrB   z
[{extra}]
requirements)distributionioStringIOr   r   r   rK   sortedwriteformatvarswrite_or_delete_filegetvalue)cmdbasenamefilenamedistdatar   r   extras           r   write_requirementsr]   s   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)rO   rP   rK   rN   setup_requiresrU   rV   )rW   rX   rY   r[   s       r   write_setup_requirementsr`      sJ    ;==Dc.=>>>18T]]__MMMMMr   )r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   ) __doc__
__future__r   rO   collectionsr   	itertoolsr   typingr   r   r   r<   r
   jaraco.textr   packaging.requirementsr   r   _Orderedr   _orderedr   r   r   r   r    r1   r4   rK   r]   r`   rB   r   r   <module>rj      sz    # " " " " " 				 # # # # # # ! ! ! ! ! ! ) ) ) ) ) ) ) ) ) )       # # # # # # . . . . . . WT]]D>
H H H H   $4 4 4 4@7 7 7
      
H 
H 
HN N N N Nr   