setup.py 7.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
VERSION = open('VERSION', 'r').read().strip()
25
VIRTUAL_ENV = hasattr(sys, 'real_prefix')
C
Cleber Rosa 已提交
26

Y
Yanan Fu 已提交
27 28 29 30 31
if sys.version_info[:2] >= (2, 7):
    stevedore_version = 'stevedore>=1.8.0'
else:
    stevedore_version = 'stevedore>=1.8.0,<=1.10.0'

C
Cleber Rosa 已提交
32

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


52 53
def get_tests_dir():
    return get_dir(['usr', 'share', 'avocado', 'tests'], ['tests'])
54 55


56 57 58 59 60 61 62 63 64
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'])


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

89
    data_files.append((get_avocado_libexec_dir(), glob.glob('libexec/*')))
90 91 92
    return data_files


93
def _get_resource_files(path, base):
94 95 96 97 98 99 100
    """
    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)
101
            flist.append(fullname[len(base):])
102 103 104
    return flist


105 106 107 108 109
def get_long_description():
    with open('README.rst', 'r') as req:
        req_contents = req.read()
    return req_contents

L
Lukáš Doktor 已提交
110

111
if __name__ == '__main__':
112
    setup(name='avocado-framework',
113
          version=VERSION,
114 115 116 117 118
          description='Avocado Test Framework',
          long_description=get_long_description(),
          author='Avocado Developers',
          author_email='avocado-devel@redhat.com',
          url='http://avocado-framework.github.io/',
119 120 121 122 123 124 125 126 127 128
          license="GPLv2+",
          classifiers=[
              "Development Status :: 5 - Production/Stable",
              "Intended Audience :: Developers",
              "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
              "Natural Language :: English",
              "Operating System :: POSIX",
              "Topic :: Software Development :: Quality Assurance",
              "Topic :: Software Development :: Testing",
              ],
C
Cleber Rosa 已提交
129
          use_2to3=True,
C
Cleber Rosa 已提交
130
          packages=find_packages(exclude=('selftests*',)),
131
          data_files=get_data_files(),
132
          scripts=['scripts/avocado',
133
                   'scripts/avocado-rest-client'],
C
Cleber Rosa 已提交
134
          entry_points={
C
Cleber Rosa 已提交
135
              'avocado.plugins.cli': [
136
                  'envkeep = avocado.plugins.envkeep:EnvKeep',
C
Cleber Rosa 已提交
137
                  'gdb = avocado.plugins.gdb:GDB',
C
Cleber Rosa 已提交
138
                  'wrapper = avocado.plugins.wrapper:Wrapper',
C
Cleber Rosa 已提交
139
                  'xunit = avocado.plugins.xunit:XUnitCLI',
C
Cleber Rosa 已提交
140
                  'json = avocado.plugins.jsonresult:JSONCLI',
C
Cleber Rosa 已提交
141
                  'journal = avocado.plugins.journal:Journal',
C
Cleber Rosa 已提交
142
                  'remote = avocado.plugins.remote:Remote',
A
Amador Pahim 已提交
143
                  'replay = avocado.plugins.replay:Replay',
144
                  'tap = avocado.plugins.tap:TAP',
C
Cleber Rosa 已提交
145
                  'vm = avocado.plugins.vm:VM',
146
                  'docker = avocado.plugins.docker:Docker',
147
                  'yaml_to_mux = avocado.plugins.yaml_to_mux:YamlToMux',
148
                  'zip_archive = avocado.plugins.archive:ArchiveCLI',
C
Cleber Rosa 已提交
149
                  ],
C
Cleber Rosa 已提交
150
              'avocado.plugins.cli.cmd': [
C
Cleber Rosa 已提交
151
                  'config = avocado.plugins.config:Config',
C
Cleber Rosa 已提交
152
                  'distro = avocado.plugins.distro:Distro',
C
Cleber Rosa 已提交
153
                  'exec-path = avocado.plugins.exec_path:ExecPath',
C
Cleber Rosa 已提交
154
                  'multiplex = avocado.plugins.multiplex:Multiplex',
C
Cleber Rosa 已提交
155
                  'list = avocado.plugins.list:List',
C
Cleber Rosa 已提交
156
                  'run = avocado.plugins.run:Run',
C
Cleber Rosa 已提交
157
                  'sysinfo = avocado.plugins.sysinfo:SysInfo',
158
                  'plugins = avocado.plugins.plugins:Plugins',
A
Amador Pahim 已提交
159
                  'diff = avocado.plugins.diff:Diff',
160 161 162 163
                  ],
              'avocado.plugins.job.prepost': [
                  'jobscripts = avocado.plugins.jobscripts:JobScripts',
                  ],
C
Cleber Rosa 已提交
164 165
              'avocado.plugins.result': [
                  'xunit = avocado.plugins.xunit:XUnitResult',
C
Cleber Rosa 已提交
166
                  'json = avocado.plugins.jsonresult:JSONResult',
167
                  'zip_archive = avocado.plugins.archive:Archive',
C
Cleber Rosa 已提交
168
                  ],
169 170
              'avocado.plugins.result_events': [
                  'human = avocado.plugins.human:Human',
171
                  'tap = avocado.plugins.tap:TAPResult',
172
                  'journal = avocado.plugins.journal:JournalResult',
173
                  ],
C
Cleber Rosa 已提交
174
              },
H
Hao Liu 已提交
175
          zip_safe=False,
176
          test_suite='selftests',
177
          python_requires='>=2.6',
Y
Yanan Fu 已提交
178
          install_requires=[stevedore_version])