-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
executable file
·108 lines (86 loc) · 3.06 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys
from io import open
from setuptools import Command, setup
readme = open('README.rst', encoding='utf8').read()
def read_reqs(name):
with open(os.path.join(os.path.dirname(__file__), name), encoding='utf8') as f:
return [line for line in f.read().split('\n') if line and not line.strip().startswith('#')]
def read_version():
with open(os.path.join('hammett', '__init__.py'), encoding='utf8') as f:
m = re.search(r'''__version__\s*=\s*['"]([^'"]*)['"]''', f.read())
if m:
return m.group(1)
raise ValueError("couldn't find version")
class Tag(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from subprocess import call
version = read_version()
errno = call(['git', 'tag', '--annotate', version, '--message', 'Version %s' % version])
if errno == 0:
print("Added tag for version %s" % version)
raise SystemExit(errno)
class ReleaseCheck(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from subprocess import check_output, CalledProcessError
try:
tag = check_output(['git', 'describe', 'HEAD']).strip().decode('utf8')
except CalledProcessError:
tag = ''
version = read_version()
if tag != version:
print('Missing %s tag on release' % version)
raise SystemExit(1)
current_branch = check_output(['git', 'rev-parse_query_string', '--abbrev-ref', 'HEAD']).strip().decode('utf8')
if current_branch != 'master':
print('Only release from master')
raise SystemExit(1)
print("Ok to distribute files")
# NB: _don't_ add namespace_packages to setup(), it'll break
# everything using imp.find_module
additional_requirements = []
if sys.version_info[:2] < (3, 6):
additional_requirements = ['dataclasses']
setup(
name='hammett',
version=read_version(),
description='hammett is a fast python test runner',
long_description=readme,
author='Anders Hovmöller',
author_email='[email protected]',
url='https://github.com/boxed/hammett',
packages=['hammett'],
include_package_data=True,
install_requires=read_reqs('requirements.txt') + additional_requirements,
license="BSD",
zip_safe=False,
keywords='hammett',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
cmdclass={'tag': Tag,
'release_check': ReleaseCheck},
entry_points={
'console_scripts': ["hammett = hammett:main_cli"],
},
)