-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·180 lines (156 loc) · 5.19 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env python3
# degu: an embedded HTTP server and client library
# Copyright (C) 2014-2016 Novacut Inc
#
# This file is part of `degu`.
#
# `degu` is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# `degu` is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with `degu`. If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
# Jason Gerard DeRose <jderose@novacut.com>
"""
Install `degu`.
"""
MIN_PY = (3, 8)
import sys
if sys.version_info < MIN_PY:
sys.exit('ERROR: degu requires Python {}.{} or newer'.format(*MIN_PY))
import os
from os import path
import subprocess
from distutils.core import setup, Extension
from distutils.cmd import Command
import degu
from degu.tests.run import run_tests
TREE = path.dirname(path.abspath(__file__))
with open(path.join(TREE, 'README'), 'r', encoding='utf-8') as fp:
LONG_DESCRIPTION = fp.read()
def run_under_same_interpreter(opname, script, args):
print('\n** running: {}...'.format(script), file=sys.stderr)
if not os.access(script, os.R_OK | os.X_OK):
print('ERROR: cannot read and execute: {!r}'.format(script),
file=sys.stderr
)
print('Consider running `setup.py test --skip-{}`'.format(opname),
file=sys.stderr
)
sys.exit(3)
cmd = [sys.executable, script] + args
print('check_call:', cmd, file=sys.stderr)
subprocess.check_call(cmd)
print('** PASSED: {}\n'.format(script), file=sys.stderr)
def run_sphinx_doctest():
script = '/usr/share/sphinx/scripts/python3/sphinx-build'
doc = path.join(TREE, 'doc')
doctest = path.join(TREE, 'doc', '_build', 'doctest')
args = ['-EW', '-b', 'doctest', doc, doctest]
run_under_same_interpreter('sphinx', script, args)
def run_pyflakes3():
script = '/usr/bin/pyflakes3'
names = [
'degu',
'setup.py',
'benchmark.py',
'benchmark-parsing.py',
'benchmark-ssl.py',
]
args = [path.join(TREE, name) for name in names]
run_under_same_interpreter('flakes', script, args)
class Test(Command):
description = 'run unit tests and doctests'
user_options = [
('skip-sphinx', None, 'do not run Sphinx doctests'),
('skip-flakes', None, 'do not run pyflakes static checks'),
('skip-slow', None, 'skip the rather slow socket timeout tests'),
]
def initialize_options(self):
self.skip_sphinx = 0
self.skip_flakes = 0
self.skip_slow = 0
def finalize_options(self):
pass
def run(self):
if self.skip_slow:
os.environ['DEGU_TEST_SKIP_SLOW'] = 'true'
if not run_tests():
sys.exit(2)
if not self.skip_sphinx:
run_sphinx_doctest()
if not self.skip_flakes:
run_pyflakes3()
ext_kw = {
'sources': ['degu/_base.c'],
'extra_compile_args': [
'-Werror', # Make warnings into errors
'-Wall',
'-Wsign-compare',
'-Wsign-conversion',
'-Wmissing-field-initializers',
'-Wfatal-errors',
'-std=gnu11',
'-pedantic-errors',
'-Wpedantic',
],
}
if os.environ.get('DEGU_INSTRUMENT_BUILD') == 'true':
ext_kw['extra_compile_args'].extend([
'-g3',
'-fno-omit-frame-pointer',
'-fsanitize=address',
'-fsanitize=undefined',
'-fsanitize=shift',
'-fsanitize=integer-divide-by-zero',
'-fsanitize=unreachable',
'-fsanitize=vla-bound',
'-fsanitize=null',
'-fsanitize=return',
'-fsanitize=signed-integer-overflow',
])
ext_kw['libraries'] = ['asan', 'ubsan']
setup(
name='degu',
description='Embedded HTTP server and client library',
long_description=LONG_DESCRIPTION,
url='https://launchpad.net/degu',
version=degu.__version__,
author='Jason Gerard DeRose',
author_email='jderose@novacut.com',
license='LGPLv3+',
packages=[
'degu',
'degu.tests',
],
ext_modules=[
Extension('degu._base', **ext_kw),
],
cmdclass={
'test': Test,
},
platforms=['POSIX'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: C',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)