Fix all PEP-008 issues

This commit is contained in:
Nicola Soranzo
2020-02-14 15:50:06 +00:00
parent 1e420a9b57
commit cab6ecef24
34 changed files with 175 additions and 65 deletions
+15 -7
View File
@@ -1,10 +1,20 @@
import argparse, os, subprocess, sys, textwrap
import argparse
import os
import sys
import textwrap
import traceback
import cibuildwheel
import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos
from cibuildwheel.environment import parse_environment, EnvironmentParseError
import cibuildwheel.linux
import cibuildwheel.macos
import cibuildwheel.windows
from cibuildwheel.environment import (
EnvironmentParseError,
parse_environment,
)
from cibuildwheel.util import BuildSelector, Unbuffered
def get_option_from_environment(option_name, platform=None, default=None):
'''
Returns an option from the environment, optionally scoped by the platform.
@@ -84,7 +94,6 @@ def main():
file=sys.stderr)
exit(2)
output_dir = args.output_dir
test_command = get_option_from_environment('CIBW_TEST_COMMAND', platform=platform)
test_requires = get_option_from_environment('CIBW_TEST_REQUIRES', platform=platform, default='').split()
@@ -112,9 +121,8 @@ def main():
try:
environment = parse_environment(environment_config)
except (EnvironmentParseError, ValueError) as e:
except (EnvironmentParseError, ValueError):
print('cibuildwheel: Malformed environment option "%s"' % environment_config, file=sys.stderr)
import traceback
traceback.print_exc(None, sys.stderr)
exit(2)
@@ -210,6 +218,7 @@ def detect_obsolete_options():
))
os.environ[option] = os.environ[option].replace(deprecated, alternative)
def print_preamble(platform, build_options):
print(textwrap.dedent('''
_ _ _ _ _ _ _
@@ -220,7 +229,6 @@ def print_preamble(platform, build_options):
print('cibuildwheel version %s\n' % cibuildwheel.__version__)
print('Build options:')
print(' platform: %r' % platform)
for option, value in sorted(build_options.items()):
+8 -3
View File
@@ -1,9 +1,13 @@
import subprocess, shlex, sys
import shlex
import subprocess
import sys
from collections import namedtuple
import bashlex
NodeExecutionContext = namedtuple('NodeExecutionContext', ['environment', 'input'])
def evaluate(value, environment):
if not value:
# empty string evaluates to empty string
@@ -16,9 +20,9 @@ def evaluate(value, environment):
raise ValueError('"%s" has too many parts' % value)
value_word_node = command_node.parts[0]
return evaluate_node(
value_word_node,
value_word_node,
context=NodeExecutionContext(environment=environment, input=value)
)
@@ -63,5 +67,6 @@ def evaluate_command_node(node, context):
return subprocess.check_output(shlex.split(command), env=context.environment, universal_newlines=True)
def evaluate_parameter_node(node, context):
return context.environment.get(node.value, '')
+1
View File
@@ -1,4 +1,5 @@
import bashlex
from . import bashlex_eval
+16 -8
View File
@@ -1,6 +1,15 @@
import os, shlex, subprocess, sys, textwrap, uuid
import os
import shlex
import subprocess
import sys
import textwrap
import uuid
from collections import namedtuple
from .util import prepare_command, get_build_verbosity_extra_flags
from .util import (
get_build_verbosity_extra_flags,
prepare_command,
)
def get_python_configurations(build_selector):
@@ -27,7 +36,7 @@ def get_python_configurations(build_selector):
def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, repair_command, environment, manylinux_images):
try:
subprocess.check_call(['docker', '--version'])
except:
except Exception:
print('cibuildwheel: Docker not found. Docker is required to run Linux builds. '
'If you\'re building on Travis CI, add `services: [docker]` to your .travis.yml.'
'If you\'re building on Circle CI in Linux, add a `setup_remote_docker` step to your .circleci/config.yml',
@@ -123,7 +132,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
for repaired_wheel in "${{repaired_wheels[@]}}"; do chown {uid}:{gid} "/output/$(basename "$repaired_wheel")"; done
done
'''.format(
pybin_paths=' '.join(c.path+'/bin' for c in platform_configs),
pybin_paths=' '.join(c.path + '/bin' for c in platform_configs),
test_requires=' '.join(test_requires),
test_extras=test_extras,
test_command=shlex.quote(
@@ -147,9 +156,8 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
'--env', 'CIBUILDWHEEL',
'--name', container_name,
'-i',
'-v', '/:/host', # ignored on CircleCI
docker_image, '/bin/bash'],
check=True)
'-v', '/:/host', # ignored on CircleCI
docker_image, '/bin/bash'], check=True)
subprocess.run(['docker', 'cp', os.path.abspath(project_dir) + '/.', container_name + ':/project'], check=True)
subprocess.run(['docker', 'start', '-i', '-a', container_name], input=bash_script, universal_newlines=True, check=True)
subprocess.run(['docker', 'cp', container_name + ':/output/.', os.path.abspath(output_dir)], check=True)
@@ -184,5 +192,5 @@ def troubleshoot(project_dir, error):
'''))
print(' Files detected:')
print('\n'.join([' '+f for f in so_files]))
print('\n'.join([' ' + f for f in so_files]))
print('')
+10 -3
View File
@@ -1,9 +1,16 @@
import os
import shlex
import shutil
import subprocess
import tempfile
import os, subprocess, shlex, sys, shutil
from collections import namedtuple
from glob import glob
from .util import prepare_command, get_build_verbosity_extra_flags, download
from .util import (
download,
get_build_verbosity_extra_flags,
prepare_command,
)
def get_python_configurations(build_selector):
@@ -31,7 +38,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
get_pip_url = 'https://bootstrap.pypa.io/get-pip.py'
get_pip_script = '/tmp/get-pip.py'
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):
+3 -3
View File
@@ -1,6 +1,6 @@
import os
import urllib.request
from fnmatch import fnmatch
import warnings
import os, urllib.request
from time import sleep
@@ -64,7 +64,7 @@ def download(url, dest):
for i in range(repeat_num):
try:
response = urllib.request.urlopen(url)
except:
except Exception:
if i == repeat_num - 1:
raise
sleep(3)
+11 -3
View File
@@ -1,8 +1,15 @@
import os, tempfile, subprocess, shutil, sys
import os
import shutil
import subprocess
import tempfile
from collections import namedtuple
from glob import glob
from .util import prepare_command, get_build_verbosity_extra_flags, download
from .util import (
download,
get_build_verbosity_extra_flags,
prepare_command,
)
IS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')
@@ -20,6 +27,7 @@ def get_nuget_args(configuration):
python_name = python_name + "x86"
return [python_name, "-Version", configuration.version, "-OutputDirectory", "C:/cibw/python"]
def get_python_configurations(build_selector):
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'arch', 'identifier'])
python_configurations = [
@@ -40,7 +48,7 @@ def get_python_configurations(build_selector):
# try with (and similar): msiexec /i VCForPython27.msi ALLUSERS=1 ACCEPT=YES /passive
python_configurations = [c for c in python_configurations if not c.version.startswith('2.7.')]
# skip builds as required
# skip builds as required
python_configurations = [c for c in python_configurations if build_selector(c.identifier)]
return python_configurations