From f402cde902143bfb06641f3154ad834c08218cef Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Mon, 11 May 2020 07:54:37 -0500 Subject: [PATCH] Pass full environ copy to sdist subprocess In order to tell pbr not to build release notes and create CHANGELOG and AUTHORS files, we need to pass flags in as environment variables. We can't just pass these flags though, as that will exclude the rest of the normal environment set in. So copy the current environment, append our updates, and pass that in explicitly to the subprocess call. Change-Id: Ia47e73b51b3216572d51399338e95bd4269a8d1d Signed-off-by: Sean McGinnis --- openstack_releases/processutils.py | 18 +++++++++++++++++- openstack_releases/pythonutils.py | 16 ++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/openstack_releases/processutils.py b/openstack_releases/processutils.py index 5ca395092d..da3d9f8428 100644 --- a/openstack_releases/processutils.py +++ b/openstack_releases/processutils.py @@ -13,6 +13,7 @@ # under the License. import logging +import os import subprocess @@ -42,7 +43,14 @@ def check_call(*popenargs, timeout=None, **kwargs): LOG.debug('cwd = {}'.format(kwargs['cwd'])) LOG.debug('$ {}'.format(' '.join(cmd))) - completed = subprocess.run(*popenargs, **kwargs) + # Copy full environment to pass in so we can include any of our own + # environment variables with it. + env = os.environ.copy() + env_extras = kwargs.pop('env', None) + if env_extras: + env.update(env_extras) + + completed = subprocess.run(*popenargs, env=env, **kwargs) _multi_line_log(logging.DEBUG, completed.stdout.decode('utf-8')) if completed.returncode: @@ -74,10 +82,18 @@ def check_output(*popenargs, timeout=None, **kwargs): if 'stderr' not in kwargs: kwargs['stderr'] = subprocess.PIPE + # Copy full environment to pass in so we can include any of our own + # environment variables with it. + env = os.environ.copy() + env_extras = kwargs.pop('env', None) + if env_extras: + env.update(env_extras) + completed = subprocess.run(*popenargs, stdout=subprocess.PIPE, timeout=timeout, check=True, + env=env, **kwargs) if completed.stderr: diff --git a/openstack_releases/pythonutils.py b/openstack_releases/pythonutils.py index d9207136bb..48cd6b8df9 100644 --- a/openstack_releases/pythonutils.py +++ b/openstack_releases/pythonutils.py @@ -86,18 +86,18 @@ def build_sdist(workdir, repo): python = '.tox/venv/bin/python3' else: python = 'python3' + # Set some flags to turn off pbr functionality that we don't need. - # This is currently causing some failures, so for now we are not passing - # along until we understand why. - # flags = { - # 'SKIP_GENERATE_RENO': '1', - # 'SKIP_GENERATE_AUTHORS': '1', - # 'SKIP_WRITE_GIT_CHANGELOG': '1', - # } + flags = { + 'SKIP_GENERATE_RENO': '1', + 'SKIP_GENERATE_AUTHORS': '1', + 'SKIP_WRITE_GIT_CHANGELOG': '1', + } cmd = [python, 'setup.py', 'sdist', 'bdist_wheel'] processutils.check_call( cmd, - cwd=dest) + cwd=dest, + env=flags) def check_readme_format(workdir, repo):