-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathsetup.py
More file actions
57 lines (48 loc) · 1.58 KB
/
Copy pathsetup.py
File metadata and controls
57 lines (48 loc) · 1.58 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
"""Builds the Cython extension; all other packaging configuration is in pyproject.toml."""
import os
from pathlib import Path
import Cython.Compiler.Options
from Cython.Build import cythonize
from setuptools import Extension, setup
Cython.Compiler.Options.annotate = True
# Set to True if the library can still function when extensions fail to compile
# (e.g. slower, python fallback). Don't allow failure if cibuildwheel is running.
# allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1"
allowed_to_fail = False
if os.name == "nt": # Windows
extra_compile_args = [
"/O2",
]
else: # UNIX-based systems
extra_compile_args = [
"-O3",
"-Werror",
"-Wno-unreachable-code-fallthrough",
"-Wno-deprecated-declarations",
"-Wno-parentheses-equality",
]
extra_compile_args.append("-UNDEBUG") # Cython disables asserts by default.
# Relative to project root directory
include_dirs = [
"pythontemplate/",
"pythontemplate/_c_src",
]
c_files = [str(x) for x in Path("pythontemplate/_c_src").rglob("*.c")]
extensions = [
Extension(
# Your .pyx file will be available to cpython at this location.
"pythontemplate._c_extension",
[
# ".c" and ".pyx" source file paths
"pythontemplate/_c_extension.pyx",
*c_files,
],
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
language="c",
optional=allowed_to_fail,
),
]
setup(
ext_modules=cythonize(extensions, include_path=include_dirs, language_level=3, annotate=True),
)