5 from distutils.core import setup
8 # enable "setup.py develop", optional
14 version_path = 'VERSION'
15 if not os.path.isfile(version_path):
16 print 'No VERSION file in topdir, abort'
20 # first line should be the version number
21 version = open(version_path).readline().strip()
23 print 'VERSION file is invalid, abort'
26 ver_file = open('%s/__version__.py' % MOD_NAME, 'w')
27 ver_file.write("VERSION = \"%s\"\n" % version)
30 print 'WARNING: Cannot write version number file'
32 # --install-layout is recognized after 2.5
33 if sys.version_info[:2] > (2, 5):
34 if len(sys.argv) > 1 and 'install' in sys.argv:
37 (dist, ver, id) = platform.linux_distribution()
39 # for debian-like distros, mods will be installed to
40 # ${PYTHONLIB}/dist-packages
41 if dist in ('debian', 'Ubuntu'):
42 sys.argv.append('--install-layout=deb')
49 MOD_NAME + '/kickstart',
50 MOD_NAME + '/kickstart/custom_commands',
51 MOD_NAME + '/3rdparty/pykickstart',
52 MOD_NAME + '/3rdparty/pykickstart/commands',
53 MOD_NAME + '/3rdparty/pykickstart/handlers',
54 MOD_NAME + '/3rdparty/pykickstart/urlgrabber',
57 IMAGER_PLUGINS = glob.glob(os.path.join("plugins", "imager", "*.py"))
58 BACKEND_PLUGINS = glob.glob(os.path.join("plugins", "backend", "*.py"))
60 # the following code to do a simple parse for '--prefix' opts
67 if '--prefix=' in arg:
70 elif '--prefix' == arg:
73 # get the installation path of mic.conf
74 prefix = os.path.abspath(os.path.expanduser(prefix)).rstrip('/')
75 if prefix.lstrip('/') == 'usr':
78 etc_prefix = os.path.join(prefix, 'etc')
80 conffile = 'distfiles/mic.conf'
81 if os.path.isfile('%s/mic/mic.conf' % etc_prefix):
84 # apply prefix to mic.conf.in to generate actual mic.conf
85 conf_str = file('distfiles/mic.conf.in').read()
86 conf_str = conf_str.replace('@PREFIX@', prefix)
87 with file(conffile, 'w') as wf:
91 os.environ['PREFIX'] = prefix
94 description = 'Image Creator for Linux Distributions',
95 author='Jian-feng Ding, Qiang Zhang, Gui Chen',
96 author_email='jian-feng.ding@intel.com, qiang.z.zhang@intel.com, gui.chen@intel.com',
97 url='https://github.com/jfding/mic',
102 data_files = [("%s/lib/mic/plugins/imager" % prefix, IMAGER_PLUGINS),
103 ("%s/lib/mic/plugins/backend" % prefix, BACKEND_PLUGINS),
104 ("%s/mic" % etc_prefix, [conffile])]
107 # remove dynamic file distfiles/mic.conf