update setup.py to apply VERSION in installation
authorJF Ding <jian-feng.ding@intel.com>
Wed, 16 May 2012 09:55:48 +0000 (17:55 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Wed, 16 May 2012 09:59:58 +0000 (17:59 +0800)
setup.py

index f46eaae..735a510 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -8,8 +8,28 @@ try:
 except ImportError:
     pass
 
+MOD_NAME = 'kickstart'
+
+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'
+
 setup(name='kickstarter',
-      version = "0.2",
+      version = version,
       description='Kickstarter',
       author='Anas Nashif',
       author_email='anas.nashif@intel.com',