5 from distutils.core import setup
8 # enable "setup.py develop", optional
16 version = mic.__version__
17 except (ImportError, AttributeError):
20 # --install-layout is recognized after 2.5
21 if sys.version_info[:2] > (2, 5):
22 if len(sys.argv) > 1 and 'install' in sys.argv:
25 (dist, ver, id) = platform.linux_distribution()
27 # for debian-like distros, mods will be installed to
28 # ${PYTHONLIB}/dist-packages
29 if dist in ('debian', 'Ubuntu'):
30 sys.argv.append('--install-layout=deb')
37 MOD_NAME + '/kickstart',
38 MOD_NAME + '/kickstart/custom_commands',
39 MOD_NAME + '/3rdparty/pykickstart',
40 MOD_NAME + '/3rdparty/pykickstart/commands',
41 MOD_NAME + '/3rdparty/pykickstart/handlers',
42 MOD_NAME + '/3rdparty/pykickstart/urlgrabber',
45 IMAGER_PLUGINS = glob.glob(os.path.join("plugins", "imager", "*.py"))
46 BACKEND_PLUGINS = glob.glob(os.path.join("plugins", "backend", "*.py"))
48 # the following code to do a simple parse for '--prefix' opts
55 if '--prefix=' in arg:
58 elif '--prefix' == arg:
61 # get the installation path of mic.conf
62 prefix = os.path.abspath(os.path.expanduser(prefix)).rstrip('/')
63 if prefix.lstrip('/') == 'usr':
66 etc_prefix = os.path.join(prefix, 'etc')
68 conffile = 'etc/mic.conf'
69 if os.path.isfile('%s/mic/mic.conf' % etc_prefix):
72 # apply prefix to mic.conf.in to generate actual mic.conf
73 conf_str = file('etc/mic.conf.in').read()
74 conf_str = conf_str.replace('@PREFIX@', prefix)
75 with file(conffile, 'w') as wf:
79 os.environ['PREFIX'] = prefix
82 description = 'Image Creator for Linux Distributions',
83 author='Jian-feng Ding, Qiang Zhang, Gui Chen',
84 author_email='jian-feng.ding@intel.com, qiang.z.zhang@intel.com, gui.chen@intel.com',
85 url='https://github.com/jfding/mic',
90 data_files = [("%s/lib/mic/plugins/imager" % prefix, IMAGER_PLUGINS),
91 ("%s/lib/mic/plugins/backend" % prefix, BACKEND_PLUGINS),
92 ("%s/mic" % etc_prefix, [conffile])]
95 # remove dynamic file distfiles/mic.conf