forked from RohanArepally/aiochclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
98 lines (81 loc) · 3.12 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
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='2.6.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,
install_requires=['sqlparse>=0.4.3'],
license='MIT',
url='https://github.com/maximdanilchenko/aiochclient',
zip_safe=False,
keywords='clickhouse async python aiohttp httpx',
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',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
test_suite='tests',
ext_modules=extensions,
extras_require={
# aiohttp client
'aiohttp': ['aiohttp>=3.8.4'],
'aiohttp-speedups': ['aiodns', 'faust-cchardet', 'ciso8601>=2.3.0', 'aiohttp>=3.8.4'],
# httpx client
'httpx': ['httpx'],
'httpx-speedups': ['ciso8601>=2.3.0', 'httpx'],
},
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)