forked from belvedere-trading/vigilance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·65 lines (57 loc) · 2.07 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
#pylint: skip-file
from __future__ import print_function
import re
import six
import subprocess
import sys
from distutils.cmd import Command
from setuptools import setup, find_packages
def run_with_exit(command):
returnCode = subprocess.call(command)
if returnCode:
sys.exit(returnCode)
class TestWithCoverage(Command):
"""Runs unit tests along with a test coverage report.
"""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
run_with_exit(['coverage', 'run', 'setup.py', 'nosetests'])
run_with_exit(['coverage', 'report', '-m'])
run_with_exit(['coverage', 'xml'])
tag_regex = re.compile(r'v\d\.\d\.\d')
def get_tagged_version():
process = subprocess.Popen(['git', 'describe', '--abbrev=0'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
out = six.ensure_text(out)
if process.returncode:
print('Failed to get tagged version: {}'.format(err))
sys.exit(process.returncode)
out = out.strip()
if not re.match(tag_regex, out):
print('Found invalid tag: {}'.format(out))
sys.exit(-1)
return out[1:]
if __name__ == '__main__':
thirdPartyPackages = open('required_packages.req').read().splitlines()
testPackages = open('test_required_packages.req').read().splitlines()
consoleScripts = ['vigilance = vigilance.cli:main']
setup(name='vigilance',
version=get_tagged_version(),
author='Belvedere Trading',
author_email='jkaye@belvederetrading.com',
packages=find_packages(),
url='http://pypi:28080/simple/Vigilance/',
description='A utility for enforcing minimum code coverage',
install_requires=thirdPartyPackages,
tests_require=testPackages,
test_loader='nose.loader:TestLoader',
test_suite='vigilance',
entry_points={
'console_scripts': consoleScripts
},
scripts=['doxypy_filter'],
cmdclass={'coverage': TestWithCoverage})