setup.py 3.3 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 21 22 23

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup
24 25 26

import avocado.version

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

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 已提交
46 47 48 49 50 51 52 53 54
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


55 56
def get_data_files():
    data_files = [(get_settings_dir(), ['etc/settings.ini'])]
57 58
    data_files += [(get_tests_dir(), glob.glob('examples/tests/*.py'))]
    for data_dir in glob.glob('examples/tests/*.data'):
59
        fmt_str = '%s/*' % data_dir
60 61
        for f in glob.glob(fmt_str):
            data_files += [(os.path.join(get_tests_dir(), os.path.basename(data_dir)), [f])]
C
Cleber Rosa 已提交
62
    data_files.append((get_docs_dir(), ['man/avocado.rst']))
63 64 65
    return data_files


66 67 68 69 70 71 72 73 74 75 76 77
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


78 79 80 81 82 83 84 85 86 87
def get_requirements():
    requirements = []
    with open('requirements.txt', 'r') as req:
        req_contents = req.read()
        for line in req_contents.splitlines():
            if not line.startswith("#"):
                line = line.split("#")[0].strip()
                requirements.append("%s" % line)
    return requirements

88 89 90
setup(name='avocado',
      version=avocado.version.VERSION,
      description='Avocado Test Framework',
91 92
      author='Avocado Developers',
      author_email='avocado-devel@redhat.com',
C
Cleber Rosa 已提交
93
      url='http://github.com/avocado-framework/avocado',
94 95
      packages=['avocado',
                'avocado.cli',
96
                'avocado.core',
97
                'avocado.external',
98
                'avocado.linux',
R
Rudá Moura 已提交
99 100
                'avocado.utils',
                'avocado.plugins'],
101
      package_data={'avocado.plugins': _get_plugin_resource_files('avocado/plugins/resources')},
102
      data_files=get_data_files(),
103 104
      scripts=['scripts/avocado'],
      install_requires=get_requirements())