diff options
author | Blaise Thompson <blaise@untzag.com> | 2019-11-09 20:01:55 -0600 |
---|---|---|
committer | Blaise Thompson <blaise@untzag.com> | 2019-11-09 20:01:55 -0600 |
commit | 4f1731772dd84a41ed0756ac3a7953c3d021b1cd (patch) | |
tree | a4cf51d3b742d1d10c0deaffa0eba48b1be486c3 /shopdb | |
parent | c99d2447b57d6e14a78013152a53bb4552a33bb7 (diff) |
version
Diffstat (limited to 'shopdb')
-rw-r--r-- | shopdb/VERSION | 1 | ||||
-rw-r--r-- | shopdb/__version__.py | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/shopdb/VERSION b/shopdb/VERSION new file mode 100644 index 0000000..bd52db8 --- /dev/null +++ b/shopdb/VERSION @@ -0,0 +1 @@ +0.0.0
\ No newline at end of file diff --git a/shopdb/__version__.py b/shopdb/__version__.py new file mode 100644 index 0000000..4d42882 --- /dev/null +++ b/shopdb/__version__.py @@ -0,0 +1,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__ = "" |