setup.py 4.2 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 distutils.core import setup
21 22 23

import avocado.version

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

def get_settings_dir():
    settings_system_wide = os.path.join('/etc', 'avocado')
    settings_local_install = os.path.join('etc', 'avocado')
    if 'VIRTUAL_ENV' in os.environ:
        return settings_local_install
    else:
        return settings_system_wide


def get_tests_dir():
    settings_system_wide = os.path.join('/usr', 'share', 'avocado', 'tests')
    settings_local_install = os.path.join('tests')
    if 'VIRTUAL_ENV' in os.environ:
        return settings_local_install
    else:
        return settings_system_wide


C
Cleber Rosa 已提交
43 44 45 46 47 48 49 50 51
def get_docs_dir():
    settings_system_wide = os.path.join('/usr', 'share', 'doc', 'avocado')
    settings_local_install = ''
    if 'VIRTUAL_ENV' in os.environ:
        return settings_local_install
    else:
        return settings_system_wide


52 53 54 55 56 57 58 59 60
def get_wrappers_dir():
    settings_system_wide = os.path.join('/usr', 'share', 'avocado', 'wrappers')
    settings_local_install = 'wrappers'
    if 'VIRTUAL_ENV' in os.environ:
        return settings_local_install
    else:
        return settings_system_wide


61 62 63 64 65 66 67 68 69
def get_api_dir():
    settings_system_wide = os.path.join('/usr', 'share', 'avocado', 'api')
    settings_local_install = 'api'
    if 'VIRTUAL_ENV' in os.environ:
        return settings_local_install
    else:
        return settings_system_wide


70
def get_data_files():
71 72
    data_files = [(get_settings_dir(), ['etc/avocado/avocado.conf'])]
    data_files += [(os.path.join(get_settings_dir(), 'conf.d'), ['etc/avocado/conf.d/README'])]
73 74
    data_files += [(get_tests_dir(), glob.glob('examples/tests/*.py'))]
    for data_dir in glob.glob('examples/tests/*.data'):
75
        fmt_str = '%s/*' % data_dir
76 77
        for f in glob.glob(fmt_str):
            data_files += [(os.path.join(get_tests_dir(), os.path.basename(data_dir)), [f])]
78
    data_files.append((get_docs_dir(), ['man/avocado.rst', 'man/avocado-rest-client.rst']))
79
    data_files += [(get_wrappers_dir(), glob.glob('examples/wrappers/*.sh'))]
80
    data_files += [(get_api_dir(), glob.glob('examples/api/*/*.py'))]
81 82 83
    return data_files


84 85 86 87 88 89 90 91 92 93 94 95
def _get_plugin_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/plugins/'):])
    return flist


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

101 102 103 104 105 106 107 108 109 110 111 112 113 114
if __name__ == '__main__':
    setup(name='avocado',
          version=avocado.version.VERSION,
          description='Avocado Test Framework',
          long_description=get_long_description(),
          author='Avocado Developers',
          author_email='avocado-devel@redhat.com',
          url='http://avocado-framework.github.io/',
          packages=['avocado',
                    'avocado.cli',
                    'avocado.core',
                    'avocado.external',
                    'avocado.linux',
                    'avocado.utils',
115
                    'avocado.plugins',
116
                    'avocado.remote',
117 118 119 120
                    'avocado.restclient',
                    'avocado.restclient.cli',
                    'avocado.restclient.cli.args',
                    'avocado.restclient.cli.actions'],
121 122 123
          package_data={'avocado.plugins': _get_plugin_resource_files(
              'avocado/plugins/resources')},
          data_files=get_data_files(),
124 125
          scripts=['scripts/avocado',
                   'scripts/avocado-rest-client'])