o
    8)i                     @  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 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rBddl
mZ ejdZd"d#ddZd$ddZdhZd%d d!ZdS )&    )annotationsN)Path)TYPE_CHECKING)Iterable)Iterator   )_entrypoints)_log)_types)Configuration)imZdiscoverTroot_t.PathTsearch_parentsboolreturnIterator[Path]c                 c  s(    t | } | V  |r| jE dH  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)r   parents)r   r    r   R/home/app/PyTorch/.pytorch/lib/python3.10/site-packages/setuptools_scm/discover.pywalk_potential_roots   s   r   namestrc                 C  s6   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 ep %sF)ospathexistsjoinisabslogdebug)r   r   r   r   r   match_entrypoint"   s
   r    z setuptools_scm_git_archive:parse
entrypointconfigr   Iterable[im.EntryPoint]c                 c  sj    t d||  t| |jD ]$}tj|dD ]}|jtv rqt||j	r1t 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 ep %s in %s)groupzfound ep %s in %sN)r   r   r   Zsearch_parent_directoriesr   Zentry_pointsvalue_BLOCKED_EP_TARGETSr    r   parent)r   r!   r"   wdepr   r   r   iter_matching_entrypoints6   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   pathlibr   typingr   r   r    r   r	   r
   Z_t_configr   r   r   getChildr   r    r&   r*   r   r   r   r   <module>   s"    
