o
    8)i$                     @  s   d dl mZ d dl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lmZ d dlmZ d)d*ddZd+ddZd,ddZd-ddZd-ddZd.d!d"Zd/d#d$Zd0d%d&Zd0d'd(ZdS )1    )annotationsN)Path)Any)Configuration)
find_files)_get_version)walk_potential_rootsargslist[str] | Nonereturnintc              
   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yP } ztdtj| d| dtjd t|d}W Y d }~nd }~ww |jrWd}nt||jd}|d u rgtd||jrq|d	d
 }t|||S )N.)rootzWarning: could not use z(, using default configuration.
 Reason: filez+0.0.0+no-version-was-requested.fake-version)force_write_version_fileszERROR: no version found forz.devr   )_get_cli_optsr   config_find_pyprojectr   	from_fileospathabspathLookupErrorFileNotFoundErrorprintrelpathsysstderr
no_versionr   r   
SystemExitZ	strip_dev	partitioncommand)r	   optsZinferred_root	pyprojectr   exversion r'   N/home/app/PyTorch/.pytorch/lib/python3.10/site-packages/setuptools_scm/_cli.pymain   s8   



r)   argparse.Namespacec           	      C  sJ  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 g d}|jddtjdd|d |jddtjddd |jddd d |jd!d"d#d$}d%}|jd&|d'  |d(d   |d) d*}|jd+|d'  |d(d   |d)}|jd,d-}|jd.dd/d |jd0dd1d |jd2dd3d |	| S )4Nz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-Nz--no-versionz,do not include package version in the output)jsonplain	key-valuez-fz--formatr3   zspecify output format)typer,   r-   choicesz-qz--query*zdisplay setuptools-scm settings according to query, e.g. dist_name, do not supply an argument in order to print a list of valid queries.)r5   nargsr-   z--force-write-version-fileszntrigger to write the content of the version files
its recommended to use normal/editable installation instead)zextra commandsr"    )titledestr/   z7List information about the package, e.g. included fileslsr      )r-   r+   z5Create .git_archival.txt file for git archive supportcreate-archival-fileT)requiredz--stablez:create stable archival file (recommended, no branch names)z--fullzIcreate full archival file with branch information (can cause instability)z--forcez)overwrite existing .git_archival.txt file)
argparseArgumentParseradd_argumentstrcasefoldadd_subparsers
add_parserloweradd_mutually_exclusive_group
parse_args)	r	   progZdescparserZoutput_formatssubZarchival_descZarchival_parserZarchival_groupr'   r'   r(   r   4   s   	$
r   r#   r&   rC   r   r   c              	   C  s:  i }| j dkrdg| _| j dkrt| |S | jg kr/d| _tjd dg| _dg|j|d< | jd u r7g | _| js>||d< d| jv rJt|j	|d< | jD ]-}|dv rTqMz|
d	r]t t||||< W qM tyz   tjd
| d Y  dS w | jdkrttj|dd | jdkrt| | jdkrt| dS )Nr<   filesr>   TzAvailable queries:

queriesr&   )rM   rN   r&   _zError: unknown query: 'z'
r=   r2      )indentr3   r4   r   )r"   query_create_archival_filer   r   r   write__dataclass_fields__r   r   
startswithAttributeErrorgetattrformatr   r2   dumps_print_plain_print_key_value)r#   r&   r   dataqr'   r'   r(   r"      sD   










r"   r]   dict[str, Any]Nonec                 C  sr   |  dd }|rt| |  dg }|D ]}t| q|  dg }|D ]}t| q#| r7td|   d S d S )Nr&   rM   rN   
)popr   joinvalues)r]   r&   rM   file_rN   rR   r'   r'   r(   r[      s   

r[   c                 C  sP   |   D ]!\}}t|trt| d|  qd|}t| d|  qd S )Nz = z
  )items
isinstancerC   r   rc   )r]   keyvalueZ	str_valuer'   r'   r(   r\      s   

r\   parentc                 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   rc   isfile)rj   	directoryr$   r'   r'   r(   r      s   r   c              
   C  sZ  t |jd}| r| jstd| dtjd dS | jr%t }td n| j	r3t
 }td td zY|j|d	d
 td|  t |jd}d}| r]|d	}d|v r]d|v r]d}|rztd td td td td td W dS td td td td W dS  ty } ztd| d| tjd W Y d}~dS d}~ww )z7Create .git_archival.txt file with appropriate content.z.git_archival.txtzError: z* already exists. Use --force to overwrite.r   r=   z<Creating stable .git_archival.txt (recommended for releases)z7Creating full .git_archival.txt with branch informationz9WARNING: This can cause archive checksums to be unstable!zutf-8)encodingz	Created: z.gitattributesTzexport-substFz
Next steps:z#1. Add this line to .gitattributes:z"   .git_archival.txt  export-substz2. Commit both files:z+   git add .git_archival.txt .gitattributesz*   git commit -m 'add git archive support'z
Next step:zCommit the archival file:z   git add .git_archival.txtz+   git commit -m 'update git archival file'r   zError: Could not create z: N)r   r   existsforcer   r   r   Zstable_get_stable_archival_contentfull_get_full_archival_content
write_text	read_textOSError)r#   r   Zarchival_pathcontentZgitattributes_pathZneeds_gitattributesZgitattributes_contenter'   r'   r(   rS      sT   


rS   c                   C     dS )z8Generate stable archival file content (no branch names).zfnode: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
r'   r'   r'   r'   r(   rp        rp   c                   C  rx   )z<Generate full archival file content with branch information.a  # WARNING: Including ref-names can make archive checksums unstable
# after commits are added post-release. Use only if describe-name is insufficient.
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
r'   r'   r'   r'   r(   rr     ry   rr   )N)r	   r
   r   r   )r	   r
   r   r*   )r#   r*   r&   rC   r   r   r   r   )r]   r_   r   r`   )rj   rC   r   rC   )r#   r*   r   r   r   r   )r   rC   )
__future__r   r@   r2   r   r   pathlibr   typingr   Zsetuptools_scmr   Zsetuptools_scm._file_findersr   Z setuptools_scm._get_version_implr   Zsetuptools_scm.discoverr   r)   r   r"   r[   r\   r   rS   rp   rr   r'   r'   r'   r(   <module>   s(    
#
T
0

	

7	