Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 658
1
# Definition of the version number
2
try:
3
from ._utils import _sh
4
except: # pragma: no cover
5
_sh = None
6
7
from subprocess import STDOUT
8
__all__ = ["__version__"]
9
10
# major, minor, patch, -extra
11
version_info = 4, 8, 4
12
13
# Nice string for the version
14
__version__ = '.'.join(map(str, version_info))
15
16
17
# auto -extra based on commit hash (if not tagged as release)
18
if (_sh is not None) and (len(version_info) < 4): # pragma: no cover
19
def commit_hash(*args):
20
try:
21
res = _sh('git', 'log', '-n', '1', '--oneline', *args,
22
stderr=STDOUT).lstrip().split()[0]
23
return None if res.startswith('fatal') else res
24
except:
25
return None
26
27
cur_hash = commit_hash()
28
if cur_hash is not None:
29
last_release = commit_hash('v' + __version__)
30
31
if (last_release is None) or (cur_hash not in last_release):
32
__version__ += '-' + cur_hash
33
34