-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup.py
79 lines (66 loc) · 2.52 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright (C) 2016, 2018 Intel Corporation
#
# SPDX-License-Identifier: MIT
from __future__ import print_function
from setuptools import setup
def build_native():
'''Return cythonized extensions for native benchmarks'''
try:
# use icx if it is available
icpx = subprocess.check_output('which icpx',shell=True).decode('utf-8')
except:
icpx = None
extra_args = []
else:
print('Using icpx: %s' % icpx)
os.environ['CC'] = icpx
os.environ['CXX'] = os.environ['CC']
extra_args = ['-qmkl']
if not 'CXX' in os.environ:
print('icpx not detected, and CXX is not set. Skipping building native benchmarks.')
print('If you want to build native benchmarks, specify a compiler in the CXX '
'environment variable.')
return
try:
os.mkdir('pyx')
except OSError:
pass
def make_bench(name):
tpl_env = Environment(loader=FileSystemLoader('ibench/native'))
with open('pyx/%s.pyx' % name,'w') as pyxf:
pyxf.write(tpl_env.get_template('tpl.bench.pyx').render({'bench': name, 'Bench': name.capitalize()}))
return Extension(name='ibench.native.%s' % name,
extra_compile_args=extra_args,
extra_link_args=extra_args,
sources=['pyx/%s.pyx' % name])
return cythonize([make_bench(i) for i in ['det', 'dot', 'inv', 'lu', 'cholesky', 'qr']])
packages = ['ibench','ibench/docker','ibench/cmds','ibench/configs','ibench/benchmarks']
try:
from Cython.Build import cythonize
from jinja2 import FileSystemLoader
from jinja2 import Environment
import os
from setuptools import Extension
import subprocess
import sys
except ImportError:
print('Cython not found. Skipping building native benchmarks.')
extensions = None
else:
# Cython and Jinja2 found in build environment. Look for compilers
extensions = build_native()
if extensions:
packages.append('ibench/native')
setup(name='ibench',
version='0.1rc',
description='Benchmarking for scientific python',
url='http://github.com/intelpython/ibench',
download_url='http://github.com/intelpython/ibench/tarball/0.1rc',
author='Robert Cohn',
author_email='Robert.S.Cohn@intel.com',
license='MIT',
packages=packages,
install_requires=['jinja2','numpy','scipy','scikit-learn'],
ext_modules=extensions,
package_data={'ibench': ['docker/Dockerfile.tpl']},
zip_safe=False)