drop VERSION file, use __version__ directly in mic module
authorGui Chen <gui.chen@intel.com>
Wed, 28 Aug 2013 09:43:31 +0000 (05:43 -0400)
committerGui Chen <gui.chen@intel.com>
Mon, 16 Sep 2013 02:06:22 +0000 (22:06 -0400)
Change-Id: I0f0ea1a93d8bbc924f5853c0d161c286251eb670
Signed-off-by: Gui Chen <gui.chen@intel.com>
Makefile
VERSION [deleted file]
mic/__init__.py
setup.py
tools/mic

index 5bbf2f6..dc1d030 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 PYTHON ?= python
-VERSION = $(shell cat VERSION)
-TAGVER = $(shell cat VERSION | sed -e "s/\([0-9\.]*\).*/\1/")
+VERSION = $(shell sed -ne 's/__version__\s*=\s*"\(.*\)"/\1/p ' mic/__init__.py)
+TAGVER = $(shell echo $(VERSION) | sed -e "s/\([0-9\.]*\).*/\1/")
 
 PKGNAME = mic
 
diff --git a/VERSION b/VERSION
deleted file mode 100644 (file)
index 5320adc..0000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-0.21
index 63c1d9c..6232cc4 100644 (file)
@@ -1,4 +1,22 @@
+#
+# Copyright (c) 2013 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
 import os, sys
 
+__version__ = "0.21"
+
 cur_path = os.path.dirname(__file__) or '.'
 sys.path.insert(0, cur_path + '/3rdparty')
index 2c79dda..d4db893 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -11,23 +11,11 @@ except ImportError:
 
 MOD_NAME = 'mic'
 
-version_path = 'VERSION'
-if not os.path.isfile(version_path):
-    print 'No VERSION file in topdir, abort'
-    sys.exit(1)
-
 try:
-    # first line should be the version number
-    version = open(version_path).readline().strip()
-    if not version:
-        print 'VERSION file is invalid, abort'
-        sys.exit(1)
-
-    ver_file = open('%s/__version__.py' % MOD_NAME, 'w')
-    ver_file.write("VERSION = \"%s\"\n" % version)
-    ver_file.close()
-except IOError:
-    print 'WARNING: Cannot write version number file'
+    import mic
+    version = mic.__version__
+except (ImportError, AttributeError):
+    version = "dev"
 
 # --install-layout is recognized after 2.5
 if sys.version_info[:2] > (2, 5):
index b316dbf..6d6abf6 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import os, sys, errno
-from mic import msger, creator
+from mic import msger, creator, __version__ as VERSION
 from mic.utils import cmdln, misc, errors
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
-from mic.__version__ import VERSION
 
 
 def optparser_setup(func):