Skip to content

Commit

Permalink
Removing Python 2-compatible imports of urllib.request.open and shlex…
Browse files Browse the repository at this point in the history
….quote
  • Loading branch information
YannickJadoul committed Feb 3, 2020
1 parent 6bd3fbd commit 74253c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
13 changes: 4 additions & 9 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from __future__ import print_function
import os, subprocess, sys, uuid
import os, shlex, subprocess, sys, uuid
from collections import namedtuple
from .util import prepare_command, get_build_verbosity_extra_flags

try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote


def get_python_configurations(build_selector):
PythonConfiguration = namedtuple('PythonConfiguration', ['identifier', 'path'])
Expand Down Expand Up @@ -132,14 +127,14 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
pybin_paths=' '.join(c.path+'/bin' for c in platform_configs),
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()),
Expand Down
6 changes: 1 addition & 5 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import os, subprocess, shlex, sys, shutil
from collections import namedtuple
from glob import glob
try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote

from .util import prepare_command, get_build_verbosity_extra_flags, download

Expand Down Expand Up @@ -46,7 +42,7 @@ def call(args, env=None, cwd=None, shell=False):
if shell:
print('+ %s' % args)
else:
print('+ ' + ' '.join(shlex_quote(a) for a in args))
print('+ ' + ' '.join(shlex.quote(a) for a in args))

return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)

Expand Down
9 changes: 2 additions & 7 deletions cibuildwheel/util.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from fnmatch import fnmatch
import warnings
import os
import os, urllib.request
from time import sleep

try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen


def prepare_command(command, **kwargs):
'''
Expand Down Expand Up @@ -68,7 +63,7 @@ def download(url, dest):
repeat_num = 3
for i in range(repeat_num):
try:
response = urlopen(url)
response = urllib.request.urlopen(url)
except:
if i == repeat_num - 1:
raise
Expand Down
5 changes: 0 additions & 5 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
from collections import namedtuple
from glob import glob

try:
from shlex import quote as shlex_quote
except ImportError:
from pipes import quote as shlex_quote

from .util import prepare_command, get_build_verbosity_extra_flags, download


Expand Down

0 comments on commit 74253c0

Please sign in to comment.