setup.py 6.0 KB
Newer Older
1
#!/bin/env python
2 3
# 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
4 5
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
6 7 8 9 10 11 12
#
# 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.
#
13
# Copyright: Red Hat Inc. 2013-2014
14 15
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>

16
import glob
17
import os
18
import sys
19
# pylint: disable=E0611
20

C
Cleber Rosa 已提交
21
from setuptools import setup, find_packages
22

23

24
VIRTUAL_ENV = hasattr(sys, 'real_prefix')
C
Cleber Rosa 已提交
25 26


27 28 29 30 31 32 33 34 35 36 37 38 39
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)
40
    else:
41 42 43
        if system_path is None:
            system_path = []
        return os.path.join(*(['/'] + system_path))
44 45


46 47
def get_tests_dir():
    return get_dir(['usr', 'share', 'avocado', 'tests'], ['tests'])
48 49


50 51 52 53 54 55 56 57 58
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'])


59
def get_data_files():
60 61
    data_files = [(get_dir(['etc', 'avocado']), ['etc/avocado/avocado.conf'])]
    data_files += [(get_dir(['etc', 'avocado', 'conf.d']),
62
                    ['etc/avocado/conf.d/README', 'etc/avocado/conf.d/gdb.conf'])]
63 64 65
    data_files += [(get_dir(['etc', 'avocado', 'sysinfo']),
                    ['etc/avocado/sysinfo/commands', 'etc/avocado/sysinfo/files',
                     'etc/avocado/sysinfo/profilers'])]
66 67 68 69
    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'])]
70
    data_files += [(get_tests_dir(), glob.glob('examples/tests/*.py'))]
71
    data_files += [(get_tests_dir(), glob.glob('examples/tests/*.sh'))]
72
    for data_dir in glob.glob('examples/tests/*.data'):
73
        fmt_str = '%s/*' % data_dir
74
        for f in glob.glob(fmt_str):
75 76 77 78 79 80 81
            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'))]
82

83
    data_files.append((get_avocado_libexec_dir(), glob.glob('libexec/*')))
84 85 86
    return data_files


87
def _get_resource_files(path):
88 89 90 91 92 93 94
    """
    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)
95
            flist.append(fullname[len('avocado/core/'):])
96 97 98
    return flist


99 100 101 102 103
def get_long_description():
    with open('README.rst', 'r') as req:
        req_contents = req.read()
    return req_contents

104 105
if __name__ == '__main__':
    setup(name='avocado',
C
Cleber Rosa 已提交
106
          version='40.0',
107 108 109 110 111
          description='Avocado Test Framework',
          long_description=get_long_description(),
          author='Avocado Developers',
          author_email='avocado-devel@redhat.com',
          url='http://avocado-framework.github.io/',
C
Cleber Rosa 已提交
112
          use_2to3=True,
C
Cleber Rosa 已提交
113
          packages=find_packages(exclude=('selftests*',)),
114 115
          package_data={'avocado.core': _get_resource_files(
              'avocado/core/resources')},
116
          data_files=get_data_files(),
117
          scripts=['scripts/avocado',
118
                   'scripts/avocado-rest-client'],
C
Cleber Rosa 已提交
119
          entry_points={
C
Cleber Rosa 已提交
120
              'avocado.plugins.cli': [
121
                  'envkeep = avocado.plugins.envkeep:EnvKeep',
C
Cleber Rosa 已提交
122
                  'gdb = avocado.plugins.gdb:GDB',
C
Cleber Rosa 已提交
123
                  'wrapper = avocado.plugins.wrapper:Wrapper',
C
Cleber Rosa 已提交
124
                  'xunit = avocado.plugins.xunit:XUnitCLI',
C
Cleber Rosa 已提交
125
                  'json = avocado.plugins.jsonresult:JSONCLI',
C
Cleber Rosa 已提交
126
                  'journal = avocado.plugins.journal:Journal',
C
Cleber Rosa 已提交
127
                  'html = avocado.plugins.html:HTML',
C
Cleber Rosa 已提交
128
                  'remote = avocado.plugins.remote:Remote',
A
Amador Pahim 已提交
129
                  'replay = avocado.plugins.replay:Replay',
130
                  'tap = avocado.plugins.tap:TAP',
C
Cleber Rosa 已提交
131
                  'vm = avocado.plugins.vm:VM',
132
                  'docker = avocado.plugins.docker:Docker',
C
Cleber Rosa 已提交
133
                  ],
C
Cleber Rosa 已提交
134
              'avocado.plugins.cli.cmd': [
C
Cleber Rosa 已提交
135
                  'config = avocado.plugins.config:Config',
C
Cleber Rosa 已提交
136
                  'distro = avocado.plugins.distro:Distro',
C
Cleber Rosa 已提交
137
                  'exec-path = avocado.plugins.exec_path:ExecPath',
C
Cleber Rosa 已提交
138
                  'multiplex = avocado.plugins.multiplex:Multiplex',
C
Cleber Rosa 已提交
139
                  'list = avocado.plugins.list:List',
C
Cleber Rosa 已提交
140
                  'run = avocado.plugins.run:Run',
C
Cleber Rosa 已提交
141
                  'sysinfo = avocado.plugins.sysinfo:SysInfo',
142
                  'plugins = avocado.plugins.plugins:Plugins',
A
Amador Pahim 已提交
143
                  'diff = avocado.plugins.diff:Diff',
144 145 146 147
                  ],
              'avocado.plugins.job.prepost': [
                  'jobscripts = avocado.plugins.jobscripts:JobScripts',
                  ],
C
Cleber Rosa 已提交
148 149
              'avocado.plugins.result': [
                  'xunit = avocado.plugins.xunit:XUnitResult',
C
Cleber Rosa 已提交
150
                  'json = avocado.plugins.jsonresult:JSONResult',
C
Cleber Rosa 已提交
151
                  ],
C
Cleber Rosa 已提交
152
              },
H
Hao Liu 已提交
153
          zip_safe=False,
154 155
          test_suite='selftests',
          python_requires='>=2.6')