-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
57 lines (52 loc) · 2.08 KB
/
setup.py
File metadata and controls
57 lines (52 loc) · 2.08 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
import os
import numpy
from setuptools import Extension, setup
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("*", ["src/pyretechnics/*.py"], include_dirs=[numpy.get_include()])
]
setup(name="pyretechnics",
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,
}))