提交 64681084 编写于 作者: T Tzu-ping Chung

Merge branch 'main' into resolvelib-060

......@@ -2,7 +2,7 @@ name: CI
on:
push:
branches: [master]
branches: [main]
tags:
# Tags for all potential release numbers till 2030.
- "2[0-9].[0-3]" # 20.0 -> 29.3
......
......@@ -5,6 +5,6 @@ sphinx:
configuration: docs/html/conf.py
python:
version: 3.7
version: 3.8
install:
- requirements: tools/requirements/docs.txt
......@@ -1368,7 +1368,7 @@ When pip finds that an assumption is incorrect, it has to try another approach
(backtrack), which means discarding some of the work that has already been done,
and going back to choose another path.
For example; The user requests ``pip install tea``. ```tea`` has dependencies of
For example; The user requests ``pip install tea``. ``tea`` has dependencies of
``cup``, ``hot-water``, ``spoon`` amongst others.
pip starts by installing a version of ``cup``. If it finds out it isnt
......
``--user`` is no longer suggested incorrectly when pip fails with a permission
error in a virtual environment.
Fix pip to work with warnings converted to errors.
import os
import sys
import warnings
# Remove '' and current working directory from the first entry
# of sys.path, if present to avoid using current directory
......@@ -18,7 +19,13 @@ if __package__ == "":
path = os.path.dirname(os.path.dirname(__file__))
sys.path.insert(0, path)
from pip._internal.cli.main import main as _main
if __name__ == "__main__":
# Work around the error reported in #9540, pending a proper fix.
# Note: It is essential the warning filter is set *before* importing
# pip, as the deprecation happens at import time, not runtime.
warnings.filterwarnings(
"ignore", category=DeprecationWarning, module=".*packaging\\.version"
)
from pip._internal.cli.main import main as _main
sys.exit(_main())
......@@ -165,7 +165,7 @@ class Command(CommandContextMixIn):
"use the TMPDIR/TEMP/TMP environment variable, "
"possibly combined with --no-clean"
),
gone_in="21.1",
gone_in="21.3",
issue=8333,
)
......
......@@ -824,6 +824,15 @@ install_options = partial(
"directory path, be sure to use absolute path.",
) # type: Callable[..., Option]
build_options = partial(
Option,
"--build-option",
dest="build_options",
metavar="options",
action="append",
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
) # type: Callable[..., Option]
global_options = partial(
Option,
"--global-option",
......@@ -831,7 +840,7 @@ global_options = partial(
action="append",
metavar="options",
help="Extra global options to be supplied to the setup.py "
"call before the install command.",
"call before the install or bdist_wheel command.",
) # type: Callable[..., Option]
no_clean = partial(
......
......@@ -35,7 +35,10 @@ from pip._internal.utils.misc import (
write_output,
)
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.virtualenv import virtualenv_no_global
from pip._internal.utils.virtualenv import (
running_under_virtualenv,
virtualenv_no_global,
)
from pip._internal.wheel_builder import (
BinaryAllowedPredicate,
build,
......@@ -725,7 +728,7 @@ def create_os_error_message(error, show_traceback, using_user_site):
user_option_part = "Consider using the `--user` option"
permissions_part = "Check the permissions"
if not using_user_site:
if not running_under_virtualenv() and not using_user_site:
parts.extend([
user_option_part, " or ",
permissions_part.lower(),
......
......@@ -54,13 +54,6 @@ class WheelCommand(RequirementCommand):
self.cmd_opts.add_option(cmdoptions.no_binary())
self.cmd_opts.add_option(cmdoptions.only_binary())
self.cmd_opts.add_option(cmdoptions.prefer_binary())
self.cmd_opts.add_option(
'--build-option',
dest='build_options',
metavar='options',
action='append',
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
)
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
self.cmd_opts.add_option(cmdoptions.use_pep517())
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
......@@ -81,13 +74,8 @@ class WheelCommand(RequirementCommand):
help="Don't verify if built wheel is valid.",
)
self.cmd_opts.add_option(
'--global-option',
dest='global_options',
action='append',
metavar='options',
help="Extra global options to be supplied to the setup.py "
"call before the 'bdist_wheel' command.")
self.cmd_opts.add_option(cmdoptions.build_options())
self.cmd_opts.add_option(cmdoptions.global_options())
self.cmd_opts.add_option(
'--pre',
......
......@@ -42,3 +42,8 @@ def test_version_warning_is_not_shown_if_python_version_is_not_2(script):
def test_flag_does_nothing_if_python_version_is_not_2(script):
script.pip("list", "--no-python-version-warning")
def test_pip_works_with_warnings_as_errors(script):
script.environ['PYTHONWARNINGS'] = 'error'
script.pip("--version")
import compileall
import shutil
import subprocess
import sys
import textwrap
import venv as _venv
......@@ -55,11 +56,16 @@ class VirtualEnvironment:
else:
# Create a new virtual environment.
if self._venv_type == "virtualenv":
_virtualenv.create_environment(
self.location,
no_pip=True,
no_wheel=True,
no_setuptools=True,
subprocess.check_call(
[
sys.executable,
"-m",
"virtualenv",
"--no-pip",
"--no-wheel",
"--no-setuptools",
str(self.location),
]
)
self._fix_virtualenv_site_module()
elif self._venv_type == "venv":
......
......@@ -4,6 +4,7 @@ from unittest.mock import patch
import pytest
from pip._vendor.packaging.requirements import Requirement
from pip._internal.commands import install
from pip._internal.commands.install import (
create_os_error_message,
decide_user_install,
......@@ -109,7 +110,8 @@ def test_rejection_for_location_requirement_options():
' permissions.\n'),
])
def test_create_os_error_message(
error, show_traceback, using_user_site, expected
monkeypatch, error, show_traceback, using_user_site, expected
):
monkeypatch.setattr(install, "running_under_virtualenv", lambda: False)
msg = create_os_error_message(error, show_traceback, using_user_site)
assert msg == expected
......@@ -201,6 +201,10 @@ class TestYankedWarning:
"""
Test unyanked candidate preferred over yanked.
"""
# Ignore spurious DEBUG level messages
# TODO: Probably better to work out why they are occurring, but IMO the
# tests are at fault here for being to dependent on exact output.
caplog.set_level(logging.WARNING)
candidates = [
make_mock_candidate('1.0'),
make_mock_candidate('2.0', yanked_reason='bad metadata #2'),
......@@ -217,6 +221,10 @@ class TestYankedWarning:
"""
Test all candidates yanked.
"""
# Ignore spurious DEBUG level messages
# TODO: Probably better to work out why they are occurring, but IMO the
# tests are at fault here for being to dependent on exact output.
caplog.set_level(logging.WARNING)
candidates = [
make_mock_candidate('1.0', yanked_reason='bad metadata #1'),
# Put the best candidate in the middle, to test sorting.
......@@ -253,6 +261,10 @@ class TestYankedWarning:
"""
Test the log message with various reason strings.
"""
# Ignore spurious DEBUG level messages
# TODO: Probably better to work out why they are occurring, but IMO the
# tests are at fault here for being to dependent on exact output.
caplog.set_level(logging.WARNING)
candidates = [
make_mock_candidate('1.0', yanked_reason=yanked_reason),
]
......
sphinx == 3.2.1
# FIXME: Remove towncrier constraint after upgrading sphinxcontrib-towncrier.
towncrier < 19.9.0
furo
myst_parser
sphinx-copybutton
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册