]> www.vanbest.org Git - motioneye-debian/commitdiff
automatically detect version from git
authorCalin Crisan <ccrisan@gmail.com>
Sun, 30 Aug 2015 10:37:17 +0000 (13:37 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 30 Aug 2015 10:39:39 +0000 (13:39 +0300)
.gitignore
motioneye/__init__.py
setup.py

index 806f37ae5597fffcdce82dbad24721f139622d7d..005b14592a88f31a13892b931a164824e6ca65dc 100644 (file)
@@ -11,3 +11,5 @@ conf
 run
 media
 log
+dist
+motioneye.egg-info
index ad23e4c3191cd87d2a445928ceddcc66b66323fd..587c2482b72cb8ec90a58d2609710a4878dfd000 100644 (file)
@@ -1,2 +1,2 @@
 
-VERSION = '0.26'
+VERSION = "0.25.2-10-g030bf9c"
index 2f6dfe2381e3fa3c3bc17a137ead93daace15b9a..165b615e225d6d0a5d2936c6ec94a50615de77dc 100644 (file)
--- 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
     }
 )