Skip to content

Commit 6468108

Browse files
committed
Merge branch 'main' into resolvelib-060
2 parents 4e56f1c + a0f6041 commit 6468108

File tree

15 files changed

+66
-29
lines changed

15 files changed

+66
-29
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [main]
66
tags:
77
# Tags for all potential release numbers till 2030.
88
- "2[0-9].[0-3]" # 20.0 -> 29.3

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ sphinx:
55
configuration: docs/html/conf.py
66

77
python:
8-
version: 3.7
8+
version: 3.8
99
install:
1010
- requirements: tools/requirements/docs.txt

docs/html/user_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ When pip finds that an assumption is incorrect, it has to try another approach
13681368
(backtrack), which means discarding some of the work that has already been done,
13691369
and going back to choose another path.
13701370

1371-
For example; The user requests ``pip install tea``. ```tea`` has dependencies of
1371+
For example; The user requests ``pip install tea``. ``tea`` has dependencies of
13721372
``cup``, ``hot-water``, ``spoon`` amongst others.
13731373

13741374
pip starts by installing a version of ``cup``. If it finds out it isn’t

news/9409.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``--user`` is no longer suggested incorrectly when pip fails with a permission
2+
error in a virtual environment.

news/9779.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix pip to work with warnings converted to errors.

src/pip/__main__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import warnings
34

45
# Remove '' and current working directory from the first entry
56
# of sys.path, if present to avoid using current directory
@@ -18,7 +19,13 @@
1819
path = os.path.dirname(os.path.dirname(__file__))
1920
sys.path.insert(0, path)
2021

21-
from pip._internal.cli.main import main as _main
22-
2322
if __name__ == "__main__":
23+
# Work around the error reported in #9540, pending a proper fix.
24+
# Note: It is essential the warning filter is set *before* importing
25+
# pip, as the deprecation happens at import time, not runtime.
26+
warnings.filterwarnings(
27+
"ignore", category=DeprecationWarning, module=".*packaging\\.version"
28+
)
29+
from pip._internal.cli.main import main as _main
30+
2431
sys.exit(_main())

src/pip/_internal/cli/base_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _main(self, args):
165165
"use the TMPDIR/TEMP/TMP environment variable, "
166166
"possibly combined with --no-clean"
167167
),
168-
gone_in="21.1",
168+
gone_in="21.3",
169169
issue=8333,
170170
)
171171

src/pip/_internal/cli/cmdoptions.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,23 @@ def _handle_no_use_pep517(option, opt, value, parser):
824824
"directory path, be sure to use absolute path.",
825825
) # type: Callable[..., Option]
826826

827+
build_options = partial(
828+
Option,
829+
"--build-option",
830+
dest="build_options",
831+
metavar="options",
832+
action="append",
833+
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
834+
) # type: Callable[..., Option]
835+
827836
global_options = partial(
828837
Option,
829838
"--global-option",
830839
dest="global_options",
831840
action="append",
832841
metavar="options",
833842
help="Extra global options to be supplied to the setup.py "
834-
"call before the install command.",
843+
"call before the install or bdist_wheel command.",
835844
) # type: Callable[..., Option]
836845

837846
no_clean = partial(

src/pip/_internal/commands/install.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
write_output,
3636
)
3737
from pip._internal.utils.temp_dir import TempDirectory
38-
from pip._internal.utils.virtualenv import virtualenv_no_global
38+
from pip._internal.utils.virtualenv import (
39+
running_under_virtualenv,
40+
virtualenv_no_global,
41+
)
3942
from pip._internal.wheel_builder import (
4043
BinaryAllowedPredicate,
4144
build,
@@ -725,7 +728,7 @@ def create_os_error_message(error, show_traceback, using_user_site):
725728
user_option_part = "Consider using the `--user` option"
726729
permissions_part = "Check the permissions"
727730

728-
if not using_user_site:
731+
if not running_under_virtualenv() and not using_user_site:
729732
parts.extend([
730733
user_option_part, " or ",
731734
permissions_part.lower(),

src/pip/_internal/commands/wheel.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ def add_options(self):
5454
self.cmd_opts.add_option(cmdoptions.no_binary())
5555
self.cmd_opts.add_option(cmdoptions.only_binary())
5656
self.cmd_opts.add_option(cmdoptions.prefer_binary())
57-
self.cmd_opts.add_option(
58-
'--build-option',
59-
dest='build_options',
60-
metavar='options',
61-
action='append',
62-
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
63-
)
6457
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
6558
self.cmd_opts.add_option(cmdoptions.use_pep517())
6659
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
@@ -81,13 +74,8 @@ def add_options(self):
8174
help="Don't verify if built wheel is valid.",
8275
)
8376

84-
self.cmd_opts.add_option(
85-
'--global-option',
86-
dest='global_options',
87-
action='append',
88-
metavar='options',
89-
help="Extra global options to be supplied to the setup.py "
90-
"call before the 'bdist_wheel' command.")
77+
self.cmd_opts.add_option(cmdoptions.build_options())
78+
self.cmd_opts.add_option(cmdoptions.global_options())
9179

9280
self.cmd_opts.add_option(
9381
'--pre',

tests/functional/test_warning.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ def test_version_warning_is_not_shown_if_python_version_is_not_2(script):
4242

4343
def test_flag_does_nothing_if_python_version_is_not_2(script):
4444
script.pip("list", "--no-python-version-warning")
45+
46+
47+
def test_pip_works_with_warnings_as_errors(script):
48+
script.environ['PYTHONWARNINGS'] = 'error'
49+
script.pip("--version")

tests/lib/venv.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import compileall
22
import shutil
3+
import subprocess
34
import sys
45
import textwrap
56
import venv as _venv
@@ -55,11 +56,16 @@ def _create(self, clear=False):
5556
else:
5657
# Create a new virtual environment.
5758
if self._venv_type == "virtualenv":
58-
_virtualenv.create_environment(
59-
self.location,
60-
no_pip=True,
61-
no_wheel=True,
62-
no_setuptools=True,
59+
subprocess.check_call(
60+
[
61+
sys.executable,
62+
"-m",
63+
"virtualenv",
64+
"--no-pip",
65+
"--no-wheel",
66+
"--no-setuptools",
67+
str(self.location),
68+
]
6369
)
6470
self._fix_virtualenv_site_module()
6571
elif self._venv_type == "venv":

tests/unit/test_command_install.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
from pip._vendor.packaging.requirements import Requirement
66

7+
from pip._internal.commands import install
78
from pip._internal.commands.install import (
89
create_os_error_message,
910
decide_user_install,
@@ -109,7 +110,8 @@ def test_rejection_for_location_requirement_options():
109110
' permissions.\n'),
110111
])
111112
def test_create_os_error_message(
112-
error, show_traceback, using_user_site, expected
113+
monkeypatch, error, show_traceback, using_user_site, expected
113114
):
115+
monkeypatch.setattr(install, "running_under_virtualenv", lambda: False)
114116
msg = create_os_error_message(error, show_traceback, using_user_site)
115117
assert msg == expected

tests/unit/test_resolution_legacy_resolver.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def test_sort_best_candidate__has_non_yanked(self, caplog, monkeypatch):
201201
"""
202202
Test unyanked candidate preferred over yanked.
203203
"""
204+
# Ignore spurious DEBUG level messages
205+
# TODO: Probably better to work out why they are occurring, but IMO the
206+
# tests are at fault here for being to dependent on exact output.
207+
caplog.set_level(logging.WARNING)
204208
candidates = [
205209
make_mock_candidate('1.0'),
206210
make_mock_candidate('2.0', yanked_reason='bad metadata #2'),
@@ -217,6 +221,10 @@ def test_sort_best_candidate__all_yanked(self, caplog, monkeypatch):
217221
"""
218222
Test all candidates yanked.
219223
"""
224+
# Ignore spurious DEBUG level messages
225+
# TODO: Probably better to work out why they are occurring, but IMO the
226+
# tests are at fault here for being to dependent on exact output.
227+
caplog.set_level(logging.WARNING)
220228
candidates = [
221229
make_mock_candidate('1.0', yanked_reason='bad metadata #1'),
222230
# Put the best candidate in the middle, to test sorting.
@@ -253,6 +261,10 @@ def test_sort_best_candidate__yanked_reason(
253261
"""
254262
Test the log message with various reason strings.
255263
"""
264+
# Ignore spurious DEBUG level messages
265+
# TODO: Probably better to work out why they are occurring, but IMO the
266+
# tests are at fault here for being to dependent on exact output.
267+
caplog.set_level(logging.WARNING)
256268
candidates = [
257269
make_mock_candidate('1.0', yanked_reason=yanked_reason),
258270
]

tools/requirements/docs.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
sphinx == 3.2.1
2+
# FIXME: Remove towncrier constraint after upgrading sphinxcontrib-towncrier.
3+
towncrier < 19.9.0
24
furo
35
myst_parser
46
sphinx-copybutton

0 commit comments

Comments
 (0)