diff --git a/pomice/__init__.py b/pomice/__init__.py index 61c3da8..9c5aac2 100644 --- a/pomice/__init__.py +++ b/pomice/__init__.py @@ -18,7 +18,7 @@ if not discord.__version__.startswith("2.0"): "Uninstall your current version and install discord.py 2.0 or a compatible fork." ) -__version__ = "1.1.7" +__version__ = "1.1.7b" __title__ = "pomice" __author__ = "cloudwithax" diff --git a/setup.py b/setup.py index 4d9ba19..ba8ca15 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,29 @@ import setuptools +import re + +version = '' +with open('pomice/__init__.py') as f: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('version is not set') + +if version.endswith(('a', 'b', 'rc')): + # append version identifier based on commit count + try: + import subprocess + p = subprocess.Popen(['git', 'rev-list', '--count', 'HEAD'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if out: + version += out.decode('utf-8').strip() + p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if out: + version += '+g' + out.decode('utf-8').strip() + except Exception: + pass with open("requirements.txt") as f: requirements = f.read().splitlines() @@ -9,7 +34,7 @@ with open("README.md") as f: setuptools.setup( name="pomice", author="cloudwithax", - version="1.1.7", + version=version, url="https://github.com/cloudwithax/pomice", packages=setuptools.find_packages(), license="GPL",