diff setup.py @ 2572:7e7f4e344a96

setup: use scm version
author Goffi <goffi@goffi.org>
date Thu, 05 Apr 2018 12:49:25 +0200
parents 4aca060075b7
children fbcdb761981c
line wrap: on
line diff
--- a/setup.py	Thu Apr 05 10:41:08 2018 +0200
+++ b/setup.py	Thu Apr 05 12:49:25 2018 +0200
@@ -56,6 +56,24 @@
 DBUS_FILE = 'misc/org.goffi.SAT.service'
 with open('sat/VERSION') as f:
     VERSION = f.read().strip()
+is_dev_version = VERSION.endswith('D')
+
+
+def sat_dev_version():
+    """Use mercurial data to compute version"""
+    def version_scheme(version):
+        return VERSION
+
+    def local_scheme(version):
+        # XXX: setuptools_scm seems buggy and the '+' and the '_' are replaced by '-'
+        #      breaking the local version identifier scheme
+        #      cf. https://github.com/pypa/setuptools_scm/issues/237
+        return "+{rev}_{distance}".format(
+            rev=version.node[1:],
+            distance=version.distance)
+
+    return {'version_scheme': version_scheme,
+            'local_scheme': local_scheme}
 
 
 setup(name=NAME,
@@ -78,6 +96,8 @@
                   ],
       scripts=['sat_frontends/jp/jp', 'sat_frontends/primitivus/primitivus', 'bin/sat'],
       zip_safe=False,
+      setup_requires=['setuptools_scm'] if is_dev_version else [],
+      use_scm_version=sat_dev_version if is_dev_version else False,
       install_requires=install_requires,
       package_data={'sat': ['VERSION']},
       python_requires='~=2.7',