70 lines
2.0 KiB
Diff
70 lines
2.0 KiB
Diff
From f569b675403aa987c3023f2365052bf38a663f3f Mon Sep 17 00:00:00 2001
|
|
From: Lubosz Sarnecki <lubosz@gmail.com>
|
|
Date: Mon, 4 Aug 2014 12:31:10 +0200
|
|
Subject: [PATCH 1/3] msys2: port to subprocess.check_output.
|
|
|
|
---
|
|
setup.py | 41 ++++++++++++++++++-----------------------
|
|
1 file changed, 18 insertions(+), 23 deletions(-)
|
|
|
|
diff --git a/setup.py b/setup.py
|
|
index 1985420..dabf41e 100755
|
|
--- a/setup.py
|
|
+++ b/setup.py
|
|
@@ -16,35 +16,30 @@ pkgconfig_file = 'py3cairo.pc'
|
|
config_file = 'src/config.h'
|
|
|
|
|
|
-def call(command):
|
|
- pipe = subprocess.Popen(command, shell=True,
|
|
- stdout=subprocess.PIPE,
|
|
- stderr=subprocess.PIPE)
|
|
- pipe.wait()
|
|
- return pipe
|
|
-
|
|
def pkg_config_version_check(pkg, version):
|
|
- check = '%s >= %s' % (pkg, version)
|
|
- pipe = call("pkg-config --print-errors --exists '%s'" % (check,))
|
|
- if pipe.returncode == 0:
|
|
- print(check, ' Successful')
|
|
- else:
|
|
- print(check, ' Failed')
|
|
- raise SystemExit(pipe.stderr.read().decode())
|
|
+ command = ["pkg-config",
|
|
+ "--print-errors",
|
|
+ "--exists",
|
|
+ '%s >= %s' % (pkg, version)]
|
|
+ try:
|
|
+ ret = subprocess.check_output(command)
|
|
+ except subprocess.CalledProcessError as e:
|
|
+ print(command, ' Failed')
|
|
+ raise SystemExit(e.output.decode())
|
|
+ print(command, ' Successful')
|
|
|
|
def pkg_config_parse(opt, pkg):
|
|
- check = "pkg-config %s %s" % (opt, pkg)
|
|
- pipe = call("pkg-config %s %s" % (opt, pkg))
|
|
- if pipe.returncode != 0:
|
|
- print(check, ' Failed')
|
|
- raise SystemExit(pipe.stderr.read().decode())
|
|
-
|
|
- output = pipe.stdout.read()
|
|
- output = output.decode() # get the str
|
|
+ command = ["pkg-config", opt, pkg]
|
|
+ try:
|
|
+ ret = subprocess.check_output(command)
|
|
+ except subprocess.CalledProcessError as e:
|
|
+ print(command, ' Failed')
|
|
+ raise SystemExit(e.output.decode())
|
|
+
|
|
+ output = ret.decode()
|
|
opt = opt[-2:]
|
|
return [x.lstrip(opt) for x in output.split()]
|
|
|
|
-
|
|
def createPcFile(PcFile):
|
|
print('creating %s' % PcFile)
|
|
with open(PcFile, 'w') as fo:
|
|
--
|
|
2.0.4
|