Skip to content

Commit 27f9070

Browse files
author
Anton Eriksson
committed
fix(python): Fix OpenMP detection
1 parent ed7a428 commit 27f9070

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

interfaces/python/setup.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@ def is_clang():
2222
return b'clang' in subprocess.check_output([get_compiler(), '--version'])
2323

2424

25+
test_openmp = """#include <omp.h>
26+
#include <cstdio>
27+
28+
int main() {
29+
#pragma omp parallel
30+
printf("Hello from thread %d, nthreads %d\\n", omp_get_thread_num(), omp_get_num_threads());
31+
}
32+
"""
33+
34+
2535
def have_openmp():
2636
# Create a temporary directory
2737
tmpdir = tempfile.mkdtemp()
2838
cwd = Path.cwd()
29-
filename = 'test-openmp.cpp'
30-
shutil.copyfile(os.path.join(cwd.parent.parent, 'utils', filename), os.path.join(tmpdir, filename))
31-
3239
os.chdir(tmpdir)
3340

41+
filename = 'test-openmp.cpp'
42+
with open(os.path.join(tmpdir, filename), 'w') as f:
43+
f.write(test_openmp)
44+
3445
compiler = get_compiler()
3546
compile_args = ['-fopenmp']
3647

utils/test-openmp.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)