Skip to content

Commit b8ff0e1

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 b2fc3f4 commit b8ff0e1

File tree

4 files changed

+65
-41
lines changed

4 files changed

+65
-41
lines changed

cibuildwheel/__main__.py

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def main():
107107

108108
print_preamble(platform, build_options)
109109

110+
if not os.path.exists(output_dir):
111+
os.mkdir(output_dir)
112+
110113
if platform == 'linux':
111114
cibuildwheel.linux.build(**build_options)
112115
elif platform == 'windows':

cibuildwheel/linux.py

+22-16
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,33 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
5353
cd /project
5454
5555
for PYBIN in {pybin_paths}; do
56+
# Setup
57+
rm -rf /tmp/built_wheel
58+
rm -rf /tmp/delocated_wheel
59+
mkdir /tmp/built_wheel
60+
mkdir /tmp/delocated_wheel
61+
5662
if [ ! -z {before_build} ]; then
5763
PATH=$PYBIN:$PATH sh -c {before_build}
5864
fi
5965
60-
# install the package first to take care of dependencies
61-
"$PYBIN/pip" install .
62-
63-
"$PYBIN/pip" wheel --no-deps . -w /tmp/linux_wheels
64-
done
66+
# Build that wheel
67+
"$PYBIN/pip" wheel . -w /tmp/built_wheel --no-deps
68+
built_wheel=(/tmp/built_wheel/*.whl)
6569
66-
for whl in /tmp/linux_wheels/*.whl; do
67-
if [[ "$whl" == *none-any.whl ]]; then
68-
# pure python wheel - just copy to the output
69-
cp "$whl" /output
70+
# Delocate the wheel
71+
# NOTE: 'built_wheel' here is a bash array of glob matches; "$built_wheel" returns
72+
# the first element
73+
if [[ "$built_wheel" == *none-any.whl ]]; then
74+
# pure python wheel - just copy
75+
mv "$built_wheel" /tmp/delocated_wheel
7076
else
71-
auditwheel repair "$whl" -w /output
77+
auditwheel repair "$built_wheel" -w /tmp/delocated_wheel
7278
fi
73-
done
79+
delocated_wheel=(/tmp/delocated_wheel/*.whl)
7480
75-
# Install packages and test
76-
for PYBIN in {pybin_paths}; do
7781
# Install the wheel we just built
78-
"$PYBIN/pip" install {package_name} \
79-
--upgrade --force-reinstall --no-deps --no-index -f /output
82+
"$PYBIN/pip" install "$delocated_wheel"
8083
8184
# Install any requirements to run the tests
8285
if [ ! -z "{test_requires}" ]; then
@@ -89,6 +92,9 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
8992
PATH=$PYBIN:$PATH sh -c {test_command}
9093
popd
9194
fi
95+
96+
# we're all done here; move it to output
97+
mv "$delocated_wheel" /output
9298
done
9399
'''.format(
94100
package_name=package_name,
@@ -111,7 +117,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
111117
'-v', '%s:/output' % os.path.abspath(output_dir),
112118
docker_image,
113119
'/bin/bash'],
114-
stdin=subprocess.PIPE, universal_newlines=True)
120+
stdin=subprocess.PIPE, universal_newlines=True)
115121

116122
try:
117123
docker_process.communicate(bash_script)

cibuildwheel/macos.py

+23-16
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, shutil
33
from collections import namedtuple
44
from glob import glob
55
try:
@@ -53,31 +53,35 @@ def shell(args, env=None, cwd=None):
5353
shell([pip, 'install', 'wheel'], env=env)
5454
shell([pip, 'install', 'delocate'], env=env)
5555

56+
# setup dirs
57+
if os.path.exists('/tmp/built_wheel'):
58+
shutil.rmtree('/tmp/built_wheel')
59+
os.makedirs('/tmp/built_wheel')
60+
if os.path.exists('/tmp/delocated_wheel'):
61+
shutil.rmtree('/tmp/delocated_wheel')
62+
os.makedirs('/tmp/delocated_wheel')
63+
5664
# run the before_build command
5765
if before_build:
5866
before_build_prepared = prepare_command(before_build, python=python, pip=pip)
5967
shell(shlex.split(before_build_prepared), env=env)
6068

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

69-
if temp_wheel.endswith('none-any.whl'):
70-
# pure python wheel - just copy to output_dir
71-
shell(['cp', temp_wheel, output_dir], env=env)
73+
if built_wheel.endswith('none-any.whl'):
74+
# pure python wheel - just move
75+
shutil.move(built_wheel, '/tmp/delocated_wheel')
7276
else:
7377
# list the dependencies
74-
shell(['delocate-listdeps', temp_wheel], env=env)
78+
shell(['delocate-listdeps', built_wheel], env=env)
7579
# rebuild the wheel with shared libraries included and place in output dir
76-
shell(['delocate-wheel', '-w', output_dir, temp_wheel], env=env)
80+
shell(['delocate-wheel', '-w', '/tmp/delocated_wheel', built_wheel], env=env)
81+
delocated_wheel = glob('/tmp/delocated_wheel/*.whl')[0]
7782

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)
83+
# install the wheel
84+
shell([pip, 'install', delocated_wheel], env=env)
8185

8286
# test the wheel
8387
if test_requires:
@@ -89,3 +93,6 @@ def shell(args, env=None, cwd=None):
8993
abs_project_dir = os.path.abspath(project_dir)
9094
test_command_absolute = test_command.format(project=abs_project_dir)
9195
shell(shlex.split(test_command_absolute), cwd=os.environ['HOME'], env=env)
96+
97+
# we're all done here; move it to output
98+
shutil.move(delocated_wheel, output_dir)

cibuildwheel/windows.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from __future__ import print_function
2-
import os, tempfile, subprocess, sys
2+
import os, tempfile, subprocess, sys, shutil
33
try:
44
from urllib2 import urlopen
55
except ImportError:
66
from urllib.request import urlopen
77
from collections import namedtuple
8+
from glob import glob
89

910
from .util import prepare_command
1011

@@ -21,7 +22,7 @@ def shell(args, env=None, cwd=None):
2122
# print the command executing for the logs
2223
print('+ ' + ' '.join(args))
2324
args = ['cmd', '/E:ON', '/V:ON', '/C', run_with_env] + args
24-
return subprocess.check_call(' '.join(args), env=env, cwd=cwd)
25+
return subprocess.check_output(' '.join(args), env=env, cwd=cwd)
2526

2627
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'arch', 'identifier', 'path'])
2728
python_configurations = [
@@ -37,11 +38,19 @@ def shell(args, env=None, cwd=None):
3738
PythonConfiguration(version='3.6.x', arch="64", identifier='cp36-win_amd64', path='C:\Python36-x64'),
3839
]
3940

41+
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
42+
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
43+
4044
for config in python_configurations:
4145
if skip(config.identifier):
4246
print('cibuildwheel: Skipping build %s' % config.identifier, file=sys.stderr)
4347
continue
4448

49+
# setup dirs
50+
if os.path.exists(built_wheel_dir):
51+
shutil.rmtree(built_wheel_dir)
52+
os.makedirs(built_wheel_dir)
53+
4554
env = os.environ.copy()
4655
# set up environment variables for run_with_env
4756
env['PYTHON_VERSION'] = config.version
@@ -66,16 +75,12 @@ def shell(args, env=None, cwd=None):
6675
before_build_prepared = prepare_command(before_build, python='python', pip='pip')
6776
shell([before_build_prepared], env=env)
6877

69-
# install the package first to take care of dependencies
70-
shell(['pip', 'install', project_dir], env=env)
71-
7278
# build the wheel
73-
shell(['pip', 'wheel', project_dir, '-w', output_dir, '--no-deps'], env=env)
79+
shell(['pip', 'wheel', project_dir, '-w', built_wheel_dir, '--no-deps'], env=env)
80+
built_wheel = glob(built_wheel_dir+'/*.whl')[0]
7481

7582
# install the wheel
76-
shell(['pip', 'install', package_name, '--upgrade',
77-
'--force-reinstall', '--no-deps', '--no-index', '-f',
78-
output_dir], env=env)
83+
shell(['pip', 'install', built_wheel], env=env)
7984

8085
# test the wheel
8186
if test_requires:
@@ -87,3 +92,6 @@ def shell(args, env=None, cwd=None):
8792
abs_project_dir = os.path.abspath(project_dir)
8893
test_command_absolute = test_command.format(project=abs_project_dir)
8994
shell([test_command_absolute], cwd='c:\\', env=env)
95+
96+
# we're all done here; move it to output
97+
shutil.move(built_wheel, output_dir)

0 commit comments

Comments
 (0)