o
    bK                     @  s   d dl mZ d dlZd dlmZ d dlmZ d dlmZ er$ddlmZ	 ddl
mZ dd	lmZ 	
ddddZdddZd ddZdS )!    )annotationsN)Iterable)Iterator)TYPE_CHECKING   )_types)Configuration)traceTroot_t.PathTsearch_parentsboolreturnIterator[_t.PathT]c                 c  s:    |s| V  dS | }|r| V  t j| \} }|sdS dS )z
    Iterate though a path and each of its parents.
    :param root: File path.
    :param search_parents: If ``False`` the parents are not considered.
    N)ospathsplit)r
   r   tail r   ;usr/lib/python3.10/site-packages/setuptools_scm/discover.pywalk_potential_roots   s   	r   namestrc                 C  s4   t jt j| |rt j|sdS td| dS )z
    Consider a ``root`` as entry-point.
    :param root: File path.
    :param name: Subdirectory name.
    :return: ``True`` if a subdirectory ``name`` exits in ``root``.
    Tzignoring bad epF)r   r   existsjoinisabsr	   )r
   r   r   r   r   match_entrypoint"   s
   
r   
entrypointconfigr   Iterable[_t.EntrypointProtocol]c                 c  sd    t d||  ddlm} t| |jD ]}||D ]}t||jr.t d|d| ||_|V  qqdS )a  
    Consider different entry-points in ``root`` and optionally its parents.
    :param root: File path.
    :param entrypoint: Entry-point to consider.
    :param config: Configuration,
        read ``search_parent_directories``, write found parent to ``parent``.
    zlooking for epr   )iter_entry_pointszfound epinN)r	   _entrypointsr    r   search_parent_directoriesr   r   parent)r
   r   r   r    wdepr   r   r   iter_matching_entrypoints2   s   r'   )T)r
   r   r   r   r   r   )r
   r   r   r   r   r   )r
   r   r   r   r   r   r   r   )
__future__r   r   typingr   r   r    r   Z_tr   r   utilsr	   r   r   r'   r   r   r   r   <module>   s    
