forked from NoneGG/aredis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
166 lines (135 loc) · 4.76 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
#!/usr/bin/env python
import re
import sys
import pathlib
try:
from setuptools import setup
from setuptools.command.test import test as TestCommand
from setuptools.command.build_ext import build_ext
from setuptools.extension import Extension
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, because outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
except ImportError:
from distutils.core import setup, Extension
from distutils.command.build_ext import build_ext
def PyTest(x):
x
class custom_build_ext(build_ext):
"""
NOTE: This code was originally taken from tornado.
Allows C extension building to fail.
The C extension speeds up crc16, but is not essential.
"""
warning_message = """
********************************************************************
{target} could not
be compiled. No C extensions are essential for aredis to run,
although they do result in significant speed improvements for
websockets.
{comment}
Here are some hints for popular operating systems:
If you are seeing this message on Linux you probably need to
install GCC and/or the Python development package for your
version of Python.
Debian and Ubuntu users should issue the following command:
$ sudo apt-get install build-essential python-dev
RedHat and CentOS users should issue the following command:
$ sudo yum install gcc python-devel
Fedora users should issue the following command:
$ sudo dnf install gcc python-devel
If you are seeing this message on OSX please read the documentation
here:
https://api.mongodb.org/python/current/installation.html#osx
********************************************************************
"""
def run(self):
try:
super().run()
except Exception as e:
self.warn(e)
self.warn(
self.warning_message.format(
target="Extension modules",
comment=(
"There is an issue with your platform configuration "
"- see above."
)
)
)
def build_extension(self, ext):
try:
super().build_extension(ext)
except Exception as e:
self.warn(e)
self.warn(
self.warning_message.format(
target="The {} extension ".format(ext.name),
comment=(
"The output above this warning shows how the "
"compilation failed."
)
)
)
_ROOT_DIR = pathlib.Path(__file__).parent
with open(str(_ROOT_DIR / 'README.rst')) as f:
long_description = f.read()
with open(str(_ROOT_DIR / 'aredis' / '__init__.py')) as f:
str_regex = r"['\"]([^'\"]*)['\"]"
try:
version = re.findall(
r"^__version__ = {}$".format(str_regex), f.read(), re.MULTILINE
)[0]
except IndexError:
raise RuntimeError("Unable to find version in __init__.py")
setup(
name='aredis',
version=version,
description='Python async client for Redis key-value store',
long_description=long_description,
url='https://github.com/NoneGG/aredis',
author='Jason Chen',
author_email='[email protected]',
maintainer='Jason Chen',
maintainer_email='[email protected]',
keywords=['Redis', 'key-value store', 'asyncio'],
license='MIT',
packages=['aredis', 'aredis.commands'],
python_requires=">=3.5",
extras_require={'hiredis': ['hiredis>=0.2.0']},
tests_require=['pytest',
'pytest_asyncio>=0.5.0'],
cmdclass={
'test': PyTest,
'build_ext': custom_build_ext
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8'
],
ext_modules=[
Extension(name='aredis.speedups',
sources=['aredis/speedups.c']),
],
# The good news is that the standard library always
# takes the precedence over site packages,
# so even if a local contextvars module is installed,
# the one from the standard library will be used.
install_requires=[
'contextvars;python_version<"3.7"'
]
)