forked from avocado-framework/avocado
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·156 lines (137 loc) · 5.96 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/env python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <[email protected]>
import glob
import os
# pylint: disable=E0611
from setuptools import setup
from avocado import VERSION
VIRTUAL_ENV = 'VIRTUAL_ENV' in os.environ
def get_dir(system_path=None, virtual_path=None):
"""
Retrieve VIRTUAL_ENV friendly path
:param system_path: Relative system path
:param virtual_path: Overrides system_path for virtual_env only
:return: VIRTUAL_ENV friendly path
"""
if virtual_path is None:
virtual_path = system_path
if VIRTUAL_ENV:
if virtual_path is None:
virtual_path = []
return os.path.join(*virtual_path)
else:
if system_path is None:
system_path = []
return os.path.join(*(['/'] + system_path))
def get_tests_dir():
return get_dir(['usr', 'share', 'avocado', 'tests'], ['tests'])
def get_avocado_libexec_dir():
if VIRTUAL_ENV:
return get_dir(['libexec'])
elif os.path.exists('/usr/libexec'): # RHEL-like distro
return get_dir(['usr', 'libexec', 'avocado'])
else: # Debian-like distro
return get_dir(['usr', 'lib', 'avocado'])
def get_data_files():
data_files = [(get_dir(['etc', 'avocado']), ['etc/avocado/avocado.conf'])]
data_files += [(get_dir(['etc', 'avocado', 'conf.d']),
['etc/avocado/conf.d/README', 'etc/avocado/conf.d/gdb.conf'])]
data_files += [(get_dir(['etc', 'avocado', 'sysinfo']),
['etc/avocado/sysinfo/commands', 'etc/avocado/sysinfo/files',
'etc/avocado/sysinfo/profilers'])]
data_files += [(get_dir(['etc', 'avocado', 'scripts', 'job', 'pre.d']),
['etc/avocado/scripts/job/pre.d/README'])]
data_files += [(get_dir(['etc', 'avocado', 'scripts', 'job', 'post.d']),
['etc/avocado/scripts/job/post.d/README'])]
data_files += [(get_tests_dir(), glob.glob('examples/tests/*.py'))]
data_files += [(get_tests_dir(), glob.glob('examples/tests/*.sh'))]
for data_dir in glob.glob('examples/tests/*.data'):
fmt_str = '%s/*' % data_dir
for f in glob.glob(fmt_str):
data_files += [(os.path.join(get_tests_dir(),
os.path.basename(data_dir)), [f])]
data_files.append((get_dir(['usr', 'share', 'doc', 'avocado'], ['.']),
['man/avocado.rst', 'man/avocado-rest-client.rst']))
data_files += [(get_dir(['usr', 'share', 'avocado', 'wrappers'],
['wrappers']),
glob.glob('examples/wrappers/*.sh'))]
data_files.append((get_avocado_libexec_dir(), glob.glob('libexec/*')))
return data_files
def _get_resource_files(path):
"""
Given a path, return all the files in there to package
"""
flist = []
for root, _, files in sorted(os.walk(path)):
for name in files:
fullname = os.path.join(root, name)
flist.append(fullname[len('avocado/core/'):])
return flist
def get_long_description():
with open('README.rst', 'r') as req:
req_contents = req.read()
return req_contents
if __name__ == '__main__':
setup(name='avocado',
version=VERSION,
description='Avocado Test Framework',
long_description=get_long_description(),
author='Avocado Developers',
author_email='[email protected]',
url='http://avocado-framework.github.io/',
use_2to3=True,
packages=['avocado',
'avocado.core',
'avocado.utils',
'avocado.utils.external',
'avocado.core.remote',
'avocado.core.restclient',
'avocado.core.restclient.cli',
'avocado.core.restclient.cli.args',
'avocado.core.restclient.cli.actions',
'avocado.plugins'],
package_data={'avocado.core': _get_resource_files(
'avocado/core/resources')},
data_files=get_data_files(),
scripts=['scripts/avocado',
'scripts/avocado-rest-client'],
entry_points={
'avocado.plugins.cli': [
'gdb = avocado.plugins.gdb:GDB',
'wrapper = avocado.plugins.wrapper:Wrapper',
'xunit = avocado.plugins.xunit:XUnit',
'json = avocado.plugins.json:JSON',
'journal = avocado.plugins.journal:Journal',
'html = avocado.plugins.html:HTML',
'remote = avocado.plugins.remote:Remote',
'replay = avocado.plugins.replay:Replay',
'vm = avocado.plugins.vm:VM',
],
'avocado.plugins.cli.cmd': [
'config = avocado.plugins.config:Config',
'distro = avocado.plugins.distro:Distro',
'exec-path = avocado.plugins.exec_path:ExecPath',
'multiplex = avocado.plugins.multiplex:Multiplex',
'list = avocado.plugins.list:List',
'run = avocado.plugins.run:Run',
'sysinfo = avocado.plugins.sysinfo:SysInfo',
'plugins = avocado.plugins.plugins:Plugins',
],
'avocado.plugins.job.prepost': [
'jobscripts = avocado.plugins.jobscripts:JobScripts',
],
},
zip_safe=False,
test_suite='selftests')