From b64770a56075719aee09924b02d57c6100992066 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Sun, 9 Sep 2018 16:11:42 +0200 Subject: [PATCH] Cleaning up use of run_docker and removing some debug output --- cibuildwheel/linux.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 387554e9..a6f5bc98 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -67,12 +67,6 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be PATH="$PYBIN:$PATH" sh -c {before_build} fi - pwd - ls -l . - ls -l /project - ls -l /output - ls -l /host - # Build that wheel PATH="$PYBIN:$PATH" "$PYBIN/pip" wheel . -w /tmp/built_wheel --no-deps {build_verbosity_flag} built_wheel=(/tmp/built_wheel/*.whl) @@ -126,7 +120,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be def run_docker(command, stdin_str=None): print('docker command: docker {}'.format(' '.join(map(shlex_quote, command)))) if stdin_str is None: - return subprocess.check_call(['docker'] + command) + subprocess.check_call(['docker'] + command) else: process = subprocess.Popen(['docker'] + command, stdin=subprocess.PIPE, universal_newlines=True) @@ -135,19 +129,22 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be except KeyboardInterrupt: process.kill() process.wait() - return process.returncode + if process.returncode != 0: + raise subprocess.CalledProcessError(process.returncode, process.args) container_name = 'cibuildwheel-{}'.format(uuid.uuid4()) - run_docker(['create', - '--env', 'CIBUILDWHEEL', - '--name', container_name, - '-i', - '-v', '/:/host', # ignored on Circle - docker_image, '/bin/bash']) - run_docker(['cp', os.path.abspath(project_dir) + '/.', container_name + ':/project']) - script_returncode = run_docker(['start', '-i', '-a', container_name], stdin_str=bash_script) - run_docker(['cp', container_name + ':/output/.', os.path.abspath(output_dir)]) - run_docker(['rm', '-v', container_name]) - - if script_returncode != 0: + try: + run_docker(['create', + '--env', 'CIBUILDWHEEL', + '--name', container_name, + '-i', + '-v', '/:/host', # ignored on Circle + docker_image, '/bin/bash']) + run_docker(['cp', os.path.abspath(project_dir) + '/.', container_name + ':/project']) + run_docker(['start', '-i', '-a', container_name], stdin_str=bash_script) + run_docker(['cp', container_name + ':/output/.', os.path.abspath(output_dir)]) + except subprocess.CalledProcessError: exit(1) + finally: + # Still gets executed, even when 'exit(1)' gets called + run_docker(['rm', '-v', container_name])