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 <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-05-11 07:54:37 -05:00
parent c75a909d1f
commit f402cde902
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
2 changed files with 25 additions and 9 deletions

View File

@ -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:

View File

@ -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):