3 # Copyright (c) 2014 Intel, Inc.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation; version 2 of the License
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # You should have received a copy of the GNU General Public License along
15 # with this program; if not, write to the Free Software Foundation, Inc., 59
16 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 Main for installing mic
25 from distutils.core import setup
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, _, _) = platform.linux_distribution()
38 # for debian-like distros, mods will be installed to
39 # ${PYTHONLIB}/dist-packages
40 if dist in ('debian', 'Ubuntu'):
41 sys.argv.append('--install-layout=deb')
42 except AttributeError:
46 def create_conf_file():
47 """Apply prefix to mic.conf.in to generate actual mic.conf"""
48 with open('etc/mic.conf.in') as source_file:
49 conf_str = source_file.read()
50 conf_str = conf_str.replace('@PREFIX@', PREFIX)
51 with open(CONF_FILE, 'w') as conf_file:
52 conf_file.write(conf_str)
57 VERSION = mic.__version__
58 except (ImportError, AttributeError):
66 MOD_NAME + '/kickstart',
67 MOD_NAME + '/kickstart/custom_commands',
68 MOD_NAME + '/3rdparty/pykickstart',
69 MOD_NAME + '/3rdparty/pykickstart/commands',
70 MOD_NAME + '/3rdparty/pykickstart/handlers',
71 MOD_NAME + '/3rdparty/pykickstart/urlgrabber',
74 IMAGER_PLUGINS = glob.glob(os.path.join("plugins", "imager", "*.py"))
75 BACKEND_PLUGINS = glob.glob(os.path.join("plugins", "backend", "*.py"))
78 # if real_prefix, it must be in virtualenv, use prefix as root
79 ROOT = sys.prefix if hasattr(sys, 'real_prefix') else ''
81 CONF_FILE = 'etc/mic.conf'
86 description = 'Image Creator for Linux Distributions',
87 author='Jian-feng Ding, Qiang Zhang, Gui Chen',
88 author_email='jian-feng.ding@intel.com, qiang.z.zhang@intel.com,\
90 url='https://github.com/01org/mic',
95 data_files = [("%s/lib/mic/plugins/imager" % PREFIX, IMAGER_PLUGINS),
96 ("%s/lib/mic/plugins/backend" % PREFIX, BACKEND_PLUGINS),
97 ("%s/etc/mic" % ROOT, [CONF_FILE])]