Skip to content

Commit

Permalink
Issue pypa#2677: Disable wheels for setup.py options.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rbtcollins committed Apr 22, 2015
1 parent 90c0c77 commit 288ccea
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
* Allow fine grained control over the use of wheels and source builds.
(:pull:`2699`)

* The use of ``--install-option``, ``--global-option`` or ``--build-option``
disable the use of wheels, and the autobuilding of wheels. (:pull:`2711`))
Fixes :issue:`2677`

**6.1.1 (2015-04-07)**

* No longer ignore dependencies which have been added to the standard library,
Expand Down
18 changes: 18 additions & 0 deletions pip/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ def resolve_wheel_no_use_binary(options):
fmt_ctl_no_use_wheel(control)


def check_install_build_global(options, getname=None, check_options=None):
"""Disable wheels if per-setup.py call options are set.
:param options: The OptionParser options to update.
:param getname: If supplied what to use to get a name from check_options.
:param check_options: The options to check, if not supplied defaults to
options.
"""
if getname is None:
getname = lambda n: getattr(options, n, None)
if check_options is None:
check_options = options
names = ["build_options", "global_options", "install_options"]
if any(map(getname, names)):
control = options.format_control
fmt_ctl_no_use_wheel(control)


###########
# options #
###########
Expand Down
1 change: 1 addition & 0 deletions pip/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def _build_package_finder(self, options, index_urls, session):

def run(self, options, args):
cmdoptions.resolve_wheel_no_use_binary(options)
cmdoptions.check_install_build_global(options)

if options.download_dir:
options.ignore_installed = True
Expand Down
1 change: 1 addition & 0 deletions pip/commands/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def check_required_packages(self):
def run(self, options, args):
self.check_required_packages()
cmdoptions.resolve_wheel_no_use_binary(options)
cmdoptions.check_install_build_global(options)

index_urls = [options.index_url] + options.extra_index_urls
if options.no_index:
Expand Down
2 changes: 2 additions & 0 deletions pip/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import absolute_import

from operator import itemgetter
import os
import re
import shlex
Expand Down Expand Up @@ -131,6 +132,7 @@ def parse_content(filename, content, finder=None, comes_from=None,
req, opts = value
comes_from = '-r %s (line %s)' % (filename, line_number)
isolated = options.isolated_mode if options else False
cmdoptions.check_install_build_global(options, itemgetter, opts)
yield InstallRequirement.from_line(
req, comes_from, isolated=isolated, options=opts,
wheel_cache=wheel_cache)
Expand Down
14 changes: 11 additions & 3 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from optparse import Values
import os
import subprocess
from textwrap import dedent
Expand All @@ -9,7 +10,7 @@
import pip
from pip.exceptions import RequirementsFileParseError
from pip.download import PipSession
from pip.index import PackageFinder
from pip.index import FormatControl, PackageFinder
from pip.req.req_install import InstallRequirement
from pip.req.req_file import (parse_requirement_options, parse_content,
parse_requirements, parse_line, join_lines,
Expand Down Expand Up @@ -338,6 +339,7 @@ def test_install_requirements_with_options(self, tmpdir, finder, session):
install_option = '--prefix=/opt'

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

req = next(parse_requirements(req_path, finder=finder,
session=session))
options = Values()
options.format_control = FormatControl(set(), set())
options.skip_requirements_regex = None
options.isolated_mode = False
req = next(parse_requirements(
req_path, finder=finder, options=options, session=session))

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

0 comments on commit 288ccea

Please sign in to comment.