forked from rajeshrinet/pyross
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
64 lines (56 loc) · 1.78 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
import numpy
import os, sys, os.path, tempfile, subprocess, shutil
from distutils.core import setup
from Cython.Build import cythonize
from distutils.extension import Extension
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
def checkOpenmpSupport():
""" Adapted from https://stackoverflow.com/questions/16549893/programatically-testing-for-openmp-support-from-a-python-setup-script
"""
ompTest = \
r"""
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Thread %d, Total number of threads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
"""
tmpdir = tempfile.mkdtemp()
curdir = os.getcwd()
os.chdir(tmpdir)
filename = r'test.c'
with open(filename, 'w') as file:
file.write(ompTest)
with open(os.devnull, 'w') as fnull:
result = subprocess.call(['cc', '-fopenmp', filename],
stdout=fnull, stderr=fnull)
os.chdir(curdir)
shutil.rmtree(tmpdir)
if result == 0:
return True
else:
return False
if checkOpenmpSupport() == True:
ompArgs = ['-fopenmp']
else:
ompArgs = None
setup(
name='pyross',
version='1.0.0',
url='https://gitlab.com/rajeshrinet/pyross',
author='The pyross team',
license='MIT',
description='python library for numerical simulation of infectious disease',
long_description='pyross is a library for numerical simulation of infectious disease',
platforms='tested on LINUX',
ext_modules=cythonize([ Extension("pyross/*", ["pyross/*.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=ompArgs,
extra_link_args=ompArgs
)]),
libraries=[],
packages=['pyross'],
package_data={'pyross': ['*.pxd']}
)