-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
84 lines (75 loc) · 2.37 KB
/
setup.py
File metadata and controls
84 lines (75 loc) · 2.37 KB
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
"""
StreamMachine setup configuration.
Cython extensions are optional and compiled with:
pip install -e ".[cython]"
python setup.py build_ext --inplace
If Cython is not installed or compilation fails, pure Python
fallbacks are used automatically.
"""
from setuptools import setup, find_packages, Extension
import os
import sys
# Check if Cython is available
CYTHON_AVAILABLE = False
try:
from Cython.Build import cythonize
CYTHON_AVAILABLE = True
except ImportError:
cythonize = None # type: ignore
# Determine if we should build Cython extensions
# Build if: CYTHON_AVAILABLE and (installing with [cython] or BUILD_CYTHON env var)
BUILD_CYTHON = CYTHON_AVAILABLE and (
os.environ.get("BUILD_CYTHON", "").lower() in ("1", "true", "yes") or
"[cython]" in " ".join(sys.argv) or
any("cython" in arg.lower() for arg in sys.argv)
)
# Define Cython extensions
ext_modules = []
if BUILD_CYTHON and CYTHON_AVAILABLE:
# Compiler flags - use -O2 for broader compatibility
extra_compile_args = ["-O2"]
extra_link_args = []
# Skip -march=native for compatibility with Rosetta and cross-compile scenarios
ext_modules = [
Extension(
"streammachine.cython.cython_decode",
["src/streammachine/cython/cython_decode.pyx"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"streammachine.cython.fast_ohlc",
["src/streammachine/cython/fast_ohlc.pyx"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"streammachine.cython.fast_consumer",
["src/streammachine/cython/fast_consumer.pyx"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
]
ext_modules = cythonize(
ext_modules,
compiler_directives={
"language_level": "3",
"boundscheck": False,
"wraparound": False,
"cdivision": True,
"initializedcheck": False,
},
)
setup(
name="streammachine",
version="0.1.0",
package_dir={"": "src"},
packages=find_packages(where="src"),
install_requires=[
"coredis>=4.22.0",
"venusian",
"uvloop",
],
python_requires=">=3.8",
ext_modules=ext_modules,
)