forked from mdavidsaver/FLAME
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pyconfig.py
56 lines (42 loc) · 1.75 KB
/
pyconfig.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
#!/usr/bin/env python
"""
Emit a file suitible to include() in a CMakeLists.txt file
with information from a python interpreter
Compatible for python 2.6 -> 3.4
"""
from __future__ import print_function
import sys, os
if len(sys.argv)<2:
out = sys.stdout
else:
out = open(sys.argv[1], 'w')
from distutils.sysconfig import get_config_var, get_python_inc, get_python_lib
incdirs = [get_python_inc()]
libdirs = [get_config_var('LIBDIR')]
have_np='NO'
try:
from numpy.distutils.misc_util import get_numpy_include_dirs
incdirs += get_numpy_include_dirs()
have_np='YES'
except ImportError:
pass
libdirs = [get_config_var('LIBDIR')]
# prepend introspected numpy directory so that it is checked before
# system python directory, which may contained a different version
# when virtualenv is used. Debian helpfully symlinks the numpy headers
# as /usr/include/pythonX.Y/numpy :P
libdirs.reverse()
incdirs.reverse()
# location of extension modules relative to prefix (eg. "lib/python3/dist-packages")
moddir = get_python_lib()
print('set(Python_DEFINITIONS, "%s")'%get_config_var('BASECFLAGS'), file=out)
print('set(Python_VERSION "%s")'%get_config_var('VERSION'), file=out)
print('set(Python_VERSION_LD "%s")'%(get_config_var('LDVERSION') or get_config_var('VERSION')), file=out)
print('set(Python_INCLUDE_DIRS "%s")'%';'.join(incdirs), file=out)
print('set(Python_LIBRARY_DIRS "%s")'%';'.join(libdirs), file=out)
print('set(Python_MODULE_DIR "%s")'%moddir, file=out)
print('set(Python_NUMPY_FOUND %s)'%have_np, file=out)
print('set(Python_VERSION_MAJOR %s)'%sys.version_info[0], file=out)
print('set(Python_VERSION_MINOR %s)'%sys.version_info[1], file=out)
print('set(Python_VERSION_PATCH %s)'%sys.version_info[2], file=out)
print('set(Python_FOUND YES)', file=out)