|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""OpTree: Optimized PyTree Utilities.""" |
|
|
|
|
|
|
|
|
|
|
|
__version__ = '0.16.0' |
|
|
__license__ = 'Apache-2.0' |
|
|
__author__ = 'OpTree Contributors' |
|
|
__release__ = True |
|
|
|
|
|
if not __release__: |
|
|
import os |
|
|
import subprocess |
|
|
|
|
|
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
|
|
try: |
|
|
prefix, sep, suffix = ( |
|
|
subprocess.check_output( |
|
|
[ |
|
|
'git', |
|
|
f'--git-dir={os.path.join(root_dir, ".git")}', |
|
|
'describe', |
|
|
'--abbrev=7', |
|
|
], |
|
|
cwd=root_dir, |
|
|
stderr=subprocess.DEVNULL, |
|
|
text=True, |
|
|
) |
|
|
.strip() |
|
|
.lstrip('v') |
|
|
.replace('-', '.dev', 1) |
|
|
.replace('-', '+', 1) |
|
|
.partition('.dev') |
|
|
) |
|
|
if sep: |
|
|
version_prefix, dot, version_tail = prefix.rpartition('.') |
|
|
prefix = f'{version_prefix}{dot}{int(version_tail) + 1}' |
|
|
__version__ = f'{prefix}{sep}{suffix}' |
|
|
del version_prefix, dot, version_tail |
|
|
else: |
|
|
__version__ = prefix |
|
|
del prefix, sep, suffix |
|
|
except (OSError, subprocess.CalledProcessError): |
|
|
pass |
|
|
|
|
|
del os, subprocess, root_dir |
|
|
|