Skip to content

Commit

Permalink
Bump pip minimum version to >= 20.3 (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
atugushev authored Mar 8, 2021
1 parent 4f89da8 commit 74aa521
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 93 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -495,5 +495,5 @@ versions as the required ``pip`` versions.
+---------------+----------------+----------------+
| 5.5.0 | 20.1 - 20.3.* | 2.7, 3.5 - 3.9 |
+---------------+----------------+----------------+
| 6.0.0 | 20.1 - 20.3.* | 3.6 - 3.9 |
| 6.0.0 | 20.3+ | 3.6 - 3.9 |
+---------------+----------------+----------------+
26 changes: 4 additions & 22 deletions piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pip._internal.utils.urls import path_to_url, url_to_path
from pip._vendor.requests import RequestException

from .._compat import PIP_VERSION, contextlib
from .._compat import contextlib
from ..exceptions import NoCandidateFound
from ..logging import log
from ..utils import (
Expand Down Expand Up @@ -55,11 +55,7 @@ def __init__(self, pip_args, cache_dir):
# General options (find_links, index_url, extra_index_url, trusted_host,
# and pre) are deferred to pip.
self.command = create_command("install")
extra_pip_args = (
[]
if PIP_VERSION[:2] <= (20, 2)
else ["--use-deprecated", "legacy-resolver"]
)
extra_pip_args = ["--use-deprecated", "legacy-resolver"]
self.options, _ = self.command.parse_args(pip_args + extra_pip_args)
if self.options.cache_dir:
self.options.cache_dir = normalize_path(self.options.cache_dir)
Expand Down Expand Up @@ -88,8 +84,6 @@ def __init__(self, pip_args, cache_dir):
self._source_dir = None
self._cache_dir = normalize_path(str(cache_dir))
self._download_dir = os.path.join(self._cache_dir, "pkgs")
if PIP_VERSION[:2] <= (20, 2):
self._wheel_download_dir = os.path.join(self._cache_dir, "wheels")

self._setup_logging()

Expand Down Expand Up @@ -119,8 +113,6 @@ def source_dir(self):

def clear_caches(self):
rmtree(self._download_dir, ignore_errors=True)
if PIP_VERSION[:2] <= (20, 2):
rmtree(self._wheel_download_dir, ignore_errors=True)

def find_all_candidates(self, req_name):
if req_name not in self._available_candidates_cache:
Expand Down Expand Up @@ -174,15 +166,10 @@ def resolve_reqs(self, download_dir, ireq, wheel_cache):
use_user_site=False,
download_dir=download_dir,
)
if PIP_VERSION[:2] <= (20, 2):
preparer_kwargs["wheel_download_dir"] = self._wheel_download_dir
preparer = self.command.make_requirement_preparer(**preparer_kwargs)

reqset = RequirementSet()
if PIP_VERSION[:2] <= (20, 1):
ireq.is_direct = True
else:
ireq.user_supplied = True
ireq.user_supplied = True
reqset.add_requirement(ireq)

resolver = self.command.make_resolver(
Expand All @@ -200,10 +187,7 @@ def resolve_reqs(self, download_dir, ireq, wheel_cache):
if not ireq.prepared:
# If still not prepared, e.g. a constraint, do enough to assign
# the ireq a name:
if PIP_VERSION[:2] <= (20, 2):
resolver._get_abstract_dist_for(ireq)
else:
resolver._get_dist_for(ireq)
resolver._get_dist_for(ireq)

return set(results)

Expand Down Expand Up @@ -233,8 +217,6 @@ def get_dependencies(self, ireq):
else:
download_dir = self._get_download_path(ireq)
os.makedirs(download_dir, exist_ok=True)
if PIP_VERSION[:2] <= (20, 2):
os.makedirs(self._wheel_download_dir, exist_ok=True)

with global_tempdir_manager():
wheel_cache = WheelCache(self._cache_dir, self.options.format_control)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ packages = find:
zip_safe = false
install_requires =
click >= 7
pip >= 20.1
pip >= 20.3

[options.packages.find]
exclude = tests
Expand Down
73 changes: 8 additions & 65 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from piptools._compat import PIP_VERSION
from piptools.exceptions import NoCandidateFound
from piptools.resolver import RequirementSummary, combine_install_requirements

Expand Down Expand Up @@ -325,40 +324,12 @@ def test_compile_failure_shows_provenance(resolver, from_line):
("test_package", "test_package", True),
("test_package==1.2.3", "test_package==1.2.3", True),
("test_package>=1.2.3", "test_package>=1.2.3", True),
pytest.param(
"test_package==1.2",
"test_package==1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
pytest.param(
"test_package>=1.2",
"test_package>=1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
("test_package==1.2", "test_package==1.2.0", True),
("test_package>=1.2", "test_package>=1.2.0", True),
("test_package[foo,bar]==1.2", "test_package[bar,foo]==1.2", True),
("test_package[foo,bar]>=1.2", "test_package[bar,foo]>=1.2", True),
pytest.param(
"test_package[foo,bar]==1.2",
"test_package[bar,foo]==1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
pytest.param(
"test_package[foo,bar]>=1.2",
"test_package[bar,foo]>=1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
("test_package[foo,bar]==1.2", "test_package[bar,foo]==1.2.0", True),
("test_package[foo,bar]>=1.2", "test_package[bar,foo]>=1.2.0", True),
("test_package", "other_test_package", False),
("test_package==1.2.3", "other_test_package==1.2.3", False),
("test_package==1.2.3", "test_package==1.2.4", False),
Expand Down Expand Up @@ -387,40 +358,12 @@ def test_RequirementSummary_equality(from_line, left_hand, right_hand, expected)
("test_package", "test_package", True),
("test_package==1.2.3", "test_package==1.2.3", True),
("test_package>=1.2.3", "test_package>=1.2.3", True),
pytest.param(
"test_package==1.2",
"test_package==1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
pytest.param(
"test_package>=1.2",
"test_package>=1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
("test_package==1.2", "test_package==1.2.0", True),
("test_package>=1.2", "test_package>=1.2.0", True),
("test_package[foo,bar]==1.2", "test_package[bar,foo]==1.2", True),
("test_package[foo,bar]>=1.2", "test_package[bar,foo]>=1.2", True),
pytest.param(
"test_package[foo,bar]==1.2",
"test_package[bar,foo]==1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
pytest.param(
"test_package[foo,bar]>=1.2",
"test_package[bar,foo]>=1.2.0",
True,
marks=pytest.mark.skipif(
PIP_VERSION[:2] < (20, 2), reason="Required only for pip>=20.2"
),
),
("test_package[foo,bar]==1.2", "test_package[bar,foo]==1.2.0", True),
("test_package[foo,bar]>=1.2", "test_package[bar,foo]>=1.2.0", True),
("test_package", "other_test_package", False),
("test_package==1.2.3", "other_test_package==1.2.3", False),
("test_package==1.2.3", "test_package==1.2.4", False),
Expand Down
6 changes: 2 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
# NOTE: keep this in sync with the env list in .github/workflows/ci.yml.
py{36,37,38,39,py3}-pip{20.1,20.2,20.3,previous,latest,master}-coverage
py{36,37,38,39,py3}-pip{20.3,previous,latest,master}-coverage
checkqa
readme
skip_missing_interpreters = True
Expand All @@ -11,11 +11,9 @@ extras =
testing
coverage: coverage
deps =
pipprevious: pip==20.2.*
pipprevious: pip==20.3.*
piplatest: pip
pipmaster: -e git+https://github.com/pypa/pip.git@master#egg=pip
pip20.1: pip==20.1.*
pip20.2: pip==20.2.*
pip20.3: pip==20.3.*
setenv =
coverage: PYTEST_ADDOPTS=--strict --doctest-modules --cov --cov-report=term-missing --cov-report=xml {env:PYTEST_ADDOPTS:}
Expand Down

0 comments on commit 74aa521

Please sign in to comment.