Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
singlestore-labs
GitHub Repository: singlestore-labs/singlestoredb-python
Path: blob/main/setup.py
464 views
1
#!/usr/bin/env python
2
"""SingleStoreDB package installer."""
3
import os
4
import platform
5
from typing import Tuple
6
7
from setuptools import Extension
8
from setuptools import setup
9
from wheel.bdist_wheel import bdist_wheel
10
11
12
py_limited_api = '0x03080000'
13
# py_limited_api = False
14
15
build_extension = bool(int(os.environ.get('SINGLESTOREDB_BUILD_EXTENSION', '1')))
16
17
universal2_flags = ['-arch', 'x86_64', '-arch', 'arm64'] \
18
if (
19
platform.platform().startswith('mac') and
20
'x86_64' in platform.platform()
21
) else []
22
23
24
class bdist_wheel_abi3(bdist_wheel):
25
26
def get_tag(self) -> Tuple[str, str, str]:
27
python, abi, plat = super().get_tag()
28
29
if python.startswith('cp'):
30
if universal2_flags:
31
plat = plat.replace('x86_64', 'universal2')
32
33
# on CPython, our wheels are abi3 and compatible back to 3.8
34
return 'cp38', 'abi3', plat
35
36
return python, abi, plat
37
38
39
if build_extension:
40
setup(
41
ext_modules=[
42
Extension(
43
'_singlestoredb_accel',
44
sources=['accel.c'],
45
define_macros=[
46
('Py_LIMITED_API', py_limited_api),
47
] if py_limited_api else [],
48
py_limited_api=bool(py_limited_api),
49
extra_compile_args=universal2_flags,
50
extra_link_args=universal2_flags,
51
),
52
],
53
cmdclass={'bdist_wheel': bdist_wheel_abi3 if py_limited_api else bdist_wheel},
54
)
55
else:
56
setup()
57
58