forked from ansible/pytest-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
141 lines (118 loc) · 4.21 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
import sys
import glob
import shutil
from setuptools import setup, Command, find_packages
from setuptools.command.test import test as TestCommand
from pytest_ansible import __version__, __author__, __author_email__
class ToxTestCommand(TestCommand):
"""Test command which runs tox under the hood."""
user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
def initialize_options(self):
"""Initialize options and set their defaults."""
TestCommand.initialize_options(self)
self.tox_args = '--recreate'
def finalize_options(self):
"""Add options to the test runner (tox)."""
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
"""Invoke the test runner (tox)."""
# import here, cause outside the eggs aren't loaded
import tox
import shlex
errno = tox.cmdline(args=shlex.split(self.tox_args))
sys.exit(errno)
class CleanCommand(Command):
description = "Custom clean command that forcefully removes dist/build directories"
user_options = []
def initialize_options(self):
self.cwd = None
def finalize_options(self):
self.cwd = os.getcwd()
def run(self):
assert os.getcwd() == self.cwd, 'Must be in package root: %s' % self.cwd
# List of things to remove
rm_list = list()
# Find any .pyc files or __pycache__ dirs
for root, dirs, files in os.walk(self.cwd, topdown=False):
for fname in files:
if fname.endswith('.pyc') and os.path.isfile(os.path.join(root, fname)):
rm_list.append(os.path.join(root, fname))
if root.endswith('__pycache__') or root.endswith('.cache') or root.endswith('.ansible') or \
root.endswith('.eggs') or root.endswith('.tox'):
rm_list.append(root)
# Find egg's
for egg_dir in glob.glob('*.egg') + glob.glob('*egg-info'):
rm_list.append(egg_dir)
# Zap!
for rm in rm_list:
if self.verbose:
print "Removing '%s'" % rm
if os.path.isdir(rm):
if not self.dry_run:
shutil.rmtree(rm)
else:
if not self.dry_run:
os.remove(rm)
def long_description(*paths):
'''Returns a RST formated string.
'''
result = ''
# attempt to import pandoc
try:
import pypandoc
except (ImportError, OSError), e:
print "Unable to import pypandoc - %s" % e
return result
# attempt md -> rst conversion
try:
for path in paths:
result += '\n' + pypandoc.convert(
path, 'rst', format='markdown'
)
except (OSError, IOError), e:
print "Failed to convert with pypandoc - %s" % e
return result
return result
setup(
name="pytest-ansible",
version=__version__,
description='Plugin for py.test to allow running ansible',
long_description=long_description('README.md', 'HISTORY.md'),
license='MIT',
keywords='py.test pytest ansible',
author=__author__,
author_email=__author_email__,
url='http://github.com/jlaska/pytest-ansible',
platforms='any',
packages=find_packages(),
entry_points={
'pytest11': [
'pytest-ansible = pytest_ansible.plugin'
],
},
zip_safe=False,
tests_require=['tox'],
# setup_requires=['pypandoc<1.2.0', 'setuptools-markdown'],
setup_requires=['setuptools-markdown'],
install_requires=['ansible', 'pytest'],
cmdclass={
'test': ToxTestCommand,
'clean': CleanCommand,
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Topic :: Software Development :: Testing',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Utilities',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7 ',
],
)