o
    ¡K&bê  ã                   @   s:   d Z ddlZddlmZmZ dZdZdZdi fdd„Z	dS )	z”
Version determination functions

These are in their own file so they can be imported by setup.py before we have
any of our dependencies installed.
é    N)Ú
exceptionsÚutilz27.7z27.7~22.04.1z{version}{feature_suffix}c           	      C   sæ   d}t | ¡ ƒD ]\}}|dj|rdnd|d7 }qt d¡s&tjt|dS tj tj t	¡¡}tj 
tj |d¡¡rlg d	¢}zt |¡\}}| ¡ | W S  tjyk   g d
¢}t |¡\}}tj| ¡ |d Y S w tjt|dS )a$  Return the packaged version as a string

         Prefer the binary PACKAGED_VESION set by debian/rules to DEB_VERSION.
         If unavailable, check for a .git development environments:
           a. If run in our upstream repo `git describe` will gives a leading
              XX.Y so return the --long version to allow daily build recipes
              to count commit offset from upstream's XX.Y signed tag.
           b. If run in a git-ubuntu pkg repo, upstream tags aren't visible,
              parse the debian/changelog in that case
    Ú z {enabled}{name}ú+ú-)ÚenabledÚnamez@@PACKAGED_VERSION)ÚversionÚfeature_suffixz.git)ZgitZdescribez
--abbrev=8z--match=[0-9]*z--long)zdpkg-parsechangelogz-Sr	   )ÚsortedÚitemsÚformatÚPACKAGED_VERSIONÚ
startswithÚVERSION_TMPLÚosÚpathÚdirnameÚ__file__ÚexistsÚjoinr   ZsubpÚstripr   ZProcessExecutionErrorÚ__VERSION__)	Z_argsZfeaturesr
   ÚkeyÚvalueZtopdirÚcmdÚoutÚ_© r   ú2/usr/lib/python3/dist-packages/uaclient/version.pyÚget_version   s2   
ÿ
ÿ
ÿûÿr    )
Ú__doc__Úos.pathr   Zuaclientr   r   r   r   r   r    r   r   r   r   Ú<module>   s    