|
6 | 6 | from distutils.command.build_ext import build_ext
|
7 | 7 | from distutils.sysconfig import get_config_vars
|
8 | 8 | from platform import architecture
|
9 |
| -from subprocess import check_output, check_call |
| 9 | +from subprocess import Popen, CalledProcessError, PIPE, check_call |
10 | 10 | import shutil
|
11 | 11 | import sys
|
12 | 12 | import os
|
@@ -77,10 +77,10 @@ def build_extension(self, ext):
|
77 | 77 |
|
78 | 78 |
|
79 | 79 | def _build_monoclr(self, ext):
|
80 |
| - mono_libs = check_output("pkg-config --libs mono-2", shell=True) |
81 |
| - mono_cflags = check_output("pkg-config --cflags mono-2", shell=True) |
82 |
| - glib_libs = check_output("pkg-config --libs glib-2.0", shell=True) |
83 |
| - glib_cflags = check_output("pkg-config --cflags glib-2.0", shell=True) |
| 80 | + mono_libs = _check_output("pkg-config --libs mono-2", shell=True) |
| 81 | + mono_cflags = _check_output("pkg-config --cflags mono-2", shell=True) |
| 82 | + glib_libs = _check_output("pkg-config --libs glib-2.0", shell=True) |
| 83 | + glib_cflags = _check_output("pkg-config --cflags glib-2.0", shell=True) |
84 | 84 | cflags = mono_cflags.strip() + " " + glib_cflags.strip()
|
85 | 85 | libs = mono_libs.strip() + " " + glib_libs.strip()
|
86 | 86 |
|
@@ -129,6 +129,22 @@ def _build_monoclr(self, ext):
|
129 | 129 | debug=self.debug)
|
130 | 130 |
|
131 | 131 |
|
| 132 | +def _check_output(*popenargs, **kwargs): |
| 133 | + """subprocess.check_output from python 2.7. |
| 134 | + Added here to support building for earlier versions |
| 135 | + of Python. |
| 136 | + """ |
| 137 | + process = Popen(stdout=PIPE, *popenargs, **kwargs) |
| 138 | + output, unused_err = process.communicate() |
| 139 | + retcode = process.poll() |
| 140 | + if retcode: |
| 141 | + cmd = kwargs.get("args") |
| 142 | + if cmd is None: |
| 143 | + cmd = popenargs[0] |
| 144 | + raise CalledProcessError(retcode, cmd, output=output) |
| 145 | + return output |
| 146 | + |
| 147 | + |
132 | 148 | if __name__ == "__main__":
|
133 | 149 | setup(name="pythonnet",
|
134 | 150 | ext_modules=[
|
|
0 commit comments