This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/
setup.py
executable file
·136 lines (109 loc) · 4.47 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import subprocess
import sys
import devassistant
try:
from setuptools import setup, find_packages, Command
except:
from distutils.core import setup, find_packages, Command
class GeneralTest(Command):
def finalize_options(self):
pass
def runner_exists(self, runner):
syspaths = os.getenv('PATH').split(os.pathsep)
for p in syspaths:
if os.path.exists(os.path.join(p, runner)):
return True
return False
class PyTest(GeneralTest):
user_options = [('test-runner=',
't',
'test runner to use; by default, multiple py.test runners are tried')]
command_consumes_arguments = True
def initialize_options(self):
self.test_runner = None
self.args = []
def run(self):
# if user provides a runner and it's not found, this fails
# otherwise it first tries various versioned runners and if it doesn't
# find any, it tries "py.test" - if that's not found either, this fails
supported = ['2.6', '2.7', '3.3', '3.4']
potential_runners = ['py.test-' + s for s in supported]
if self.test_runner:
potential_runners = [self.test_runner]
runners = [pr for pr in potential_runners if self.runner_exists(pr)]
if len(runners) == 0:
if not self.test_runner and self.runner_exists('py.test'):
runners = ['py.test']
else:
print('No py.test runners found, can\'t run tests.', file=sys.stderr)
print('Tried: {0}.'.format(', '.join(runners + ['py.test'])), file=sys.stderr)
raise SystemExit(100)
for runner in runners:
if len(runners) > 1:
print('\n' * 2)
print('Running tests using "{0}":'.format(runner))
retcode = 0
cmd = [runner]
for a in self.args:
cmd.append(a)
cmd.append('test')
t = subprocess.Popen(cmd)
rc = t.wait()
retcode = t.returncode or retcode
raise SystemExit(retcode)
class GUITest(GeneralTest):
user_options = []
command_consumes_arguments = True
def initialize_options(self):
self.args = []
def run(self):
if not self.runner_exists('behave'):
print('"behave" not found in PATH, can\'t run GUI tests.', file=sys.stderr)
raise SystemExit(100)
t = subprocess.Popen(['behave', '-k'] + self.args)
rc = t.wait()
raise SystemExit(t.returncode)
def _get_requirements(path):
with open(path) as f:
packages = f.read().splitlines()
packages = (p.strip() for p in packages if not p.startswith('#'))
packages = list(filter(None, packages))
return packages
def _install_requirements():
requirements = _get_requirements('requirements.txt')
if sys.version_info[0] < 3:
requirements += _get_requirements('requirements-py2.txt')
return requirements
description = ''.join(open('README.rst').readlines())
setup(
name = 'devassistant',
version = devassistant.__version__,
description = 'DevAssistant helps you kickstart your projects with ease.',
long_description = description,
keywords = 'develop,kickstart,easy,quick',
author = 'Bohuslav "Slavek" Kabrda',
author_email = 'bkabrda@redhat.com',
url = 'https://github.com/bkabrda/devassistant',
license = 'GPLv2+',
packages = find_packages(exclude=["test", "*test.*"]),
include_package_data = True,
entry_points = {'console_scripts':['da=devassistant.cli.cli_runner:CliRunner.run',
'da-gui=devassistant.gui:run_gui',
'devassistant=devassistant.cli.cli_runner:CliRunner.run',
'devassistant-gui=devassistant.gui:run_gui']},
install_requires=_install_requirements(),
setup_requires = [],
classifiers = ['Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Topic :: Software Development',
],
cmdclass = {'test': PyTest, 'guitest': GUITest}
)