-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
44 lines (35 loc) · 1.14 KB
/
Copy pathsetup.py
File metadata and controls
44 lines (35 loc) · 1.14 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
"""Build script for LZGraphs with C extension.
Compiles the C-LZGraph library and Python bindings into a single
shared library that is imported as LZGraphs._clzgraph.
"""
import os
import sys
import glob
from setuptools import setup, Extension
HERE = os.path.dirname(os.path.abspath(__file__))
# Ensure setuptools can resolve dynamic version
sys.path.insert(0, os.path.join(HERE, "src"))
# Change to setup.py directory so all paths are relative
os.chdir(HERE)
# Collect all C library source files (relative to HERE)
lib_sources = sorted(glob.glob(os.path.join("lib", "**", "*.c"), recursive=True))
# Platform-specific compile flags
if sys.platform == 'win32':
extra_compile = ["/O2", "/W3"]
extra_link = []
macros = []
else:
extra_compile = ["-O2", "-std=c11", "-Wno-unused-function"]
extra_link = ["-lm"]
macros = [("_POSIX_C_SOURCE", "200809L")]
ext = Extension(
"LZGraphs._clzgraph",
sources=[
os.path.join("src", "LZGraphs", "_clzgraph.c"),
] + lib_sources,
include_dirs=["include"],
extra_compile_args=extra_compile,
extra_link_args=extra_link,
define_macros=macros,
)
setup(ext_modules=[ext])