Newer
Older
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
#!python
# -*- coding: utf-8 -*-
"""
File: module/setup.py.in
Description: Build for cython modules
"""
__author__ = "Irreq"
__copyright__ = "Copyright Info"
__credits__ = ["Irreq"]
__license__ = "License Name and Info"
__version__ = "0.1.0"
__maintainer__ = "Irreq"
__email__ = ""
__status__ = "Production"
from distutils.core import setup
from distutils.extension import Extension
import distutils.log
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import Cython.Compiler.Options
import numpy
import config
distutils.log.set_verbosity(distutils.log.DEBUG) # Set DEBUG level
Cython.Compiler.Options.annotate = config.CYTHON_ANNOTATE
Cython.Compiler.Options.docstrings = True
Cython.Compiler.Options.error_on_unknown_names = True
Cython.Compiler.Options.gcc_branch_hints = True
Cython.Compiler.Options.cimport_from_pyx = True
compiler_directives = {
"boundscheck": config.CYTHON_BOUNDS_CHECK, # Assume user does not index out of bounds
}
PROJECT_SOURCE: str = "${CMAKE_CURRENT_SOURCE_DIR}/src"
PROJECT_NAME: str = "${CMAKE_PROJECT_NAME}"
assert PROJECT_NAME != "", "Project name is empty, check CMakeLists.txt"
PROJECT_VERSION: str = "${CMAKE_PROJECT_VERSION}"
assert PROJECT_VERSION != "", "Project version is empty, check CMakeLists.txt"
EIGEN_SOURCE = "/usr/include/eigen3"
NUMPY_SOURCE = numpy.get_include()
ext_modules = [
Extension(
name="antenna",
sources=[
"${CMAKE_CURRENT_SOURCE_DIR}/module/src/antenna.pyx",
"${CMAKE_CURRENT_SOURCE_DIR}/src/antenna.cpp",
],
include_dirs=[PROJECT_SOURCE, EIGEN_SOURCE, NUMPY_SOURCE],
language="c++",
),
Extension(
name="pipeline",
sources=[
"${CMAKE_CURRENT_SOURCE_DIR}/module/src/pipeline.pyx",
# "${CMAKE_CURRENT_SOURCE_DIR}/module/src/antenna.pyx",
"${CMAKE_CURRENT_SOURCE_DIR}/src/pipeline.cpp",
"${CMAKE_CURRENT_SOURCE_DIR}/src/ring_buffer.cpp",
"${CMAKE_CURRENT_SOURCE_DIR}/src/receiver.cpp",
],
include_dirs=[PROJECT_SOURCE, EIGEN_SOURCE, NUMPY_SOURCE],
language="c++",
),
name = PROJECT_NAME,
version = PROJECT_VERSION,
cmdclass = {"build_ext": build_ext},
ext_modules=cythonize(
ext_modules,
annotate=config.CYTHON_ANNOTATE,
cache=config.CYTHON_CACHE,
nthreads=config.N_THREADS,
compiler_directives=compiler_directives,
build_dir="build",
),
script_args=["build"],
options={"build": {"build_lib": "${CMAKE_CURRENT_BINARY_DIR}/lib"}},
verbose=True,
)