Skip to content

Commit 6ead47f

Browse files
author
ibriquem
committed
Disable wheel usage only on single package instead of whole session, fix for pypa#4118
1 parent da4d616 commit 6ead47f

File tree

8 files changed

+48
-4
lines changed

8 files changed

+48
-4
lines changed

src/pip/_internal/req/req_file.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from __future__ import absolute_import
66

7+
import copy
78
import optparse
89
import os
910
import re
@@ -128,8 +129,8 @@ def process_line(line, filename, line_number, finder=None, comes_from=None,
128129
defaults = parser.get_default_values()
129130
defaults.index_url = None
130131
if finder:
131-
# `finder.format_control` will be updated during parsing
132-
defaults.format_control = finder.format_control
132+
# `finder.format_control` should be local to each line
133+
defaults.format_control = copy.deepcopy(finder.format_control)
133134
args_str, options_str = break_args_options(line)
134135
if sys.version_info < (2, 7, 3):
135136
# Prior to 2.7.3, shlex cannot deal with unicode entries
@@ -144,8 +145,8 @@ def process_line(line, filename, line_number, finder=None, comes_from=None,
144145
# yield a line requirement
145146
if args_str:
146147
isolated = options.isolated_mode if options else False
147-
if options:
148-
cmdoptions.check_install_build_global(options, opts)
148+
if opts:
149+
cmdoptions.check_install_build_global(opts, opts)
149150
# get the options that apply to requirements
150151
req_options = {}
151152
for dest in SUPPORTED_OPTIONS_REQ_DEST:
@@ -217,6 +218,8 @@ def process_line(line, filename, line_number, finder=None, comes_from=None,
217218
if opts.trusted_hosts:
218219
finder.secure_origins.extend(
219220
("*", host, "*") for host in opts.trusted_hosts)
221+
if options:
222+
cmdoptions.check_install_build_global(options, opts)
220223

221224

222225
def break_args_options(line):

tests/data/packages/README.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,7 @@ require_simple-1.0.tar.gz
113113
------------------------
114114
contains "require_simple" package which requires simple>=2.0 - used for testing
115115
if dependencies are handled correctly.
116+
117+
wheel_only*
118+
-----------
119+
A package which fails to install from source, but can be installed from wheel (simulates a prebuilt binary package with missing include files).
1007 Bytes
Binary file not shown.
743 Bytes
Binary file not shown.

tests/data/src/wheel_only/setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[egg_info]
2+
tag_build =
3+
tag_date = 0
4+
tag_svn_revision = 0
5+

tests/data/src/wheel_only/setup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
from setuptools import setup, find_packages
3+
import os
4+
5+
# This simulates a requirement which is not necessary in the wheel
6+
# But needed if building from source
7+
if 'BUILDING_WHEEL' not in os.environ:
8+
raise Exception("Fake build error")
9+
10+
setup(name='wheel_only',
11+
version='1.0',
12+
packages=find_packages()
13+
)

tests/data/src/wheel_only/wheel_only.py

Whitespace-only changes.

tests/functional/test_install_reqs.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,22 @@ def test_install_options_local_to_package(script, data):
547547
assert bad not in result.files_created
548548
assert good in result.files_created
549549
assert result.files_created[good].dir
550+
551+
552+
def test_install_options_does_not_disable_wheels(script, data):
553+
"""Make sure --install-options disable wheel usage for other packages."""
554+
home_simple = script.scratch_path.join("for-simple")
555+
home_simple.mkdir()
556+
reqs_file = script.scratch_path.join("reqs.txt")
557+
reqs_file.write(
558+
textwrap.dedent("""
559+
simple --install-option='--home=%s'
560+
wheel-only
561+
""" % home_simple))
562+
result = script.pip(
563+
'install',
564+
'--no-index', '-f', data.find_links,
565+
'-r', reqs_file,
566+
expect_error=False,
567+
expect_stderr=True,
568+
)

0 commit comments

Comments
 (0)