Skip to content

Commit a6fb5f1

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 a6fb5f1

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed

cibuildwheel/linux.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import print_function
22
import os, subprocess, sys
33
from collections import namedtuple
4-
from .util import prepare_command
4+
from .util import prepare_command, filter_wheels_cmd
55

66
try:
77
from shlex import quote as shlex_quote
@@ -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" -c "{filter_wheels}" /tmp/linux_wheels/*.whl)
8278
8379
# Install any requirements to run the tests
8480
if [ ! -z "{test_requires}" ]; then
@@ -93,6 +89,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
9389
fi
9490
done
9591
'''.format(
92+
filter_wheels=filter_wheels_cmd,
9693
package_name=package_name,
9794
pybin_paths=' '.join(c.path+'/bin' for c in platform_configs),
9895
test_requires=' '.join(test_requires),

cibuildwheel/macos.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
except ImportError:
88
from pipes import quote as shlex_quote
99

10-
from .util import prepare_command
10+
from .util import prepare_command, filter_wheels_cmd
1111

1212

1313
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip):
@@ -22,7 +22,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
2222
def shell(args, env=None, cwd=None):
2323
# print the command executing for the logs
2424
print('+ ' + ' '.join(shlex_quote(a) for a in args))
25-
return subprocess.check_call(args, env=env, cwd=cwd)
25+
return subprocess.check_output(args, env=env, cwd=cwd)
2626

2727
for config in python_configurations:
2828
if skip(config.identifier):
@@ -58,14 +58,11 @@ def shell(args, env=None, cwd=None):
5858
before_build_prepared = prepare_command(before_build, python=python, pip=pip)
5959
shell(shlex.split(before_build_prepared), env=env)
6060

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

65+
temp_wheel = glob(temp_wheel_dir+'/*.whl')[0]
6966
if temp_wheel.endswith('none-any.whl'):
7067
# pure python wheel - just copy to output_dir
7168
shell(['cp', temp_wheel, output_dir], env=env)
@@ -75,9 +72,12 @@ def shell(args, env=None, cwd=None):
7572
# rebuild the wheel with shared libraries included and place in output dir
7673
shell(['delocate-wheel', '-w', output_dir, temp_wheel], env=env)
7774

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)
75+
# Grab the built wheel for this platform
76+
# Note: filter wheels *must* be run from inside the build environment
77+
wheels = shell([python, '-c', filter_wheels_cmd, output_dir + '/*.whl'], env=env).split()
78+
79+
# install the wheel
80+
shell([pip, 'install'] + wheels, env=env)
8181

8282
# test the wheel
8383
if test_requires:

cibuildwheel/util.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from fnmatch import fnmatch
22

3+
filter_wheels_cmd = '''\
4+
import sys, glob, itertools, pip; \
5+
sys.stdout.write(\
6+
' '.join(f for f in itertools.chain(*map(glob.iglob, sys.argv[1:])) \
7+
if pip.wheel.Wheel(f).supported()))\
8+
'''
39

410
def prepare_command(command, python, pip):
511
'''

cibuildwheel/windows.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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:
66
from urllib.request import urlopen
77
from collections import namedtuple
88

9-
from .util import prepare_command
9+
from .util import prepare_command, filter_wheels_cmd
1010

1111

1212
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip):
@@ -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 = [
@@ -66,16 +66,16 @@ 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+
stdout = shell(['python', '-c', '"'+filter_wheels_cmd+'"', output_dir + '\*.whl'], env=env)
75+
wheels = re.findall(output_dir + r'\\[^\s*]+\.whl', stdout, re.MULTILINE)
76+
7577
# install the wheel
76-
shell(['pip', 'install', package_name, '--upgrade',
77-
'--force-reinstall', '--no-deps', '--no-index', '-f',
78-
output_dir], env=env)
78+
shell(['pip', 'install'] + wheels, env=env)
7979

8080
# test the wheel
8181
if test_requires:

0 commit comments

Comments
 (0)