Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
102 lines (86 loc) · 2.95 KB
/
Copy pathsetup.py
File metadata and controls
102 lines (86 loc) · 2.95 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import platform
import sys
import numpy
from setuptools import Extension, setup
with open("README.md", "r") as fh:
long_description = fh.read()
class LazyCythonize(list):
def __init__(self, callback):
self._list, self.callback = None, callback
def c_list(self):
if self._list is None:
self._list = self.callback()
return self._list
def __iter__(self):
for e in self.c_list():
yield e
def __getitem__(self, ii):
return self.c_list()[ii]
def __len__(self):
return len(self.c_list())
def extensions():
from Cython.Build import cythonize
include_dirs = [
"fcbkwrapper/src/core/include",
numpy.get_include(),
]
is_windows = (platform.system() == "Windows") or (sys.platform == "win32")
define_macros = [("NDEBUG", "1"), ("FCBK_ENABLE_OB_CHECKS", "0")]
if is_windows:
# MSVC-style flags
extra_compile_args = [
"/std:c++17", # C++ version 17
"/EHsc", # Compiler assumes exceptions can only occur at throw (faster code)
"/O2", # Favor speed over size when compiling
"/DNDEBUG", # No debug checking (faster code)
]
extra_link_args = []
else:
# Unix-like (Linux) flags as requested
extra_compile_args = [
"-std=c++17",
"-g",
"-O3",
"-march=native",
"-mtune=native",
"-DNDEBUG",
"-m64",
]
extra_link_args = ["-m64"]
maxflow_module = Extension(
"fcbkwrapper._fcbk",
["fcbkwrapper/src/_fcbk.pyx"],
include_dirs=include_dirs,
language="c++",
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=define_macros,
)
return cythonize([maxflow_module])
setup(
name="fcbkwrapper",
version="1.0.0",
author="Christian Mikkelstrup",
author_email="cmomi@dtu.dk",
description="A thin wrapper for Python of the fcBK algorithm",
long_description=long_description,
long_description_content_type="text/markdown",
packages=["fcbkwrapper"],
install_requires=["numpy"],
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: C++",
"Programming Language :: Python",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Mathematics",
],
ext_modules=LazyCythonize(extensions),
setup_requires=["Cython", "numpy"],
)