From f2c2a06c19c88809b16933584c698ea881aa4d78 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sat, 15 Feb 2020 11:57:31 +0000 Subject: [PATCH] Merge fixes and code style --- cibuildwheel/linux.py | 26 +++++------------------- cibuildwheel/macos.py | 2 +- setup.cfg | 1 + unit_test/dependency_constraints_test.py | 1 + 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index c89bd940..80306634 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -33,22 +33,6 @@ def get_python_configurations(build_selector): return [c for c in python_configurations if build_selector(c.identifier)] -def run_docker(command, stdin_str=None): - print('docker command: docker {}'.format(' '.join(map(shlex_quote, command)))) - if stdin_str is None: - subprocess.check_call(['docker'] + command) - else: - args = ['docker'] + command - process = subprocess.Popen(args, stdin=subprocess.PIPE, universal_newlines=True) - try: - process.communicate(stdin_str) - except KeyboardInterrupt: - process.kill() - process.wait() - if process.returncode != 0: - raise subprocess.CalledProcessError(process.returncode, args) - - def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, manylinux_images, dependency_constraints): try: subprocess.check_call(['docker', '--version']) @@ -76,14 +60,14 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef '--env', 'CIBUILDWHEEL', '--name', container_name, '-i', - '-v', '/:/host', # ignored on CircleCI + '-v', '/:/host', # ignored on CircleCI docker_image, '/bin/bash']) subprocess.run(['docker', 'cp', os.path.abspath(project_dir) + '/.', container_name + ':/project']) for config in platform_configs: if dependency_constraints: constraints_file = dependency_constraints.get_for_python_version(config.version) - run_docker(['cp', os.path.abspath(constraints_file), container_name + ':/constraints.txt']) + subprocess.run(['docker', 'cp', os.path.abspath(constraints_file), container_name + ':/constraints.txt']) subprocess.run(['docker', 'start', '-i', '-a', container_name], stdin_str=''' set -o errexit @@ -174,14 +158,14 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef config_python_bin=config.path + '/bin', test_requires=' '.join(test_requires), test_extras=test_extras, - test_command=shlex_quote( + test_command=shlex.quote( prepare_command(test_command, project='/project') if test_command else '' ), - before_build=shlex_quote( + before_build=shlex.quote( prepare_command(before_build, project='/project') if before_build else '' ), build_verbosity_flag=' '.join(get_build_verbosity_extra_flags(build_verbosity)), - repair_command=shlex_quote( + repair_command=shlex.quote( prepare_command(repair_command, wheel='"$1"', dest_dir='/tmp/repaired_wheels') if repair_command else '' ), environment_exports='\n'.join(environment.as_shell_commands()), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index c5a1b8f7..f181921d 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -36,7 +36,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef python_configurations = get_python_configurations(build_selector) - pkgs_output = subprocess.check_output(['pkgutil', '--pkgs'], universal_newlines=True) + pkgs_output = subprocess.check_output(['pkgutil', '--pkgs'], universal_newlines=True) installed_system_packages = pkgs_output.splitlines() def call(args, env=None, cwd=None, shell=False): diff --git a/setup.cfg b/setup.cfg index 6c170e29..0c40e1ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,3 +22,4 @@ universal = 1 [flake8] ignore = E501,W503 application-import-names = cibuildwheel +extend-exclude = cibuildwheel/resources/ diff --git a/unit_test/dependency_constraints_test.py b/unit_test/dependency_constraints_test.py index 2f6b3ccc..5d38cabb 100644 --- a/unit_test/dependency_constraints_test.py +++ b/unit_test/dependency_constraints_test.py @@ -1,6 +1,7 @@ from cibuildwheel.util import DependencyConstraints import os + def test_defaults(): dependency_constraints = DependencyConstraints.with_defaults()