-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
executable file
·86 lines (70 loc) · 2.43 KB
/
setup.py
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
import glob
import os
import sys
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext as _build_ext
# get numpy as dependency when it is not pre-installed
# from: https://stackoverflow.com/a/54128391/798093
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
import builtins
builtins.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
def get_extensions():
ext_dir = "numpymaxflow"
include_dirs = [ext_dir]
sources = glob.glob(os.path.join(ext_dir, "**", "*.cpp"), recursive=True)
# print(sources)
define_macros = []
extra_link_args = []
extra_compile_args = []
# add any compile flags here
# compile release
extra_compile_args += ["-g0"]
# use c++11 on macos
# help from:
# https://stackoverflow.com/a/43571056/798093
if sys.platform == "darwin":
# extra_compile_args += ["-stdlib=libc++"]
extra_compile_args += ["-std=c++11"]
if not sources:
return [] # compile nothing
ext_modules = [
Extension(
name="numpymaxflowcpp",
sources=sources,
include_dirs=include_dirs,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
]
return ext_modules
with open("README.md", "r") as fh:
long_description = fh.read()
with open("requirements.txt", "r") as fp:
install_requires = fp.read().splitlines()
print(install_requires)
setup(
name="numpymaxflow",
version="0.0.7",
description="numpymaxflow: Max-flow/Min-cut in Numpy for 2D images and 3D volumes",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/masadcv/numpymaxflow",
author="Muhammad Asad",
author_email="[email protected]",
license="BSD-3-Clause License",
classifiers=[
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
],
install_requires=install_requires,
cmdclass={"build_ext": build_ext}, # .with_options(no_python_abi_suffix=True)},
packages=find_packages(exclude=("data", "docs", "examples", "scripts", "tests")),
ext_modules=get_extensions(),
python_requires=">=3.9",
)