forked from openstreetmap-ng/openstreetmap-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
72 lines (65 loc) · 1.96 KB
/
setup.py
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
import os
from pathlib import Path
from Cython.Build import cythonize
from Cython.Compiler import Options
from setuptools import Extension, setup
import app.config # DO NOT REMOVE # noqa: F401
Options.docstrings = False
Options.annotate = True
dirs = (
'app/exceptions',
'app/exceptions06',
'app/format',
'app/lib',
'app/middlewares',
'app/responses',
'app/services',
'app/queries',
'app/validators',
)
blacklist: dict[str, set[str]] = {
'app/services': {
'email_service.py',
},
'app/services/optimistic_diff': {
'__init__.py',
},
}
paths = (
p
for dir in dirs #
for p in Path(dir).rglob('*.py')
if p.name not in blacklist.get(p.parent.as_posix(), set())
)
setup(
ext_modules=cythonize(
[
Extension(
path.with_suffix('').as_posix().replace('/', '.'),
[str(path)],
extra_compile_args=[
# docs: https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc.pdf
'-march=x86-64-v3',
'-mtune=generic',
'-ffast-math',
'-fharden-compares',
'-fharden-conditional-branches',
'-fharden-control-flow-redundancy',
'-fhardened',
'-fsanitize=address',
# https://developers.redhat.com/articles/2022/06/02/use-compiler-flags-stack-protection-gcc-and-clang#safestack_and_shadow_stack
'-mshstk',
# https://stackoverflow.com/a/23501290
'--param=max-vartrack-size=0',
],
)
for path in paths
],
nthreads=os.cpu_count(),
compiler_directives={
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-directives
'overflowcheck': True,
'language_level': 3,
},
),
)