
    ϶vg                        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	 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d          Zeedf         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)Mapping)filterfalse)TypeVar)yield_lines)Requirement   )_reqs)
_StrOrIter_Tinstall_requiresr   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      \/var/www/pixelcanvas.ch/venv/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   r/   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&    )r4   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*   r4   )r=   r$   s     r   r0   r0   ^   s!    CHHAAHHr   c                    | j          S r)   )r4   r<   s    r   r3   r3   e   s    z>r   c                x    t          |pd          }d }t          ||          }|                     |           d S )N c                    | dz   S )N
rA   )lines    r   	append_crz&_write_requirements.<locals>.append_crl   s    d{r   )r   r/   
writelines)streamreqslinesrE   s       r   _write_requirementsrJ   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 )NrA   z
[{extra}]
requirements)distributionioStringIOr   r   r   rJ   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)rN   rO   rJ   rM   setup_requiresrT   rU   )rV   rW   rX   rZ   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   rN   collectionsr   collections.abcr   	itertoolsr   typingr   jaraco.textr   packaging.requirementsr	   r;   r   r   r   r   _Orderedr   r   r   r   r0   r3   rJ   r\   r_   rA   r   r   <module>ri      s    # " " " " " 				 # # # # # # # # # # # # ! ! ! ! ! !       # # # # # # . . . . . .             WT]]D>H H H H   $4 4 4 4@7 7 7
      
H 
H 
HN N N N Nr   