Debian Codegraph @

setup.py

raw symbols SCIP
1 #!/usr/bin/env python
2 import os
3 import re
4 import sys
5
6 import numpy
7 from Cython.Build import cythonize
8 from setuptools import setup
9 from setuptools.extension import Extension
10
11 here = os.path.dirname(os.path.abspath(__file__))
12
13 # Everything except the version and the extension itself lives in
14 # pyproject.toml. Synchronize the version from code.
15 fname = os.path.join("src", "extinction", "_extinction.pyx")
16 version = re.findall(r"__version__ = \"(.*?)\"", open(fname).read())[0]
17
18 # Build Cython extension
19 source_files = [fname, os.path.join("extern", "bs.c")]
20 depends_files = [
21 os.path.join("extern", "bs.h"),
22 os.path.join("extern", "bsplines.pxi")
23 ]
24 include_dirs = [numpy.get_include(), "extern"]
25
26 # MSVC does not understand -std=c11 and only warns about it.
27 extra_compile_args = [] if sys.platform == "win32" else ["-std=c11"]
28
29 # Pin the numpy C API level, so that a future numpy removing an already
30 # deprecated API is a compile error here rather than a surprise at runtime.
31 define_macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
32
33 extensions = [
34 Extension(
35 "extinction._extinction",
36 source_files,
37 include_dirs=include_dirs,
38 depends=depends_files,
39 define_macros=define_macros,
40 extra_compile_args=extra_compile_args,
41 )
42 ]
43
44 setup(
45 version=version,
46 # `include "extern/bsplines.pxi"` in the .pyx resolves against the project
47 # root, not the directory holding the .pyx.
48 ext_modules=cythonize(extensions, language_level=3, include_path=[here]),
49 )