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