Skip to content

Commit 7f9867a

Browse files
committed
Issue pypa#2677: Disable wheels for setup.py options.
Using --install-options, --build-options, --global-options changes the way that setup.py behaves, and isn't honoured by the wheel code. The new wheel autobuilding code made this very obvious - disable the use of wheels when these options are supplied.
1 parent 5456a29 commit 7f9867a

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed

CHANGES.txt

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
* Allow fine grained control over the use of wheels and source builds.
2929
(:pull:`2699`)
3030

31+
* The use of ``--install-option``, ``--global-option`` or ``--build-option``
32+
disable the use of wheels, and the autobuilding of wheels. (:pull:`2711`))
33+
Fixes :issue:`2677`
34+
3135
**6.1.1 (2015-04-07)**
3236

3337
* No longer ignore dependencies which have been added to the standard library,

pip/cmdoptions.py

+18
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ def resolve_wheel_no_use_binary(options):
3535
fmt_ctl_no_use_wheel(control)
3636

3737

38+
def check_install_build_global(options, getname=None, check_options=None):
39+
"""Disable wheels if per-setup.py call options are set.
40+
41+
:param options: The OptionParser options to update.
42+
:param getname: If supplied what to use to get a name from check_options.
43+
:param check_options: The options to check, if not supplied defaults to
44+
options.
45+
"""
46+
if getname is None:
47+
getname = lambda n: getattr(options, n, None)
48+
if check_options is None:
49+
check_options = options
50+
names = ["build_options", "global_options", "install_options"]
51+
if any(map(getname, names)):
52+
control = options.format_control
53+
fmt_ctl_no_use_wheel(control)
54+
55+
3856
###########
3957
# options #
4058
###########

pip/commands/install.py

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def _build_package_finder(self, options, index_urls, session):
194194

195195
def run(self, options, args):
196196
cmdoptions.resolve_wheel_no_use_binary(options)
197+
cmdoptions.check_install_build_global(options)
197198

198199
if options.download_dir:
199200
options.ignore_installed = True

pip/commands/wheel.py

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def check_required_packages(self):
125125
def run(self, options, args):
126126
self.check_required_packages()
127127
cmdoptions.resolve_wheel_no_use_binary(options)
128+
cmdoptions.check_install_build_global(options)
128129

129130
index_urls = [options.index_url] + options.extra_index_urls
130131
if options.no_index:

pip/req/req_file.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from __future__ import absolute_import
77

8+
from operator import itemgetter
89
import os
910
import re
1011
import shlex
@@ -131,6 +132,7 @@ def parse_content(filename, content, finder=None, comes_from=None,
131132
req, opts = value
132133
comes_from = '-r %s (line %s)' % (filename, line_number)
133134
isolated = options.isolated_mode if options else False
135+
cmdoptions.check_install_build_global(options, itemgetter, opts)
134136
yield InstallRequirement.from_line(
135137
req, comes_from, isolated=isolated, options=opts,
136138
wheel_cache=wheel_cache)

tests/unit/test_req_file.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from optparse import Values
12
import os
23
import subprocess
34
from textwrap import dedent
@@ -9,7 +10,7 @@
910
import pip
1011
from pip.exceptions import RequirementsFileParseError
1112
from pip.download import PipSession
12-
from pip.index import PackageFinder
13+
from pip.index import FormatControl, PackageFinder
1314
from pip.req.req_install import InstallRequirement
1415
from pip.req.req_file import (parse_requirement_options, parse_content,
1516
parse_requirements, parse_line, join_lines,
@@ -338,6 +339,7 @@ def test_install_requirements_with_options(self, tmpdir, finder, session):
338339
install_option = '--prefix=/opt'
339340

340341
content = '''
342+
--only-binary :all:
341343
INITools == 2.0 --global-option="{global_option}" \
342344
--install-option "{install_option}"
343345
'''.format(global_option=global_option, install_option=install_option)
@@ -346,8 +348,12 @@ def test_install_requirements_with_options(self, tmpdir, finder, session):
346348
with open(req_path, 'w') as fh:
347349
fh.write(content)
348350

349-
req = next(parse_requirements(req_path, finder=finder,
350-
session=session))
351+
options = Values()
352+
options.format_control = FormatControl(set(), set())
353+
options.skip_requirements_regex = None
354+
options.isolated_mode = False
355+
req = next(parse_requirements(
356+
req_path, finder=finder, options=options, session=session))
351357

352358
req.source_dir = os.curdir
353359
with patch.object(subprocess, 'Popen') as popen:
@@ -360,3 +366,5 @@ def test_install_requirements_with_options(self, tmpdir, finder, session):
360366
assert call.index(install_option) > \
361367
call.index('install') > \
362368
call.index(global_option) > 0
369+
assert options.format_control.no_binary == set([':all:'])
370+
assert options.format_control.only_binary == set([])

0 commit comments

Comments
 (0)