From b5a4d8c58d4f940eb22d2321c6e7cc8bf657e023 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 5 Apr 2018 12:49:25 +0200 Subject: [PATCH] setup: use scm version --- setup.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/setup.py b/setup.py index a7f60265..748ac34a 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,24 @@ DBUS_DIR = 'dbus-1/services' 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 @@ setup(name=NAME, ], 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',