Add support for riscv64
[platform/upstream/mic.git] / setup.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2014 Intel, Inc.
4 #
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
8 #
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
12 # for more details.
13 #
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.
17
18 """
19     Main for installing mic
20 """
21
22
23 import os, sys
24 import glob
25 from distutils.core import setup
26
27
28 MOD_NAME = 'mic'
29
30
31 def check_debian():
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:
35             try:
36                 import platform
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:
43                 pass
44
45
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)
53
54
55 try:
56     import mic
57     VERSION = mic.__version__
58 except (ImportError, AttributeError):
59     VERSION = "dev"
60
61 check_debian()
62
63 PACKAGES = [MOD_NAME,
64             MOD_NAME + '/utils',
65             MOD_NAME + '/imager',
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            ]
72
73 IMAGER_PLUGINS = glob.glob(os.path.join("plugins", "imager", "*.py"))
74 BACKEND_PLUGINS = glob.glob(os.path.join("plugins", "backend", "*.py"))
75
76 PREFIX = sys.prefix
77 # if real_prefix, it must be in virtualenv, use prefix as root
78 ROOT = sys.prefix if hasattr(sys, 'real_prefix') else ''
79
80 CONF_FILE = 'etc/mic.conf'
81 create_conf_file()
82
83 setup(name=MOD_NAME,
84   version = VERSION,
85   description = 'Image Creator for Linux Distributions',
86   author='Jian-feng Ding, Qiang Zhang, Gui Chen',
87   author_email='jian-feng.ding@intel.com, qiang.z.zhang@intel.com,\
88                 gui.chen@intel.com',
89   url='https://github.com/01org/mic',
90   scripts=[
91       'tools/mic',
92       ],
93   packages = PACKAGES,
94   data_files = [("%s/lib/mic/plugins/imager" % PREFIX, IMAGER_PLUGINS),
95                 ("%s/lib/mic/plugins/backend" % PREFIX, BACKEND_PLUGINS),
96                 ("%s/etc/mic" % ROOT, [CONF_FILE])]
97 )