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

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

22

23
VIRTUAL_ENV = 'VIRTUAL_ENV' in os.environ
C
Cleber Rosa 已提交
24 25


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


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


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


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

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


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


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

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