-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
executable file
·93 lines (73 loc) · 2.75 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=C0111,C0103
# setup.py
from codecs import open as copen
import os
import re
import sys
from setuptools import setup, find_packages
PACKAGE_NAME = 'dockerhub-webhook'
HERE = os.path.dirname(__file__)
with copen(os.path.join(HERE, 'README.rst'), encoding='utf8') as fpt:
README = fpt.read()
def read(*subpaths):
path = os.path.join(HERE, *subpaths)
with copen(path, encoding='utf8') as fobj:
return fobj.read()
def get_metavar(metavar, *paths):
metavar_file = read(*paths)
metavar_patern = r'''^__{}__\s*=\s*['"](?P<var>.*)['"]'''.format(metavar)
var_match = re.search(metavar_patern, metavar_file, re.M)
if var_match:
return var_match.group('var')
raise RuntimeError('{} string not found'.format(metavar))
with copen(os.path.join(HERE, 'requirements.txt'), encoding='utf8') as fpt:
install_requires = [l.strip() for l in fpt.readlines()]
VERSION = get_metavar('version', 'dockerhook', '__init__.py')
if sys.argv[-1] == 'publish':
os.system("python setup.py sdist upload")
os.system("python setup.py bdist_wheel upload")
sys.exit()
if sys.argv[-1] == 'tag':
os.system("git tag -a %s -m 'version %s'" % (VERSION, VERSION))
os.system("git push --tags")
sys.exit()
tests_require = [
'pytest >=3.0.6',
'pytest-mock >=1.5.0',
'pytest-cov >=2.4.0',
]
setup_requires = [
'pytest-runner >=2.10.1'
]
setup(name=PACKAGE_NAME,
version=get_metavar('version', 'dockerhook', '__init__.py'),
description='Webhook handler for dockerhub autodeployments',
long_description=README,
author=get_metavar('author', 'dockerhook', '__init__.py'),
author_email=get_metavar('email', 'dockerhook', '__init__.py'),
url='https://github.com/Praisebetoscience/dockerhub-webhook',
keywords='dockerhub webhook handler',
license=get_metavar('license', 'dockerhook', '__init__.py'),
packages=find_packages(exclude=['tests.*', 'tests', 'venv']),
package_data={'': 'LICENSE'},
install_requires=install_requires,
setup_requires=setup_requires,
tests_require=tests_require,
test_suite='tests',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Framework :: Flask',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Utilities'
]
)