Skip to content

Commit e019291

Browse files
committed
improve automatic versioning
1 parent e0cad9c commit e019291

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ recursive-include pypop/examples *
33
recursive-include pypop/cfgs *
44
recursive-include pypop/cutters *
55
recursive-include pypop/filters *
6+
global-exclude */.ipynb_checkpoints/*

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
author_email="[email protected]",
1414
description="Python notebook support for POP metrics and reports",
1515
packages=find_packages(),
16+
python_requires=">=3.6",
1617
install_requires=[
1718
"numpy",
1819
"matplotlib >= 2",

versionate.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#!/usr/bin/env python3
22

3+
from sys import hexversion
34
from warnings import warn
4-
from subprocess import run, PIPE
5+
from subprocess import check_output, CalledProcessError, PIPE
56

67
_k_unknown_ver = "Unknown"
78

89

9-
def get_git_verstring():
10-
git_result = run(
11-
['git', 'describe', '--tags', '--dirty', '--long'],
12-
stdout=PIPE,
13-
stderr=PIPE,
14-
)
15-
if git_result.returncode != 0:
16-
warn("Git failed with error: {}".format(str(err.stderr)))
17-
return _k_unknown_ver
10+
def get_git_verstring(silent=True):
11+
try:
12+
git_result = check_output(
13+
['git', 'describe', '--tags', '--dirty', '--long'],
14+
stderr=PIPE,
15+
)
16+
except CalledProcessError as err:
17+
if not silent:
18+
warn("Git failed with error: {}".format(str(err.stderr)))
19+
return _k_unknown_ver
1820

19-
ver_string = git_result.stdout.decode().strip()
21+
ver_string = git_result.decode().strip()
2022
ver_tokens = ver_string.split('-')
2123

2224
dirty = None
@@ -28,15 +30,17 @@ def get_git_verstring():
2830
tag = '-'.join(ver_tokens)
2931

3032
if commitcount == '0':
31-
return "-".join([tag, dirty]) if dirty else tag
33+
return "+".join([tag, dirty]) if dirty else tag
3234

33-
return ver_string
35+
localver = "+".join([tag,sha])
36+
37+
return ".".join([localver, dirty]) if dirty else localver
3438

3539

3640
def versionate():
3741

3842
ver_string = get_git_verstring()
39-
43+
4044
with open('pypop/version', 'wt') as fh:
4145
fh.write(ver_string)
4246

0 commit comments

Comments
 (0)