Skip to content

Commit e3f2540

Browse files
committed
Fix some PEP-008 issues
1 parent 1f1ab50 commit e3f2540

File tree

6 files changed

+42
-23
lines changed

6 files changed

+42
-23
lines changed

cibuildwheel/__main__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
from __future__ import print_function
2-
import argparse, os, subprocess, sys, textwrap
2+
3+
import argparse
4+
import os
5+
import sys
6+
import textwrap
7+
import traceback
38

49
import cibuildwheel
5-
import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos
10+
import cibuildwheel.linux
11+
import cibuildwheel.macos
12+
import cibuildwheel.windows
613
from cibuildwheel.environment import parse_environment, EnvironmentParseError
714
from cibuildwheel.util import BuildSelector, Unbuffered
815

16+
917
def get_option_from_environment(option_name, platform=None, default=None):
1018
'''
1119
Returns an option from the environment, optionally scoped by the platform.
@@ -108,9 +116,8 @@ def main():
108116

109117
try:
110118
environment = parse_environment(environment_config)
111-
except (EnvironmentParseError, ValueError) as e:
119+
except (EnvironmentParseError, ValueError):
112120
print('cibuildwheel: Malformed environment option "%s"' % environment_config, file=sys.stderr)
113-
import traceback
114121
traceback.print_exc(None, sys.stderr)
115122
exit(2)
116123

@@ -207,7 +214,6 @@ def print_preamble(platform, build_options):
207214

208215
print('cibuildwheel version %s\n' % cibuildwheel.__version__)
209216

210-
211217
print('Build options:')
212218
print(' platform: %r' % platform)
213219
for option, value in sorted(build_options.items()):

cibuildwheel/linux.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from __future__ import print_function
2-
import os, subprocess, sys, uuid
2+
3+
import os
4+
import subprocess
5+
import sys
6+
import uuid
37
from collections import namedtuple
8+
49
from .util import prepare_command, get_build_verbosity_extra_flags
510

611
try:
@@ -33,7 +38,7 @@ def get_python_configurations(build_selector):
3338
def build(project_dir, output_dir, test_command, test_requires, test_extras, before_build, build_verbosity, build_selector, delocate_command, environment, manylinux_images):
3439
try:
3540
subprocess.check_call(['docker', '--version'])
36-
except:
41+
except Exception:
3742
print('cibuildwheel: Docker not found. Docker is required to run Linux builds. '
3843
'If you\'re building on Travis CI, add `services: [docker]` to your .travis.yml.'
3944
'If you\'re building on Circle CI in Linux, add a `setup_remote_docker` step to your .circleci/config.yml',
@@ -131,7 +136,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
131136
for delocated_wheel in "${{delocated_wheels[@]}}"; do chown {uid}:{gid} "/output/$(basename "$delocated_wheel")"; done
132137
done
133138
'''.format(
134-
pybin_paths=' '.join(c.path+'/bin' for c in platform_configs),
139+
pybin_paths=' '.join(c.path + '/bin' for c in platform_configs),
135140
test_requires=' '.join(test_requires),
136141
test_extras=test_extras,
137142
test_command=shlex_quote(
@@ -170,7 +175,7 @@ def run_docker(command, stdin_str=None):
170175
'--env', 'CIBUILDWHEEL',
171176
'--name', container_name,
172177
'-i',
173-
'-v', '/:/host', # ignored on Circle
178+
'-v', '/:/host', # ignored on Circle
174179
docker_image, '/bin/bash'])
175180
run_docker(['cp', os.path.abspath(project_dir) + '/.', container_name + ':/project'])
176181
run_docker(['start', '-i', '-a', container_name], stdin_str=bash_script)

cibuildwheel/macos.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
from __future__ import print_function
2+
23
import tempfile
3-
import os, subprocess, shlex, sys, shutil
4+
import os
5+
import subprocess
6+
import sys
7+
import shutil
48
from collections import namedtuple
59
from glob import glob
10+
11+
from .util import prepare_command, get_build_verbosity_extra_flags
12+
613
try:
714
from shlex import quote as shlex_quote
815
except ImportError:
916
from pipes import quote as shlex_quote
1017

11-
from .util import prepare_command, get_build_verbosity_extra_flags
12-
1318

1419
def get_python_configurations(build_selector):
1520
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url'])
@@ -35,7 +40,7 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
3540
get_pip_url = 'https://bootstrap.pypa.io/get-pip.py'
3641
get_pip_script = '/tmp/get-pip.py'
3742

38-
pkgs_output = subprocess.check_output(['pkgutil', '--pkgs'])
43+
pkgs_output = subprocess.check_output(['pkgutil', '--pkgs'])
3944
if sys.version_info[0] >= 3:
4045
pkgs_output = pkgs_output.decode('utf8')
4146
installed_system_packages = pkgs_output.splitlines()

cibuildwheel/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from fnmatch import fnmatch
2-
import warnings
32

43

54
def prepare_command(command, replace_dict):

cibuildwheel/windows.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
from __future__ import print_function
2-
import os, tempfile, subprocess, shutil, sys
2+
3+
import os
4+
import tempfile
5+
import subprocess
6+
import shutil
37
from collections import namedtuple
48
from glob import glob
59

6-
try:
7-
from shlex import quote as shlex_quote
8-
except ImportError:
9-
from pipes import quote as shlex_quote
10+
from .util import prepare_command, get_build_verbosity_extra_flags
1011

1112
try:
1213
from urllib.request import urlopen
1314
except ImportError:
1415
from urllib2 import urlopen
1516

16-
from .util import prepare_command, get_build_verbosity_extra_flags
17-
1817

1918
IS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')
2019
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'
@@ -31,6 +30,7 @@ def get_nuget_args(configuration):
3130
python_name = python_name + "x86"
3231
return [python_name, "-Version", configuration.version, "-OutputDirectory", "C:/cibw/python"]
3332

33+
3434
def get_python_configurations(build_selector):
3535
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'arch', 'identifier'])
3636
python_configurations = [
@@ -51,7 +51,7 @@ def get_python_configurations(build_selector):
5151
# try with (and similar): msiexec /i VCForPython27.msi ALLUSERS=1 ACCEPT=YES /passive
5252
python_configurations = [c for c in python_configurations if not c.version.startswith('2.7.')]
5353

54-
# skip builds as required
54+
# skip builds as required
5555
python_configurations = [c for c in python_configurations if build_selector(c.identifier)]
5656

5757
return python_configurations
@@ -62,6 +62,7 @@ def simple_shell(args, env=None, cwd=None):
6262
print('+ ' + ' '.join(args))
6363
args = ['cmd', '/E:ON', '/V:ON', '/C'] + args
6464
return subprocess.check_call(' '.join(args), env=env, cwd=cwd)
65+
6566
def download(url, dest):
6667
print('+ Download ' + url + ' to ' + dest)
6768
dest_dir = os.path.dirname(dest)
@@ -73,6 +74,7 @@ def download(url, dest):
7374
file.write(response.read())
7475
finally:
7576
response.close()
77+
7678
if IS_RUNNING_ON_AZURE or IS_RUNNING_ON_TRAVIS:
7779
shell = simple_shell
7880
else:
@@ -103,7 +105,7 @@ def shell(args, env=None, cwd=None):
103105
config_python_path = get_python_path(config)
104106
simple_shell([nuget, "install"] + get_nuget_args(config))
105107
if not os.path.exists(os.path.join(config_python_path, 'Scripts', 'pip.exe')):
106-
simple_shell([os.path.join(config_python_path, 'python.exe'), get_pip_script ])
108+
simple_shell([os.path.join(config_python_path, 'python.exe'), get_pip_script])
107109

108110
# check python & pip exist for this configuration
109111
assert os.path.exists(os.path.join(config_python_path, 'python.exe'))

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ replace = cibuildwheel=={new_version}
1919
[bdist_wheel]
2020
universal = 1
2121

22+
[flake8]
23+
ignore = E501

0 commit comments

Comments
 (0)