o
    b                     @  sx   d dl mZ d dlZd dl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ddZdddZdddZdS )    )annotationsN)_get_version)Configuration)walk_potential_roots)
find_filesargslist[str] | NonereturnNonec              
   C  s   t | }|jpd}|jpt|}ztj||jd ur tj|jnd d}W n* t	t
fyO } ztdtj| d| dtjd t|}W Y d }~nd }~ww t|}|d u r]td||jrg|dd }t| |jd	kr|t|jD ]}t| qud S d S )
N.)rootzWarning: could not use z(, using default configuration.
 Reason: )filezERROR: no version found forz.devr   ls)_get_cli_optsr   config_find_pyprojectr   	from_fileospathabspathLookupErrorFileNotFoundErrorprintrelpathsysstderrr   
SystemExitZ	strip_dev	partitioncommandr   )r   optsZinferred_root	pyprojectr   exversionfname r$   7usr/lib/python3.10/site-packages/setuptools_scm/_cli.pymain   s:   





r&   argparse.Namespacec                 C  s   d}d}t j||d}|jddd dd |jdd	d d
dd |jdddd |jdddd}d}|jd|d  |dd   |d || S )Nzpython -m setuptools_scmz/Print project version according to SCM metadata)descriptionz-rz--rootzHdirectory managed by the SCM, default: inferred from config file, or ".")defaulthelpz-cz--configPATHzlpath to 'pyproject.toml' with setuptools_scm config, default: looked up in the current or parent directories)r)   metavarr*   z--strip-dev
store_truezEremove the dev/local parts of the version before printing the version)actionr*   zextra commandsr    )titledestr,   zList files managed by the SCMr   r      )r*   r(   )argparseArgumentParseradd_argumentZadd_subparsersZ
add_parserlower
parse_args)r   progdescparsersubr$   r$   r%   r   /   s2   $
r   parentstrc                 C  sD   t tj| D ]}tj|d}tj|r|  S qtjdS )Nzpyproject.toml)r   r   r   r   joinisfile)r<   	directoryr    r$   r$   r%   r   N   s   r   )N)r   r   r	   r
   )r   r   r	   r'   )r<   r=   r	   r=   )
__future__r   r3   r   r   setuptools_scmr   setuptools_scm.configr   Zsetuptools_scm.discoverr   Zsetuptools_scm.integrationr   r&   r   r   r$   r$   r$   r%   <module>   s    
"