From: Calin Crisan Date: Sun, 30 Aug 2015 10:37:17 +0000 (+0300) Subject: automatically detect version from git X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=7f51bd71a30659e89d09ae7d88c9834f640f5a5e;p=motioneye-debian automatically detect version from git --- diff --git a/.gitignore b/.gitignore index 806f37a..005b145 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ conf run media log +dist +motioneye.egg-info diff --git a/motioneye/__init__.py b/motioneye/__init__.py index ad23e4c..587c248 100644 --- a/motioneye/__init__.py +++ b/motioneye/__init__.py @@ -1,2 +1,2 @@ -VERSION = '0.26' +VERSION = "0.25.2-10-g030bf9c" diff --git a/setup.py b/setup.py index 2f6dfe2..165b615 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,10 @@ import os.path +import subprocess -from setuptools import setup from codecs import open +from setuptools.command.sdist import sdist +from setuptools import setup import motioneye @@ -15,6 +17,27 @@ with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() +# update the version according to git +git_version = subprocess.Popen('git describe --tags', + stdout=subprocess.PIPE, stderr=open('/dev/null'), shell=True).communicate()[0].strip() + +if git_version: + print 'detected git version %s' % git_version + version = git_version + +else: + print 'using found version %s' % version + + +class custom_sdist(sdist): + def run(self): + if git_version: + subprocess.Popen("sed -ri 's/VERSION = (.+)/VERSION = \"%s\"/' %s/__init__.py" % (git_version, name), + shell=True).communicate() + + sdist.run(self) + + setup( name=name, version=version, @@ -65,5 +88,9 @@ setup( 'console_scripts': [ 'meyectl=motioneye.meyectl:main', ], + }, + + cmdclass={ + 'sdist': custom_sdist } )