diff options
-rwxr-xr-x | setup.py | 34 |
1 files changed, 9 insertions, 25 deletions
@@ -34,23 +34,6 @@ def is_f(p): def is_generator(p): return '-generator' in p -def tiny_p(cmd, capture=True): - # Darn python 2.6 doesn't have check_output (argggg) - stdout = subprocess.PIPE - stderr = subprocess.PIPE - if not capture: - stdout = None - stderr = None - sp = subprocess.Popen(cmd, stdout=stdout, - stderr=stderr, stdin=None, - universal_newlines=True) - (out, err) = sp.communicate() - ret = sp.returncode - if ret not in [0]: - raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" % - (cmd, ret, out, err)) - return (out, err) - def pkg_config_read(library, var): fallbacks = { @@ -61,7 +44,7 @@ def pkg_config_read(library, var): } cmd = ['pkg-config', '--variable=%s' % var, library] try: - (path, err) = tiny_p(cmd) + path = subprocess.check_output(cmd).decode('utf-8') path = path.strip() except Exception: path = fallbacks[library][var] @@ -83,14 +66,14 @@ def in_virtualenv(): def get_version(): cmd = [sys.executable, 'tools/read-version'] - (ver, _e) = tiny_p(cmd) - return str(ver).strip() + ver = subprocess.check_output(cmd) + return ver.decode('utf-8').strip() def read_requires(): cmd = [sys.executable, 'tools/read-dependencies'] - (deps, _e) = tiny_p(cmd) - return str(deps).splitlines() + deps = subprocess.check_output(cmd) + return deps.decode('utf-8').splitlines() def render_tmpl(template, mode=None): @@ -118,10 +101,11 @@ def render_tmpl(template, mode=None): bname = os.path.basename(template).rstrip(tmpl_ext) fpath = os.path.join(tmpd, bname) if VARIANT: - tiny_p([sys.executable, './tools/render-cloudcfg', '--variant', - VARIANT, template, fpath]) + subprocess.run([sys.executable, './tools/render-cloudcfg', '--variant', + VARIANT, template, fpath]) else: - tiny_p([sys.executable, './tools/render-cloudcfg', template, fpath]) + subprocess.run( + [sys.executable, './tools/render-cloudcfg', template, fpath]) if mode: os.chmod(fpath, mode) # return path relative to setup.py |