|
10 | 10 | import commands |
11 | 11 | except ImportError: |
12 | 12 | import subprocess as commands |
13 | | -run = commands.getstatusoutput |
14 | 13 |
|
15 | 14 | version = '0.12' |
16 | 15 |
|
@@ -54,28 +53,27 @@ def _str2list(cls, pkgstr, onlystr): |
54 | 53 | res.append(l.replace(onlystr, "", 1)) |
55 | 54 | return res |
56 | 55 |
|
57 | | - @property |
58 | | - def include_dirs(self): |
59 | | - res, includes = run('pkg-config --cflags-only-I %s' % self._pkg) |
| 56 | + @classmethod |
| 57 | + def _run(cls, command_string): |
| 58 | + res, output = commands.getstatusoutput(command_string) |
60 | 59 | if res != 0: |
61 | | - print('Failed to query pkg-config --cflags-only-I %s' % self._pkg) |
| 60 | + print('Failed to query %s' % command_string) |
62 | 61 | sys.exit(1) |
| 62 | + return output |
| 63 | + |
| 64 | + @property |
| 65 | + def include_dirs(self): |
| 66 | + includes = self._run('pkg-config --cflags-only-I %s' % self._pkg) |
63 | 67 | return self._str2list(includes, '-I') |
64 | 68 |
|
65 | 69 | @property |
66 | 70 | def library_dirs(self): |
67 | | - res, libdirs = run('pkg-config --libs-only-L %s' % self._pkg) |
68 | | - if res != 0: |
69 | | - print('Failed to query pkg-config --libs-only-L %s' % self._pkg) |
70 | | - sys.exit(1) |
| 71 | + libdirs = self._run('pkg-config --libs-only-L %s' % self._pkg) |
71 | 72 | return self._str2list(libdirs, '-L') |
72 | 73 |
|
73 | 74 | @property |
74 | 75 | def libraries(self): |
75 | | - res, libs = run('pkg-config --libs-only-l %s' % self._pkg) |
76 | | - if res != 0: |
77 | | - print('Failed to query pkg-config --libs-only-l %s' % self._pkg) |
78 | | - sys.exit(1) |
| 76 | + libs = self._run('pkg-config --libs-only-l %s' % self._pkg) |
79 | 77 | return self._str2list(libs, '-l') + self._extra_libraries |
80 | 78 |
|
81 | 79 | @include_dirs.setter |
|
0 commit comments