forked from maximdanilchenko/aiochclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·109 lines (92 loc) · 3.63 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
import warnings
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
from setuptools import Extension, find_packages, setup
try:
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False
ext = '.pyx' if USE_CYTHON else '.c'
extensions = [Extension("aiochclient._types", ["aiochclient/_types" + ext])]
if USE_CYTHON:
extensions = cythonize(extensions, compiler_directives={'language_level': 3})
class BuildFailed(Exception):
pass
# This class was copy/paced from
# https://github.com/aio-libs/aiohttp/blob/master/setup.py
class ve_build_ext(build_ext):
# This class allows C extension building to fail.
def run(self):
try:
build_ext.run(self)
except (DistutilsPlatformError, FileNotFoundError):
raise BuildFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
raise BuildFailed()
def read(fname):
with open(fname, encoding="utf8") as fp:
content = fp.read()
return content
setup_opts = dict(
name='aiochclient',
version='1.4.0',
description='Async http clickhouse client for python 3.6+',
long_description=read('README.md'),
long_description_content_type="text/markdown",
author='Danilchenko Maksim',
author_email='[email protected]',
packages=find_packages(exclude=('test*',)),
package_dir={'aiochclient': 'aiochclient'},
include_package_data=True,
# aiohttp in main requires will be deprecated since 2.0.0
install_requires=['sqlparse>=0.3.0', 'aiohttp>=3.0.1'],
license='MIT',
url='https://github.com/maximdanilchenko/aiochclient',
zip_safe=False,
keywords='clickhouse async python aiohttp',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
test_suite='tests',
ext_modules=extensions,
extras_require={
# aiohttp client
'aiohttp': ['aiohttp>=3.0.1'],
'aiohttp-speedups': ['aiodns', 'cchardet', 'ciso8601>=2.1.1', 'aiohttp>=3.0.1'],
# httpx client
'httpx': ['httpx'],
'httpx-speedups': ['ciso8601>=2.1.1', 'httpx'],
# will be deprecated since 2.0.0:
'speedups': ['aiodns', 'cchardet', 'ciso8601>=2.1.1', 'aiohttp>=3.0.1'],
},
cmdclass=dict(build_ext=ve_build_ext),
)
try:
setup(**setup_opts)
except BuildFailed:
print("************************************************************")
print("Cannot compile C accelerator module, use pure python version")
print("************************************************************")
del setup_opts['ext_modules']
del setup_opts['cmdclass']
setup(**setup_opts)
finally:
warnings.warn(
"aiohttp in main requires will be deprecated"
" since 2.0.0. Please specify aiohttp or httpx in dependeces or use "
"'pip install aiochclient[aiohttp]' or 'pip install "
"aiochclient[aiohttp-speedups]' for aiohttp client usage or "
"'pip install aiochclient[httpx]' or pip install "
"aiochclient[httpx-speedups] for httpx client usage!",
DeprecationWarning,
)