Skip to content

Commit 6251913

Browse files
committed
Allow setting OpenMP flags using env var
1 parent 6dabb04 commit 6251913

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

setup.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
BUILD_DOCS = os.getenv('BUILD_DOCS', '0') == '1'
3030

3131

32+
def get_openmp_flag():
33+
if os.getenv("OPENMP_FLAG") is not None:
34+
return os.getenv("OPENMP_FLAG")
35+
if sys.platform == 'win32':
36+
return ['/openmp']
37+
else:
38+
return ['-fopenmp']
39+
40+
3241
def get_extensions():
3342
extensions = []
3443

@@ -52,11 +61,8 @@ def get_extensions():
5261
info = parallel_info()
5362
if ('backend: OpenMP' in info and 'OpenMP not found' not in info
5463
and sys.platform != 'darwin'):
55-
extra_compile_args['cxx'] += ['-DAT_PARALLEL_OPENMP']
56-
if sys.platform == 'win32':
57-
extra_compile_args['cxx'] += ['/openmp']
58-
else:
59-
extra_compile_args['cxx'] += ['-fopenmp']
64+
extra_compile_args['cxx'] += ['-DAT_PARALLEL_OPENMP',
65+
get_openmp_flag()]
6066
else:
6167
print('Compiling without OpenMP...')
6268

0 commit comments

Comments
 (0)