forked from bluelabsio/sqlalchemy-vertica-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
112 lines (94 loc) · 3.78 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
from decimal import Decimal
from distutils.cmd import Command
from setuptools import setup
from setuptools.command.install import install
import os.path
import sys
__version__ = '0.5.10'
# From https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
class VerifyVersionCommand(install):
"""Custom command to verify that the git tag matches our version"""
description = 'verify that the git tag matches our version'
def run(self):
from setup import __version__
tag = os.getenv('CIRCLE_TAG')
tag_formatted_version = 'v{}'.format(__version__)
if tag != tag_formatted_version:
info = "Git tag: {0} does not match the version of this app: {1}".format(
tag, __version__
)
sys.exit(info)
class CoverageRatchetCommand(Command):
description = 'Run coverage ratchet'
user_options = [] # type: ignore
def finalize_options(self) -> None:
pass
def run(self) -> None:
"""Run command."""
import xml.etree.ElementTree as ET
tree = ET.parse(self.coverage_source_file)
new_coverage = Decimal(tree.getroot().attrib["line-rate"]) * 100
if not os.path.exists(self.coverage_file):
with open(self.coverage_file, 'w') as f:
f.write('0')
with open(self.coverage_file, 'r') as f:
high_water_mark = Decimal(f.read())
if new_coverage < high_water_mark:
raise Exception(
"{} coverage used to be {}; "
"down to {}%. Fix by viewing '{}'".format(self.type_of_coverage,
high_water_mark,
new_coverage,
self.coverage_url))
elif new_coverage > high_water_mark:
with open(self.coverage_file, 'w') as f:
f.write(str(new_coverage))
print("Just ratcheted coverage up to {}%".format(new_coverage))
else:
print("Code coverage steady at {}%".format(new_coverage))
class TestCoverageRatchetCommand(CoverageRatchetCommand):
def initialize_options(self) -> None:
"""Set default values for options."""
self.type_of_coverage = 'Test'
self.coverage_url = 'cover/index.html'
self.coverage_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'metrics',
'coverage_high_water_mark'
)
self.coverage_source_file = "coverage.xml"
setup(
name='sqlalchemy-vertica-python',
version=__version__,
description='Vertica dialect for sqlalchemy using vertica_python',
long_description=open("README.rst").read(),
license="MIT",
url='https://github.com/bluelabsio/sqlalchemy-vertica-python',
download_url = 'https://github.com/bluelabsio/sqlalchemy-vertica-python/tarball/{}'.format(__version__),
author='James Casbon, Luke Emery-Fertitta',
maintainer='Vince Broz',
maintainer_email='[email protected]',
packages=[
'sqla_vertica_python',
],
keywords=['sqlalchemy', 'vertica', 'python'],
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
entry_points="""
[sqlalchemy.dialects]
vertica.vertica_python = sqla_vertica_python.vertica_python:VerticaDialect
""",
install_requires=[
'vertica_python'
],
cmdclass={
'coverage_ratchet': TestCoverageRatchetCommand,
'verify': VerifyVersionCommand,
},
)