|
1 | 1 | import glob
|
2 | 2 | from setuptools import setup
|
3 |
| -from pybind11.setup_helpers import Pybind11Extension, build_ext |
| 3 | +from pybind11.setup_helpers import ( |
| 4 | + Pybind11Extension, |
| 5 | + build_ext, |
| 6 | + ParallelCompile, |
| 7 | + naive_recompile |
| 8 | +) |
4 | 9 | from pathlib import Path
|
5 | 10 |
|
6 | 11 | import platform
|
7 | 12 |
|
8 | 13 | debug = False
|
9 | 14 | openmp = True
|
10 | 15 |
|
| 16 | +ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install() |
| 17 | + |
| 18 | +cpp_args = [] |
| 19 | +linkargs = [] |
| 20 | +libs = [] |
| 21 | + |
11 | 22 | if platform.system() == "Windows":
|
12 |
| - cpp_args=['/std:c++20', '/MD'] |
13 |
| - linkargs = [] |
| 23 | + cpp_args.extend(['/std:c++20', '/MD']) |
| 24 | + |
14 | 25 | if debug:
|
15 | 26 | cpp_args.extend(['/Od','/Zi'])
|
16 | 27 | linkargs.extend(['/DEBUG'])
|
| 28 | + |
17 | 29 | else:
|
18 | 30 | cpp_args.extend(['/O2', '/Ot'])
|
| 31 | + |
19 | 32 | if openmp:
|
20 | 33 | cpp_args.append('/openmp')
|
21 | 34 |
|
22 | 35 | elif platform.system() == "Linux":
|
23 |
| - cpp_args = ['-std=c++20'] |
24 |
| - linkargs = [] |
| 36 | + cpp_args.extend(['-std=c++20']) |
| 37 | + |
25 | 38 | if debug:
|
26 | 39 | cpp_args.extend(['-O0'])
|
| 40 | + |
27 | 41 | else:
|
28 | 42 | cpp_args.extend(['-O3'])
|
| 43 | + |
29 | 44 | if openmp:
|
30 |
| - pass |
31 |
| - # TODO: non-monotonic dynamic loop in gcc introduced recently causing issues with linux build |
32 |
| - # cpp_args.append('-fopenmp') |
33 |
| - # linkargs.append('-lgomp') |
34 |
| - linkargs = [] |
| 45 | + cpp_args.append('-fopenmp') |
| 46 | + libs.append('gomp') |
| 47 | + |
35 | 48 | else:
|
36 | 49 | # disable openmp for non-linux/windows systems
|
37 |
| - cpp_args = ['-std=c++20', '-O3'] |
38 |
| - linkargs = [] |
| 50 | + cpp_args.extend(['-std=c++20', '-O3']) |
39 | 51 |
|
40 | 52 |
|
41 | 53 | roughness_cppimpl_sources = [
|
|
61 | 73 | include_dirs=roughness_cppimpl_includes,
|
62 | 74 | language='c++',
|
63 | 75 | extra_compile_args=cpp_args,
|
64 |
| - extra_link_args=linkargs |
| 76 | + extra_link_args=linkargs, |
| 77 | + libraries=libs |
65 | 78 | )
|
66 | 79 |
|
67 | 80 | setup(
|
|
77 | 90 | 'surface_roughness':'surface_roughness',
|
78 | 91 | 'surface_roughness._roughness_pyimpl':'surface_roughness/_roughness_pyimpl'},
|
79 | 92 | packages=['surface_roughness','surface_roughness._roughness_pyimpl'],
|
80 |
| - # ext_package='surface_roughness', |
81 | 93 | ext_modules=[roughness_cppimpl],
|
82 | 94 | install_requires=[
|
83 | 95 | 'scipy',
|
|
0 commit comments