-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_vpy_includes.py
107 lines (73 loc) · 2.28 KB
/
get_vpy_includes.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from __future__ import print_function
"""
Search for packages and include paths to build visual python on linux systems.
"""
import subprocess
gtk_list = ['gtk2','gtk+']
mm_gl_list = ['gtkmm','gtkglext','gtkglextmm']
def get_installed():
"""
try to use pkg-config to get the right values for cflags
"""
installed = []
for line in subprocess.check_output(['pkg-config','--list-all']).split('\n'):
line_list = line.split()
if len(line_list):
for pkg in mm_gl_list:
if pkg in line_list[0]:
installed.append(line_list[0])
break
for pkg in gtk_list:
if pkg in line_list[0]:
installed.append(line_list[0])
break
not_found = []
for pkg in mm_gl_list:
found = False
for inst in installed:
if pkg in inst:
found = True
break
if not found:
not_found.append(pkg)
found = False
for pkg in gtk_list:
if not found:
for inst in installed:
if pkg in inst:
found = True
break
errors = []
if not_found:
errors.append("can't find packages installed:" + ','.join(not_found))
if not found:
errors.append("Can't find gtk[2/+] package: " + ','.join(gtk_list))
if errors:
raise RuntimeError(','.join(errors))
return installed
def get_includes():
installed = get_installed()
includes = []
cflags_dict = {}
for inst in installed:
for item in subprocess.check_output(['pkg-config','--cflags',inst]).split():
if item:
cflags_dict[item] = 1
for k in cflags_dict.keys():
includes.append(k.replace('-I/','/'))
return includes
def get_libs():
installed = get_installed()
libs = []
libs_dict = {}
for inst in installed:
for item in subprocess.check_output(['pkg-config','--libs-only-l',inst]).split():
if item:
libs_dict[item] = 1
for k in libs_dict.keys():
libs.append(k.replace('-l',''))
return libs
if __name__=='__main__':
print("looks like we need:")
print(get_includes())
print(get_libs())