-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
67 lines (58 loc) · 1.89 KB
/
setup.py
File metadata and controls
67 lines (58 loc) · 1.89 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
import os
from setuptools import setup, Extension
from Cython.Build import cythonize
def _platform_id():
tag = os.environ.get("CIBW_BUILD", "local")
return tag.split("-", 1)[1] if "-" in tag else tag
extra_compile_args = [
"-ffunction-sections", # Enable function-level sections
"-fdata-sections", # Enable data-level sections
]
# Avoid gc-sections when statically linking C++ libs with RTTI/vtables
extra_link_args = [
# intentionally no --gc-sections
"-lstdc++", # Link against C++ standard library
]
# Enable optional AddressSanitizer build via env var ASAN=1
if os.environ.get("ASAN") == "1":
# Favor debuggability over speed
extra_compile_args += [
"-O1",
"-g",
"-fno-omit-frame-pointer",
"-fsanitize=address",
]
extra_link_args += [
"-fsanitize=address",
]
repo_root = os.path.abspath(os.path.dirname(__file__))
plat_id = _platform_id()
geos_include = os.path.join(repo_root, "vendor", "geos", plat_id, "include")
geos_lib = os.path.join(repo_root, "vendor", "geos", plat_id, "lib")
setup(
ext_modules=cythonize(
[
Extension(
"togo",
sources=["togo.pyx", "tg.c", "tgx.c"],
include_dirs=[
".", # For tg.h and tgx.h
geos_include,
],
# Link static archives as whole-archive to keep all needed RTTI/vtables
extra_compile_args=extra_compile_args,
extra_link_args=[
"-Wl,--whole-archive",
os.path.join(geos_lib, "libgeos_c.a"),
os.path.join(geos_lib, "libgeos.a"),
"-Wl,--no-whole-archive",
]
+ extra_link_args,
)
]
),
# Explicitly disable auto-discovery in flat layout
packages=[],
py_modules=[],
license="MIT",
)