-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_build_flags.py
34 lines (27 loc) · 1.01 KB
/
python_build_flags.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
from __future__ import print_function
import sysconfig
import re
import numpy as np
conf = sysconfig.get_config_vars()
print('CFLAGS', end=';')
c_flags = []
# Grab compiler flags minus the compiler itself.
c_flags.extend(conf.get('CC', '').split()[2:])
c_flags.extend(conf.get('CFLAGS', '').split())
c_flags.extend(conf.get('CCSHARED', '').split())
c_flags.append('-I{}'.format(conf.get('INCLUDEPY', '')))
c_flags.append('-I{}'.format(np.get_include()))
c_flags.append('-Wno-strict-prototypes')
c_flags = [x for x in c_flags if not x.startswith('-O')]
print(' '.join(c_flags), end=';')
print('LINKER', end=';')
print(conf.get('BLDSHARED', '').split()[0], end=';')
print('LDFLAGS', end=';')
print(' '.join(conf.get('BLDSHARED', '').split()[1:]) + ' ' + conf.get('BLDLIBRARY', '') + ' ' + conf.get('LDFLAGS', ''), end=';')
print('EXT_SUFFIX', end=';')
ext_suffix = '.so'
if 'EXT_SUFFIX' in conf:
ext_suffix = conf['EXT_SUFFIX']
elif 'MULTIARCH' in conf:
ext_suffix = '.' + conf['MULTIARCH'] + '.so'
print(ext_suffix, end=';')