This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
133 lines (112 loc) · 3.79 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
# Copyright 2012 Nextdoor.com, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import shutil
import subprocess
from distutils.command.clean import clean
from distutils.command.sdist import sdist
from setuptools import Command
from setuptools import setup
from setuptools import find_packages
PACKAGE = 'hooky'
__version__ = None
execfile(os.path.join(PACKAGE, 'version.py')) # set __version__
class CheckCommand(Command):
descriptoin = 'Run tests.'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print 'Running pep8...'
if subprocess.call(['pep8', 'hooky']):
sys.exit('ERROR: failed pep8 checks')
print 'Running pyflakes...'
if subprocess.call(['pyflakes', 'hooky']):
sys.exit('ERROR: failed pyflakes checks')
print 'Running tests...'
if subprocess.call(['coverage', 'run', '--source=hooky',
'./setup.py', 'test']):
sys.exit('ERROR: failed unit tests')
subprocess.call(['coverage', 'report', '-m'])
class SourceDistHook(sdist):
"""Runs when creating the 'sdist' package.
Makes sure to create a vesrion.rst file for the source package
based on the version number found in the __version__ variable.
"""
def run(self):
with open('version.rst', 'w') as f:
f.write(':Version: %s\n' % __version__)
sdist.run(self)
class CleanHook(clean):
def run(self):
clean.run(self)
def maybe_rm(path):
if os.path.exists(path):
try:
shutil.rmtree(path)
except:
os.remove(path)
maybe_rm('hooky.egg-info')
maybe_rm('dist')
maybe_rm('.coverage')
maybe_rm('version.rst')
maybe_rm('MANIFEST')
setup(
name='hooky',
version=__version__,
description='Webhook Translation Gateway',
long_description=open('README.md', 'r').read(),
author='Matt Wise',
author_email='[email protected]',
url='https://github.com/Nextdoor/hooky',
download_url='http://pypi.python.org/pypi/hooky#downloads',
license='Apache License, Version 2.0',
keywords='web hook json post get',
entry_points={
'console_scripts': ['hooky = hooky.runserver:main'],
},
packages=find_packages(),
test_suite='hooky',
package_data={
'hooky': [ 'test_data/*/*', 'test_data/config.ini',
'test_data/config_missing_general.ini',
'static/*.tmpl', 'static/templates/*.tmpl',
'static/templates/*/*.tmpl',
'static/bootstrap/*/*'],
},
setup_requires=[ 'setuptools', 'coverage', 'unittest2' ],
install_requires=[
'tornado',
'pystache',
'xmltodict',
'setuptools',
],
classifiers=[
'Development Status :: 4 - Beta',
'Topic :: Software Development',
'License :: OSI Approved :: Apache Software License',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Operating System :: POSIX',
'Natural Language :: English',
],
cmdclass={
'sdist': SourceDistHook,
'clean': CleanHook,
'check': CheckCommand,
},
)