summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-03-27 11:24:34 -0400
committerGitHub <noreply@github.com>2020-03-27 11:24:34 -0400
commit14c1f486cf510bf76ff903710ff892606b71726d (patch)
treed283e2797360e76dcb6d9d8cf9e370f58540d0e6
parent7f9f33dbb08bacaa49244e857847400ad8a67ad4 (diff)
downloadvyos-cloud-init-14c1f486cf510bf76ff903710ff892606b71726d.tar.gz
vyos-cloud-init-14c1f486cf510bf76ff903710ff892606b71726d.zip
setup.py: drop NIH check_output implementation (#282)
We no longer need to support versions which don't have subprocess.check_output, so we can rely on its presence in the stdlib.
-rwxr-xr-xsetup.py34
1 files changed, 9 insertions, 25 deletions
diff --git a/setup.py b/setup.py
index 22b32f6f..cbacf48e 100755
--- a/setup.py
+++ b/setup.py
@@ -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