add Windows specific compiler and linker options, related to #3

This commit is contained in:
Florian Förster 2025-10-23 17:03:57 +02:00
parent 4b42f0f03a
commit a41cc5a312
2 changed files with 125 additions and 1009 deletions

View File

@ -1,4 +1,5 @@
import os
import sys
from Cython.Build import cythonize
from Cython.Compiler import Options
@ -9,20 +10,44 @@ Options.embed_pos_in_docstring = False
Options.annotate = False
Options.fast_fail = True
DEBUG = bool(os.getenv("DOPT_DEBUG", None))
linetrace_opt: bool = False
if DEBUG:
linetrace_opt = True
ext_modules = cythonize(
["src/dopt_sensor_anomalies/detection.py"],
compiler_directives={
"language_level": 3,
"boundscheck": False,
"wraparound": False,
"embedsignature": False,
"annotation_typing": True,
"linetrace": True,
"linetrace": linetrace_opt,
},
)
DEBUG = bool(os.getenv("DOPT_DEBUG", None))
if DEBUG:
ext_modules[0].define_macros.append(("CYTHON_TRACE", "1"))
compiler_args: list[str] = []
linker_args: list[str] = []
if sys.platform.startswith("win") and not DEBUG:
c_args = ("/O2", "/GL", "/Gy")
l_args = ("/LTCG", "/OPT:REF", "/OPT:ICF")
else:
c_args = tuple()
l_args = tuple()
compiler_args.extend(c_args)
linker_args.extend(l_args)
for ext in ext_modules:
ext.extra_compile_args.extend(compiler_args)
ext.extra_link_args.extend(linker_args)
setup(ext_modules=ext_modules)

File diff suppressed because it is too large Load Diff