forked from autotest/autotest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
140 lines (112 loc) · 4.31 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import os
try:
import autotest.common as common
except ImportError:
import common
# High level way of installing each autotest component
import client.setup
import frontend.setup
import cli.setup
import server.setup
import scheduler.setup
import database_legacy.setup
import tko.setup
import utils.setup
import mirror.setup
import installation_support.setup
# pylint: disable=E0611
from distutils.core import setup
from sphinx.setup_command import BuildDoc
cmdclass = {'build_doc': BuildDoc}
from autotest.client.shared import version
def _combine_dicts(list_dicts):
result_dict = {}
for d in list_dicts:
for k in d:
result_dict[k] = d[k]
return result_dict
def _fix_data_paths(package_data_dict):
'''
Corrects package data paths
When the package name is compound, and the package contents, that
is, file paths, contain the same path name found in the package
name, setuptools thinks there's an extra directory. This checks
that condition and adjusts (strips) the 1st directory name.
'''
result = {}
for package_name, package_content in package_data_dict.items():
package_structure = package_name.split('.')
package_structure_1st_level = package_structure[1]
result[package_name] = []
for p in package_content:
path_structure = p.split(os.path.sep)
path_structure_1st_level = path_structure[0]
if package_structure_1st_level == path_structure_1st_level:
path = os.path.join(*path_structure[1:])
else:
path = p
result[package_name].append(path)
return result
def get_package_dir():
return _combine_dicts([client.setup.get_package_dir(),
frontend.setup.get_package_dir(),
cli.setup.get_package_dir(),
server.setup.get_package_dir(),
scheduler.setup.get_package_dir(),
database_legacy.setup.get_package_dir(),
tko.setup.get_package_dir(),
utils.setup.get_package_dir(),
mirror.setup.get_package_dir()])
def get_packages():
return (client.setup.get_packages() +
frontend.setup.get_packages() +
cli.setup.get_packages() +
server.setup.get_packages() +
scheduler.setup.get_packages() +
database_legacy.setup.get_packages() +
tko.setup.get_packages() +
utils.setup.get_packages() +
mirror.setup.get_packages() +
installation_support.setup.get_packages())
def get_data_files():
return (client.setup.get_data_files() +
tko.setup.get_data_files() +
utils.setup.get_data_files() +
mirror.setup.get_data_files())
def get_package_data():
return _combine_dicts([
_fix_data_paths(client.setup.get_package_data()),
_fix_data_paths(frontend.setup.get_package_data()),
_fix_data_paths(cli.setup.get_package_data()),
_fix_data_paths(server.setup.get_package_data()),
_fix_data_paths(scheduler.setup.get_package_data()),
_fix_data_paths(database_legacy.setup.get_package_data()),
_fix_data_paths(utils.setup.get_package_data())
])
def get_scripts():
return (client.setup.get_scripts() +
frontend.setup.get_scripts() +
cli.setup.get_scripts() +
server.setup.get_scripts() +
scheduler.setup.get_scripts() +
database_legacy.setup.get_scripts() +
tko.setup.get_scripts() +
installation_support.setup.get_scripts())
def run():
setup(name='autotest',
description='Autotest test framework',
maintainer='Lucas Meneghel Rodrigues',
maintainer_email='[email protected]',
version=version.get_version(),
url='http://autotest.github.com',
package_dir=get_package_dir(),
package_data=get_package_data(),
packages=get_packages(),
scripts=get_scripts(),
data_files=get_data_files(),
cmdclass=cmdclass,
command_options={'build_doc': {'source_dir':
('setup.py', 'documentation/source')}}
)
if __name__ == '__main__':
run()