Merge branch 'master' into tox-docs-update

This commit is contained in:
Pradyun Gedam 2019-07-31 12:27:12 +05:30 committed by GitHub
commit 69706e8b2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 49 additions and 57 deletions

View File

@ -1,15 +1,14 @@
environment:
matrix:
# Unit and integration tests.
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python27-x64"
RUN_INTEGRATION_TESTS: "True"
- PYTHON: "C:\\Python35-x64"
RUN_INTEGRATION_TESTS: "True"
- PYTHON: "C:\\Python36-x64"
RUN_INTEGRATION_TESTS: "True"
# Unit tests only.
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36"
# Nothing for the moment
matrix:
fast_finish: true
@ -65,9 +64,6 @@ test_script:
subst T: $env:TEMP
$env:TEMP = "T:\"
$env:TMP = "T:\"
# Workaround warnings traced in packaging.requirements with pyparsing 2.4.1.
# See pypa/packaging#170 and tox-dev/tox#1375.
$env:PYTHONWARNINGS = "ignore:warn_ungrouped_named_tokens_in_collection"
tox -e py -- -m unit
if ($LastExitCode -eq 0 -and $env:RUN_INTEGRATION_TESTS -eq "True") {
tox -e py -- --use-venv -m integration -n2 --durations=20

View File

@ -9,11 +9,11 @@ jobs:
vmImage: ${{ parameters.vmImage }}
strategy:
matrix:
Python27-x64:
Python27-x86:
python.version: '2.7'
python.architecture: x64
Python36-x64:
python.version: '3.6'
python.architecture: x86
Python37-x64:
python.version: '3.7'
python.architecture: x64
maxParallel: 2
@ -32,16 +32,7 @@ jobs:
vmImage: ${{ parameters.vmImage }}
strategy:
matrix:
Python35-x64:
python.version: '3.5'
python.architecture: x64
Python37-x64:
python.version: '3.7'
python.architecture: x64
# This is for Windows, so test x86 builds
Python27-x86:
python.version: '2.7'
python.architecture: x86
Python35-x86:
python.version: '3.5'
python.architecture: x86

1
news/6794.doc Normal file
View File

@ -0,0 +1 @@
Document that ``--ignore-installed`` is dangerous.

View File

@ -184,7 +184,11 @@ class InstallCommand(RequirementCommand):
'-I', '--ignore-installed',
dest='ignore_installed',
action='store_true',
help='Ignore the installed packages (reinstalling instead).')
help='Ignore the installed packages, overwriting them. '
'This can break your system if the existing package '
'is of a different version or was installed '
'with a different package manager!'
)
cmd_opts.add_option(cmdoptions.ignore_requires_python())
cmd_opts.add_option(cmdoptions.no_build_isolation())

View File

@ -16,7 +16,7 @@ from pip._internal.utils.typing import MYPY_CHECK_RUNNING
if MYPY_CHECK_RUNNING:
from typing import (
Tuple, Callable, List, Optional, Union, Dict
Tuple, Callable, List, Optional, Union, Dict, Set
)
Pep425Tag = Tuple[str, str, str]
@ -105,6 +105,8 @@ def get_abi_tag():
(CPython 2, PyPy)."""
soabi = get_config_var('SOABI')
impl = get_abbr_impl()
abi = None # type: Optional[str]
if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
d = ''
m = ''
@ -129,8 +131,7 @@ def get_abi_tag():
abi = 'cp' + soabi.split('-')[1]
elif soabi:
abi = soabi.replace('.', '_').replace('-', '_')
else:
abi = None
return abi
@ -310,7 +311,7 @@ def get_supported(
if abi:
abis[0:0] = [abi]
abi3s = set()
abi3s = set() # type: Set[str]
for suffix in get_extension_suffixes():
if suffix.startswith('.abi'):
abi3s.add(suffix.split('.', 2)[1])

View File

@ -218,6 +218,8 @@ def _get_win_folder_from_registry(csidl_name):
def _get_win_folder_with_ctypes(csidl_name):
# type: (str) -> str
# On Python 2, ctypes.create_unicode_buffer().value returns "unicode",
# which isn't the same as str in the annotation above.
csidl_const = {
"CSIDL_APPDATA": 26,
"CSIDL_COMMON_APPDATA": 35,
@ -239,7 +241,8 @@ def _get_win_folder_with_ctypes(csidl_name):
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
buf = buf2
return buf.value
# The type: ignore is explained under the type annotation for this function
return buf.value # type: ignore
if WINDOWS:

View File

@ -53,21 +53,18 @@ else:
if MYPY_CHECK_RUNNING:
from typing import (
Any, AnyStr, Container, Iterable, List, Mapping, Match, Optional, Text,
Union,
Tuple, Union, cast,
)
from pip._vendor.pkg_resources import Distribution
from pip._internal.models.link import Link
from pip._internal.utils.ui import SpinnerInterface
try:
from typing import cast, Tuple
VersionInfo = Tuple[int, int, int]
except ImportError:
# typing's cast() isn't supported in code comments, so we need to
# define a dummy, no-op version.
def cast(typ, val):
return val
VersionInfo = None
else:
# typing's cast() is needed at runtime, but we don't want to import typing.
# Thus, we use a dummy no-op version, which we tell mypy to ignore.
def cast(type_, value): # type: ignore
return value
__all__ = ['rmtree', 'display_path', 'backup_dir',
@ -140,7 +137,7 @@ def normalize_version_info(py_version_info):
elif len(py_version_info) > 3:
py_version_info = py_version_info[:3]
return cast(VersionInfo, py_version_info)
return cast('VersionInfo', py_version_info)
def ensure_dir(path):

View File

@ -1,6 +1,5 @@
import invoke
from . import generate
from . import vendoring
from tools.automation import generate, vendoring
ns = invoke.Collection(generate, vendoring)

View File

@ -513,11 +513,10 @@ def test_list_path(tmpdir, script, data):
Test list with --path.
"""
result = script.pip('list', '--path', tmpdir, '--format=json')
assert {'name': 'simple',
'version': '2.0'} not in json.loads(result.stdout)
json_result = json.loads(result.stdout)
assert {'name': 'simple', 'version': '2.0'} not in json_result
script.pip('install', '--find-links', data.find_links,
'--target', tmpdir, 'simple==2.0')
script.pip_install_local('--target', tmpdir, 'simple==2.0')
result = script.pip('list', '--path', tmpdir, '--format=json')
json_result = json.loads(result.stdout)
assert {'name': 'simple', 'version': '2.0'} in json_result
@ -528,10 +527,9 @@ def test_list_path_exclude_user(tmpdir, script, data):
Test list with --path and make sure packages from --user are not picked
up.
"""
script.pip_install_local('--find-links', data.find_links,
'--user', 'simple2')
script.pip('install', '--find-links', data.find_links,
'--target', tmpdir, 'simple==1.0')
script.pip_install_local('--user', 'simple2')
script.pip_install_local('--target', tmpdir, 'simple==1.0')
result = script.pip('list', '--user', '--format=json')
json_result = json.loads(result.stdout)
assert {'name': 'simple2', 'version': '3.0'} in json_result
@ -549,10 +547,10 @@ def test_list_path_multiple(tmpdir, script, data):
os.mkdir(path1)
path2 = tmpdir / "path2"
os.mkdir(path2)
script.pip('install', '--find-links', data.find_links,
'--target', path1, 'simple==2.0')
script.pip('install', '--find-links', data.find_links,
'--target', path2, 'simple2==3.0')
script.pip_install_local('--target', path1, 'simple==2.0')
script.pip_install_local('--target', path2, 'simple2==3.0')
result = script.pip('list', '--path', path1, '--format=json')
json_result = json.loads(result.stdout)
assert {'name': 'simple', 'version': '2.0'} in json_result

View File

@ -1,3 +1,4 @@
import pytest
from pip._vendor import pytoml
from pip._internal.build_env import BuildEnvironment
@ -198,6 +199,7 @@ def test_explicit_setuptools_backend(script, tmpdir, data, common_wheels):
result.assert_installed(name, editable=False)
@pytest.mark.network
def test_pep517_and_build_options(script, tmpdir, data, common_wheels):
"""Backend generated requirements are installed in the build env"""
project_dir, name = make_pyproject_with_setup(tmpdir)

View File

@ -1 +0,0 @@
mypy == 0.670

View File

@ -0,0 +1 @@
mypy == 0.720

10
tox.ini
View File

@ -15,10 +15,10 @@ setenv =
# This is required in order to get UTF-8 output inside of the subprocesses
# that our tests use.
LC_CTYPE = en_US.UTF-8
deps = -r{toxinidir}/tools/tests-requirements.txt
deps = -r{toxinidir}/tools/requirements/tests.txt
commands_pre =
python -c 'import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)' {toxinidir}/tests/data/common_wheels
{[helpers]pip} wheel -w {toxinidir}/tests/data/common_wheels -r {toxinidir}/tools/tests-common_wheels-requirements.txt
{[helpers]pip} wheel -w {toxinidir}/tests/data/common_wheels -r {toxinidir}/tools/requirements/tests-common_wheels.txt
commands = pytest --timeout 300 []
install_command = {[helpers]pip} install {opts} {packages}
list_dependencies_command = {[helpers]pip} freeze --all
@ -29,7 +29,7 @@ commands = pytest --timeout 300 --cov=pip --cov-report=term-missing --cov-report
[testenv:docs]
# Don't skip install here since pip_sphinxext uses pip's internals.
deps = -r{toxinidir}/tools/docs-requirements.txt
deps = -r{toxinidir}/tools/requirements/docs.txt
basepython = python3.7
commands =
sphinx-build -W -d {envtmpdir}/doctrees/html -b html docs/html docs/build/html
@ -50,7 +50,7 @@ commands =
python setup.py check -m -r -s
[lint]
deps = -r{toxinidir}/tools/lint-requirements.txt
deps = -r{toxinidir}/tools/requirements/lint.txt
[testenv:lint-py2]
skip_install = True
@ -74,7 +74,7 @@ commands =
[testenv:mypy]
skip_install = True
basepython = python3
deps = -r{toxinidir}/tools/mypy-requirements.txt
deps = -r{toxinidir}/tools/requirements/mypy.txt
commands_pre =
commands =
mypy src