11import sys
2+ import numpy
23import setuptools
34from distutils .core import setup
45from distutils .extension import Extension
910module_name1 = 'maxflow'
1011maxflow_source = "maxflow_python/wrap_py{0:}.cpp" .format (py_version )
1112module1 = Extension (module_name1 ,
12- include_dirs = ['./dependency' , './maxflow_python' ],
13+ include_dirs = [numpy . get_include (), './dependency' , './maxflow_python' ],
1314 sources = ['maxflow_python/maxflow.cpp' ,
1415 'maxflow_python/util.cpp' ,
1516 'dependency/maxflow-v3.0/graph.cpp' ,
1920module_name2 = 'denseCRF'
2021densecrf_source = "densecrf_python/wrap2D_py{0:}.cpp" .format (py_version )
2122module2 = Extension (module_name2 ,
22- include_dirs = [
23+ include_dirs = [numpy . get_include (),
2324 './dependency/densecrf/include' ,
2425 './dependency/densecrf/external/liblbfgs/include' ],
2526 sources = ['./densecrf_python/densecrf.cpp' ,
3940module_name3 = 'denseCRF3D'
4041densecrf_source = "densecrf_python/wrap3D_py{0:}.cpp" .format (py_version )
4142module3 = Extension (module_name3 ,
42- include_dirs = [
43+ include_dirs = [numpy . get_include (),
4344 './dependency/densecrf3d/include' ,
4445 './dependency/densecrf/external/liblbfgs/include' ],
4546 sources = ['./densecrf_python/densecrf3d.cpp' ,
6869 with open ('README.md' , encoding = 'utf-8' ) as f :
6970 long_description = f .read ()
7071
71- from setuptools .command .build_ext import build_ext
72-
73- class CustomBuildExtCommand (build_ext ):
74- """build_ext command for use when numpy headers are needed."""
75- def run (self ):
76-
77- # Import numpy here, only when headers are needed
78- import numpy
79-
80- # Add numpy headers to include_dirs
81- self .include_dirs .append (numpy .get_include ())
82-
83- # Call original build_ext command
84- build_ext .run (self )
8572
8673setup (name = package_name ,
8774 version = "0.1.1" ,
@@ -100,10 +87,7 @@ def run(self):
10087 'Programming Language :: Python :: 2' ,
10188 'Programming Language :: Python :: 3' ,
10289 ],
103- python_requires = '>=3.6' ,
104- cmdclass = {'build_ext' : CustomBuildExtCommand },
105- install_requires = ['numpy' ],
106- )
90+ python_requires = '>=3.6' )
10791
10892
10993# to build, run python stup.py build or python setup.py build_ext --inplace
0 commit comments