blob: 4d42882eaed43b773de7c78735372b4bd59aac11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
"""Define version."""
import pathlib
here = pathlib.Path(__file__).resolve().parent
__all__ = ["__version__", "__branch__"]
# read from VERSION file
with open(str(here / "VERSION")) as f:
__version__ = f.read().strip()
# add git branch, if appropriate
p = here.parent / ".git"
if p.is_file():
with open(str(p)) as f:
p = p.parent / f.readline()[8:].strip() # Strip "gitdir: "
p = p / "HEAD"
if p.exists():
with open(str(p)) as f:
__branch__ = f.readline().rstrip().split(r"/")[-1]
__version__ += "+" + __branch__
else:
__branch__ = ""
|