-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
66 lines (61 loc) · 2.25 KB
/
Copy pathsetup.py
File metadata and controls
66 lines (61 loc) · 2.25 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
import os
import numpy
from setuptools import Extension, setup, find_packages
from setuptools.command.build_ext import build_ext
from Cython.Build import cythonize
set_gcc_args = (os.getenv("PYR_SET_GCC_ARGS") == "1")
profile_cython = (os.getenv("PYR_PROFILE_CYTHON") == "1")
class custom_build_ext(build_ext):
def build_extensions(self):
if set_gcc_args:
# This removes the "default" compiler flags that would
# otherwise get passed on to to the compiler, i.e.,
# sysconfig.get_config_var("CFLAGS").
self.compiler.set_executable("compiler_so", "gcc")
build_ext.build_extensions(self)
def build_extension(self, extension):
if set_gcc_args:
extension.extra_compile_args = [
# Warnings
"-Wall",
"-Wno-maybe-uninitialized",
"-Wno-unused-result",
"-Wno-unused-function",
"-Wsign-compare",
# Optimization
"-O3",
"-fno-semantic-interposition",
# Debugging
"-g",
"-DNDEBUG",
"-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION",
# Code Generation
"-fwrapv",
"-fPIC",
]
build_ext.build_extension(self, extension)
extensions = [
Extension("pyretechnics.*", ["src/pyretechnics/*.py"], include_dirs=[numpy.get_include()])
]
setup(
name="pyretechnics",
version="2026.5.15",
packages=find_packages(where="src"),
package_dir={"": "src"},
cmdclass={"build_ext": custom_build_ext},
ext_modules=cythonize(extensions,
exclude="src/pyretechnics/py_types.py",
annotate=True,
compiler_directives={
"language_level": "3",
"profile": profile_cython,
"initializedcheck": False,
"cdivision": True,
"wraparound": False,
"boundscheck": False,
}),
package_data={
"pyretechnics": ["*.pxd", "*.py"],
},
include_package_data=True,
)