From 51b19b2b2dfa14e0efdc84bef81623e6503422e5 Mon Sep 17 00:00:00 2001 From: daquexian Date: Thu, 23 May 2019 21:40:50 +0800 Subject: [PATCH] Auto set python package version from git tag --- tools/onnx2daq/python/setup.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/onnx2daq/python/setup.py b/tools/onnx2daq/python/setup.py index 81c5e04..b7367ed 100644 --- a/tools/onnx2daq/python/setup.py +++ b/tools/onnx2daq/python/setup.py @@ -40,6 +40,13 @@ tests_require = [] extras_require = {} +build_source_branch = os.getenv("BUILD_SOURCEBRANCH", "") +if build_source_branch.startswith('refs/tags/v'): + dnnlibrary_version = build_source_branch[len('refs/tags/v'):] +else: + dnnlibrary_version = '0.0.0' +print("DNNLibrary version: {}".format(dnnlibrary_version)) + ################################################################################ # Global variables for controlling the build variant ################################################################################ @@ -184,7 +191,7 @@ def build_extension(self, ext): setuptools.setup( name="onnx2daq", - # version=VersionInfo.version, + version=dnnlibrary_version, description="Convert ONNX to daq for DNNLibrary", ext_modules=ext_modules, cmdclass=cmdclass,