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
# pylint: disable=E0611
19

20
from setuptools import setup
21

22
from avocado import VERSION
23

24

25
VIRTUAL_ENV = 'VIRTUAL_ENV' in os.environ
C
Cleber Rosa 已提交
26 27


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


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


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


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

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


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


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

105 106
if __name__ == '__main__':
    setup(name='avocado',
107
          version=VERSION,
108 109 110 111 112
          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 已提交
113
          use_2to3=True,
114 115 116
          packages=['avocado',
                    'avocado.core',
                    'avocado.utils',
117
                    'avocado.utils.external',
118
                    'avocado.core.remote',
119 120 121
                    'avocado.core.restclient',
                    'avocado.core.restclient.cli',
                    'avocado.core.restclient.cli.args',
122 123
                    'avocado.core.restclient.cli.actions',
                    'avocado.plugins'],
124 125
          package_data={'avocado.core': _get_resource_files(
              'avocado/core/resources')},
126
          data_files=get_data_files(),
127
          scripts=['scripts/avocado',
128
                   'scripts/avocado-rest-client'],
C
Cleber Rosa 已提交
129
          entry_points={
C
Cleber Rosa 已提交
130 131
              'avocado.plugins.cli': [
                  'gdb = avocado.plugins.gdb:GDB',
C
Cleber Rosa 已提交
132
                  'wrapper = avocado.plugins.wrapper:Wrapper',
C
Cleber Rosa 已提交
133
                  'xunit = avocado.plugins.xunit:XUnit',
C
Cleber Rosa 已提交
134
                  'json = avocado.plugins.json:JSON',
C
Cleber Rosa 已提交
135
                  'journal = avocado.plugins.journal:Journal',
C
Cleber Rosa 已提交
136
                  'html = avocado.plugins.html:HTML',
C
Cleber Rosa 已提交
137
                  'remote = avocado.plugins.remote:Remote',
A
Amador Pahim 已提交
138
                  'replay = avocado.plugins.replay:Replay',
C
Cleber Rosa 已提交
139
                  'vm = avocado.plugins.vm:VM',
C
Cleber Rosa 已提交
140
                  ],
C
Cleber Rosa 已提交
141
              'avocado.plugins.cli.cmd': [
C
Cleber Rosa 已提交
142
                  'config = avocado.plugins.config:Config',
C
Cleber Rosa 已提交
143
                  'distro = avocado.plugins.distro:Distro',
C
Cleber Rosa 已提交
144
                  'exec-path = avocado.plugins.exec_path:ExecPath',
C
Cleber Rosa 已提交
145
                  'multiplex = avocado.plugins.multiplex:Multiplex',
C
Cleber Rosa 已提交
146
                  'list = avocado.plugins.list:List',
C
Cleber Rosa 已提交
147
                  'run = avocado.plugins.run:Run',
C
Cleber Rosa 已提交
148
                  'sysinfo = avocado.plugins.sysinfo:SysInfo',
149
                  'plugins = avocado.plugins.plugins:Plugins',
150 151 152 153
                  ],
              'avocado.plugins.job.prepost': [
                  'jobscripts = avocado.plugins.jobscripts:JobScripts',
                  ],
C
Cleber Rosa 已提交
154
              },
H
Hao Liu 已提交
155
          zip_safe=False,
156
          test_suite='selftests')