Skip to content

Commit db39985

Browse files
committed
revert PR9; add --no-deps to pip wheel
Revert PR9; it was never actually needed in the first place it just fixed an issue by side effect. 1) add --no-deps to pip wheel step in order to avoid building wheels for dependencies. This also addresses the issues raised in PR pypa#11. 2) Modify the pip install step across platforms to allow installation of dependencies from the index. (This is required since we will no longer be building wheels for dependencies).
1 parent 5b7f105 commit db39985

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
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

+3-6
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
5959
PATH=$PYBIN:$PATH sh -c {before_build}
6060
fi
6161
62-
# install the package first to take care of dependencies
63-
"$PYBIN/pip" install .
64-
65-
"$PYBIN/pip" wheel --no-deps . -w /tmp/linux_wheels
62+
"$PYBIN/pip" wheel . -w /tmp/linux_wheels --no-deps
6663
done
6764
6865
for whl in /tmp/linux_wheels/*.whl; do
@@ -77,8 +74,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
7774
# Install packages and test
7875
for PYBIN in {pybin_paths}; do
7976
# Install the wheel we just built
80-
"$PYBIN/pip" install {package_name} \
81-
--upgrade --force-reinstall --no-deps --no-index -f /output
77+
"$PYBIN/pip" install $("$PYBIN/python" /cibw/filter_wheels.py /tmp/linux_wheels/*.whl)
8278
8379
# Install any requirements to run the tests
8480
if [ ! -z "{test_requires}" ]; then
@@ -111,6 +107,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
111107
'-i',
112108
'-v', '%s:/project' % os.path.abspath(project_dir),
113109
'-v', '%s:/output' % os.path.abspath(output_dir),
110+
'-v', '%s:/cibw' % os.path.dirname(__file__),
114111
docker_image,
115112
'/bin/bash'],
116113
stdin=subprocess.PIPE, universal_newlines=True)

cibuildwheel/macos.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import print_function
2-
import os, subprocess, shlex, sys
2+
import os, subprocess, shlex, sys, re
33
from collections import namedtuple
44
from glob import glob
55
try:
@@ -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):
@@ -22,7 +23,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
2223
def shell(args, env=None, cwd=None):
2324
# print the command executing for the logs
2425
print('+ ' + ' '.join(shlex_quote(a) for a in args))
25-
return subprocess.check_call(args, env=env, cwd=cwd)
26+
return subprocess.check_output(args, env=env, cwd=cwd)
2627

2728
for config in python_configurations:
2829
if skip(config.identifier):
@@ -58,14 +59,11 @@ def shell(args, env=None, cwd=None):
5859
before_build_prepared = prepare_command(before_build, python=python, pip=pip)
5960
shell(shlex.split(before_build_prepared), env=env)
6061

61-
# install the package first to take care of dependencies
62-
shell([pip, 'install', project_dir], env=env)
63-
6462
# build the wheel to temp dir
6563
temp_wheel_dir = '/tmp/tmpwheel%s' % config.version
6664
shell([pip, 'wheel', project_dir, '-w', temp_wheel_dir, '--no-deps'], env=env)
67-
temp_wheel = glob(temp_wheel_dir+'/*.whl')[0]
6865

66+
temp_wheel = glob(temp_wheel_dir+'/*.whl')[0]
6967
if temp_wheel.endswith('none-any.whl'):
7068
# pure python wheel - just copy to output_dir
7169
shell(['cp', temp_wheel, output_dir], env=env)
@@ -75,9 +73,14 @@ def shell(args, env=None, cwd=None):
7573
# rebuild the wheel with shared libraries included and place in output dir
7674
shell(['delocate-wheel', '-w', output_dir, temp_wheel], env=env)
7775

78-
# now install the package from the generated wheel
79-
shell([pip, 'install', package_name, '--upgrade', '--force-reinstall',
80-
'--no-deps', '--no-index', '--find-links', output_dir], env=env)
76+
# Grab the built wheel for this platform
77+
# Note: filter wheels *must* be run from inside the build environment
78+
filter_wheels = os.path.join(os.path.dirname(__file__), 'filter_wheels.py')
79+
stdout = shell([python, filter_wheels, output_dir + '/*.whl'], env=env)
80+
wheels = re.findall(r"^%s/.*\.whl$" % output_dir, stdout, re.MULTILINE)
81+
82+
# install the wheel
83+
shell([pip, 'install'] + wheels, env=env)
8184

8285
# test the wheel
8386
if test_requires:

cibuildwheel/windows.py

+10-9
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:
@@ -17,11 +17,11 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
1717
request = urlopen('https://github.com/ogrisel/python-appveyor-demo/raw/09a1c8672e5015a74d8f69d07add6ee803c176ec/appveyor/run_with_env.cmd')
1818
f.write(request.read())
1919

20-
def shell(args, env=None, cwd=None):
20+
def shell(args, env=None, cwd=None, **kwargs):
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, **kwargs)
2525

2626
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'arch', 'identifier', 'path'])
2727
python_configurations = [
@@ -66,16 +66,17 @@ def shell(args, env=None, cwd=None):
6666
before_build_prepared = prepare_command(before_build, python='python', pip='pip')
6767
shell([before_build_prepared], env=env)
6868

69-
# install the package first to take care of dependencies
70-
shell(['pip', 'install', project_dir], env=env)
71-
7269
# build the wheel
7370
shell(['pip', 'wheel', project_dir, '-w', output_dir, '--no-deps'], env=env)
7471

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, universal_newlines=True)
76+
wheels = re.findall(r"^%s\\.*\.whl$" % output_dir, stdout, re.MULTILINE)
77+
7578
# install the wheel
76-
shell(['pip', 'install', package_name, '--upgrade',
77-
'--force-reinstall', '--no-deps', '--no-index', '-f',
78-
output_dir], env=env)
79+
shell(['pip', 'install'] + wheels, env=env)
7980

8081
# test the wheel
8182
if test_requires:

0 commit comments

Comments
 (0)