-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
67 lines (54 loc) · 1.63 KB
/
setup.py
File metadata and controls
67 lines (54 loc) · 1.63 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
"""
TrueEntropy - Setup Script for Cython Extension
This script builds the Cython-accelerated extension module.
Usage:
# Build in-place for development
python setup.py build_ext --inplace
# Or install with Cython support
pip install -e ".[cython]"
"""
import os
import sys
from pathlib import Path
# Try to import Cython and setuptools
try:
from Cython.Build import cythonize
from setuptools import setup, Extension
CYTHON_AVAILABLE = True
except ImportError:
CYTHON_AVAILABLE = False
from setuptools import setup
def get_extensions():
"""Get the list of Cython extensions to build."""
if not CYTHON_AVAILABLE:
print("Cython not available. Skipping extension build.")
return []
# Find the .pyx file
src_dir = Path(__file__).parent / "src" / "trueentropy"
pyx_file = src_dir / "_accel.pyx"
if not pyx_file.exists():
print(f"Warning: {pyx_file} not found. Skipping extension build.")
return []
extensions = [
Extension(
"trueentropy._accel",
sources=[str(pyx_file)],
extra_compile_args=["-O3"] if sys.platform != "win32" else ["/O2"],
)
]
return cythonize(
extensions,
compiler_directives={
"language_level": "3",
"boundscheck": False,
"wraparound": False,
"cdivision": True,
}
)
if __name__ == "__main__":
# This script is only for building extensions
# Full package installation is handled by pyproject.toml
setup(
name="trueentropy-accel",
ext_modules=get_extensions(),
)