o
    )i                     @   sn   d dl Z d dlZd dlZd dlZdZejejeje	Z
dd Zdd Zdd Zed	kr5e  dS dS )
    Nz0.1.21c                 C   s
   |  dS )Nzutf-8)decode)Zcstr r   \/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/xgrammar/version.pypy_str   s   
r   c                  C   sB  g d} t j| t jt jtd}| \}}W d   n1 s w   Y  |jdkr6t|}t	d| dS t|
 }|d}|d drR|d d	d |d< t|d	kr`|d |d fS t|d
krnt	d| dS |d d}|dkr|d d|d d }n|d }| d|d	  }	|	 d|d  }
|	|
fS )a}  Get PEP-440 compatible public and local version using git describe.

    Returns
    -------
    pub_ver: str
        Public version.

    local_ver: str
        Local version (with additional label appended to pub_ver).

    Notes
    -----
    - We follow PEP 440's convention of public version
      and local versions.
    - Only tags conforming to vMAJOR.MINOR.REV (e.g. "v0.7.0")
      are considered in order to generate the version string.
      See the use of `--match` in the `git` command below.

    Here are some examples:

    - pub_ver = '0.7.0', local_ver = '0.7.0':
      We are at the 0.7.0 release.
    - pub_ver =  '0.8.dev94', local_ver = '0.8.dev94+g0d07a329e':
      We are at the 0.8 development cycle.
      The current source contains 94 additional commits
      after the most recent tag(v0.7.0),
      the git short hash tag of the current commit is 0d07a329e.
    )gitdescribez--tags--matchzv[0-9]*.[0-9]*.[0-9]*r   zv[0-9]*.[0-9]*.dev[0-9]*)stdoutstderrcwdNr   zgit describe: %sNN-v      z#Invalid output from git describe %sz.dev+   )
subprocessPopenPIPESTDOUT	PROJ_ROOTcommunicate
returncoder   loggingwarningstripsplit
startswithlenfind)cmdprocout_msgr   Zarr_infoZdev_posZdev_versionpub_ver	local_verr   r   r   git_describe_version   s6   	

r)   c                  C   s   t jt jd tjdd} | jdddd | jddd	d | jd
dd |  }d\}}|jr4t \}}|d u r:t	}|d u r@t	}|j
rIt| d S d S )N)levelzDetect and synchronize version.)descriptionz--print-version
store_truezBPrint version to the command line. No changes is applied to files.)actionhelpz--git-describez1Use git describe to generate development version.z	--dry-run)r-   r   )r   basicConfigINFOargparseArgumentParseradd_argument
parse_argsZgit_describer)   __version__print_versionprint)parseroptr'   r(   r   r   r   mainr   s0   
r:   __main__)r1   r   osr   r5   pathdirnameabspath
expanduser__file__r   r   r)   r:   __name__r   r   r   r   <module>   s   S
