o
    LK&h                     @  s   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dZd)ddZd*ddZdd Zdd Zd d! Zd"d# Zd$d% Zd&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                 C  s   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   extras r   R/var/www/html/venv/lib/python3.10/site-packages/setuptools/command/_requirestxt.py_prepare   s   
r   'defaultdict[str, _Ordered[Requirement]]c                 C  sX   t ttt f t}|  D ]\}}||  t|D ]}||t|  	| qq|S )z
    Convert requirements in `extras_require` of the form
    `"extra": ["barbazquux; {marker}"]` to
    `"extra:{marker}": ["barbazquux"]`.
    )
r   str_Orderedr   dictitemsr
   parse_suffix_for
setdefault)r   outputsectionvrr   r   r   r   '   s   r   #Mapping[str, _Ordered[Requirement]]c                 C  sp   t t| }tt|}tt|}t tt|}|D ]}|dt|j  	| qt
d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              	   s  s6    | ]\}}|t td d tt|D fV  qdS )c                 s  s    | ]}t |V  qd S N)r   ).0r#   r   r   r   	<genexpr>R   s    z?_move_install_requirements_markers.<locals>.<genexpr>.<genexpr>N)listr   fromkeysmap
_clean_req)r'   kr"   r   r   r   r(   P   s
     
z5_move_install_requirements_markers.<locals>.<genexpr>)r)   r
   r   filter
_no_markerr   r+   r   markerr   r   r   )r   r   	inst_reqssimple_reqscomplex_reqssimple_install_requiresr#   expanded_extrasr   r   r   r   9   s   

r   c                 C  s   | j r
dt| j  S dS )z;Return the 'extras_require' suffix for a given requirement.r%    )r0   r   reqr   r   r   r   Y   s   r   c                 C  s   t t| }d|_|S )z=Given a Requirement, remove environment markers and return itN)r   r   r0   )r8   r#   r   r   r   r,   ^   s   r,   c                 C  s   | j  S r&   )r0   r7   r   r   r   r/   e      r/   c                 C  s,   t |pd}dd }t||}| | d S )Nr   c                 S  s   | d S )N
r   )liner   r   r   	append_crl   r9   z&_write_requirements.<locals>.append_cr)r   r+   
writelines)streamreqslinesr<   r   r   r   _write_requirementsi   s   
rA   c                 C  s|   | j }t }t|jpd|jpi \}}t|| t|D ]}|dj	di t
  t|||  q| d||  d S )Nr   z
[{extra}]
requirements)distributionioStringIOr   r   r   rA   sortedwriteformatvarswrite_or_delete_filegetvalue)cmdbasenamefilenamedistdatar   r   extrar   r   r   write_requirementss   s   
rR   c                 C  s,   t  }t|| jj | d||  d S )Nzsetup-requirements)rD   rE   rA   rC   setup_requiresrJ   rK   )rL   rM   rN   rP   r   r   r   write_setup_requirements   s   rT   )r   r   r   r   r   r   )r   r   r   r   )r   r   r   r$   r   r   )__doc__
__future__r   rD   collectionsr   collections.abcr   	itertoolsr   typingr   jaraco.textr   packaging.requirementsr   r6   r
   r   r   r   r   r   r   r   r   r,   r/   rA   rR   rT   r   r   r   r   <module>   s,    	



 
