Skip to content

Commit b6e0964

Browse files
committed
alternative fix for pypa#11
1 parent 7a510c7 commit b6e0964

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

cibuildwheel/filter_wheels.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
""" Filter out wheel filenames not supported on this platform
3+
"""
4+
from __future__ import print_function
5+
6+
def is_supported(fname):
7+
from pip.wheel import Wheel
8+
return Wheel(fname).supported()
9+
10+
if __name__ == '__main__':
11+
import sys
12+
from itertools import chain
13+
from glob import iglob
14+
for whl in filter(is_supported, chain(*map(iglob, sys.argv[1:]))):
15+
print(whl)
16+
sys.exit(0)

cibuildwheel/linux.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
7272
# Install packages and test
7373
for PYBIN in {pybin_paths}; do
7474
# Install the wheel we just built
75-
"$PYBIN/pip" install {package_name} --no-index -f /output
75+
"$PYBIN/pip" install $("$PYBIN/python" /cibw/filter_wheels.py /tmp/linux_wheels/*.whl)
7676
7777
# Install any requirements to run the tests
7878
if [ ! -z "{test_requires}" ]; then
@@ -105,6 +105,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
105105
'-i',
106106
'-v', '%s:/project' % os.path.abspath(project_dir),
107107
'-v', '%s:/output' % os.path.abspath(output_dir),
108+
'-v', '%s:/cibw' % os.path.dirname(__file__),
108109
docker_image,
109110
'/bin/bash'],
110111
stdin=subprocess.PIPE, universal_newlines=True)

cibuildwheel/macos.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pipes import quote as shlex_quote
99

1010
from .util import prepare_command
11+
from .filter_wheels import is_supported
1112

1213

1314
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip):
@@ -61,19 +62,19 @@ def shell(args, env=None, cwd=None):
6162
# build the wheel to temp dir
6263
temp_wheel_dir = '/tmp/tmpwheel%s' % config.version
6364
shell([pip, 'wheel', project_dir, '-w', temp_wheel_dir, '--no-deps'], env=env)
64-
temp_wheel = glob(temp_wheel_dir+'/*.whl')[0]
6565

66-
if temp_wheel.endswith('none-any.whl'):
67-
# pure python wheel - just copy to output_dir
68-
shell(['cp', temp_wheel, output_dir], env=env)
69-
else:
70-
# list the dependencies
71-
shell(['delocate-listdeps', temp_wheel], env=env)
72-
# rebuild the wheel with shared libraries included and place in output dir
73-
shell(['delocate-wheel', '-w', output_dir, temp_wheel], env=env)
66+
for temp_wheel in glob(temp_wheel_dir+'/*.whl'):
67+
if temp_wheel.endswith('none-any.whl'):
68+
# pure python wheel - just copy to output_dir
69+
shell(['cp', temp_wheel, output_dir], env=env)
70+
else:
71+
# list the dependencies
72+
shell(['delocate-listdeps', temp_wheel], env=env)
73+
# rebuild the wheel with shared libraries included and place in output dir
74+
shell(['delocate-wheel', '-w', output_dir, temp_wheel], env=env)
7475

7576
# install the wheel
76-
shell([pip, 'install', package_name, '--no-index', '--find-links', output_dir], env=env)
77+
shell([pip, 'install'] + filter(is_supported, glob(output_dir + '/*.whl')), env=env)
7778

7879
# test the wheel
7980
if test_requires:

cibuildwheel/windows.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import print_function
2-
import os, tempfile, subprocess, sys
2+
import os, tempfile, subprocess, sys, re
33
try:
44
from urllib2 import urlopen
55
except ImportError:
@@ -21,7 +21,7 @@ def shell(args, env=None, cwd=None):
2121
# print the command executing for the logs
2222
print('+ ' + ' '.join(args))
2323
args = ['cmd', '/E:ON', '/V:ON', '/C', run_with_env] + args
24-
return subprocess.check_call(' '.join(args), env=env, cwd=cwd)
24+
return subprocess.check_output(' '.join(args), env=env, cwd=cwd)
2525

2626
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'arch', 'identifier', 'path'])
2727
python_configurations = [
@@ -69,8 +69,14 @@ def shell(args, env=None, cwd=None):
6969
# build the wheel
7070
shell(['pip', 'wheel', project_dir, '-w', output_dir, '--no-deps'], env=env)
7171

72+
# Grab the built wheel for this platform
73+
# Note: filter wheels *must* be run from inside the build environment
74+
filter_wheels = os.path.join(os.path.dirname(__file__), 'filter_wheels.py')
75+
stdout = shell(['python', filter_wheels, output_dir + '\*.whl'], env=env)
76+
wheels = re.findall(r'^wheelhouse\\.*.whl$', stdout, re.MULTILINE)
77+
7278
# install the wheel
73-
shell(['pip', 'install', package_name, '--no-index', '-f', output_dir], env=env)
79+
shell(['pip', 'install'] + wheels, env=env)
7480

7581
# test the wheel
7682
if test_requires:

0 commit comments

Comments
 (0)