@@ -14,6 +14,24 @@ def get_version(package):
1414 return re .search ("__version__ = ['\" ]([^'\" ]+)['\" ]" , init_py ).group (1 )
1515
1616
17+ version = get_version ("tibiapy" )
18+ if version .endswith (('a' , 'b' , 'rc' )):
19+ # append version identifier based on commit count
20+ try :
21+ import subprocess
22+ p = subprocess .Popen (['git' , 'rev-list' , '--count' , 'HEAD' ],
23+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
24+ out , err = p .communicate ()
25+ if out :
26+ version += out .decode ('utf-8' ).strip ()
27+ p = subprocess .Popen (['git' , 'rev-parse' , '--short' , 'HEAD' ],
28+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
29+ out , err = p .communicate ()
30+ if out :
31+ version += '+g' + out .decode ('utf-8' ).strip ()
32+ except Exception :
33+ pass
34+
1735with open ('requirements.txt' ) as f :
1836 requirements = f .read ().splitlines ()
1937
@@ -33,7 +51,7 @@ def get_version(package):
3351
3452setup (
3553 name = 'tibia.py' ,
36- version = get_version ( "tibiapy" ) ,
54+ version = version ,
3755 author = 'Galarzaa90' ,
3856 author_email = "allan.galarza@gmail.com" ,
3957 url = 'https://github.com/Galarzaa90/tibia.py' ,
0 commit comments