Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pip>=20.3 support #1216

Merged
merged 8 commits into from Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions .appveyor.yml
Expand Up @@ -3,28 +3,28 @@ environment:
PYTHON: "C:\\Python36"

matrix:
- TOXENV: py27-pip20.1-coverage
PIP: 20.1
- TOXENV: py27-pipprevious-coverage
PIP: previous
- TOXENV: py27-piplatest-coverage
PIP: latest

- TOXENV: py35-pip20.1
PIP: 20.1
- TOXENV: py35-pipprevious
PIP: previous
- TOXENV: py35-piplatest
PIP: latest

- TOXENV: py36-pip20.1
PIP: 20.1
- TOXENV: py36-pipprevious
PIP: previous
- TOXENV: py36-piplatest
PIP: latest

- TOXENV: py37-pip20.1
PIP: 20.1
- TOXENV: py37-pipprevious
PIP: previous
- TOXENV: py37-piplatest
PIP: latest

- TOXENV: py38-pip20.1-coverage
PIP: 20.1
- TOXENV: py38-pipprevious-coverage
PIP: previous
- TOXENV: py38-piplatest-coverage
PIP: latest

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -28,7 +28,7 @@ jobs:
- 3.7
pip-version:
- "latest"
- "20.1"
- "previous"
include:
- os: Ubuntu
python-version: 3.9-dev
Expand All @@ -47,7 +47,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} from deadsnakes
if: endsWith(matrix.python-version, '-dev')
uses: deadsnakes/action@v1.0.0
uses: deadsnakes/action@v2.0.1
with:
python-version: ${{ matrix.python-version }}
- name: Log python version info (${{ matrix.python-version }})
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,7 @@ python:
env:
# NOTE: keep this in sync with envlist in tox.ini for tox-travis.
- PIP=latest
- PIP=20.1
- PIP=previous

cache: false
install:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -464,5 +464,5 @@ versions.
+---------------+-----------------+
| 5.0.0 - 5.3.0 | 20.0 - 20.1.1 |
+---------------+-----------------+
| >= 5.4.0 | 20.1 - 20.2.* |
| >= 5.4.0 | 20.1 - 20.3.* |
+---------------+-----------------+
28 changes: 21 additions & 7 deletions piptools/repositories/pypi.py
Expand Up @@ -58,7 +58,12 @@ 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")
self.options, _ = self.command.parse_args(pip_args)
extra_pip_args = (
[]
if PIP_VERSION[:2] <= (20, 2)
else ["--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 All @@ -85,7 +90,8 @@ def __init__(self, pip_args, cache_dir):
self.freshen_build_caches()
self._cache_dir = normalize_path(cache_dir)
self._download_dir = fs_str(os.path.join(self._cache_dir, "pkgs"))
self._wheel_download_dir = fs_str(os.path.join(self._cache_dir, "wheels"))
if PIP_VERSION[:2] <= (20, 2):
self._wheel_download_dir = fs_str(os.path.join(self._cache_dir, "wheels"))

self._setup_logging()

Expand All @@ -107,7 +113,8 @@ def source_dir(self):

def clear_caches(self):
rmtree(self._download_dir, ignore_errors=True)
rmtree(self._wheel_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 @@ -153,16 +160,18 @@ def resolve_reqs(self, download_dir, ireq, wheel_cache):
with get_requirement_tracker() as req_tracker, TempDirectory(
kind="resolver"
) as temp_dir, indent_log():
preparer = self.command.make_requirement_preparer(
preparer_kwargs = dict(
temp_build_dir=temp_dir,
options=self.options,
req_tracker=req_tracker,
session=self.session,
finder=self.finder,
use_user_site=False,
download_dir=download_dir,
wheel_download_dir=self._wheel_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):
Expand All @@ -186,7 +195,10 @@ 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:
resolver._get_abstract_dist_for(ireq)
if PIP_VERSION[:2] <= (20, 2):
resolver._get_abstract_dist_for(ireq)
else:
resolver._get_dist_for(ireq)

return set(results)

Expand Down Expand Up @@ -219,7 +231,9 @@ def get_dependencies(self, ireq):
download_dir = self._get_download_path(ireq)
if not os.path.isdir(download_dir):
os.makedirs(download_dir)
if not os.path.isdir(self._wheel_download_dir):
if PIP_VERSION[:2] <= (20, 2) and not os.path.isdir(
self._wheel_download_dir
):
os.makedirs(self._wheel_download_dir)

with global_tempdir_manager():
Expand Down
11 changes: 10 additions & 1 deletion tox.ini
@@ -1,7 +1,7 @@
[tox]
envlist =
# NOTE: keep this in sync with the env list in .travis.yml for tox-travis.
py{27,35,36,37,38,39,py,py3}-pip{20.1,20.2,latest,master}-coverage
py{27,35,36,37,38,39,py,py3}-pip{20.1,20.2,20.3,previous,latest,master}-coverage
checkqa
readme
skip_missing_interpreters = True
Expand All @@ -11,14 +11,21 @@ extras =
testing
coverage: coverage
deps =
pipprevious: pip==20.2.*
# TODO: change to `pip` after pip-20.3 being released
piplatest: -e git+https://github.com/pypa/pip.git@master#egg=pip
pipmaster: -e git+https://github.com/pypa/pip.git@master#egg=pip
pip20.1: pip==20.1.*
pip20.2: pip==20.2.*
# TODO: change to `pip==20.3.*` after pip-20.3 being released
pip20.3: -e git+https://github.com/pypa/pip.git@master#egg=pip
setenv =
pipprevious: PIP=previous
piplatest: PIP=latest
pipmaster: PIP=master
pip20.1: PIP==20.1
pip20.2: PIP==20.2
pip20.3: PIP==20.3

coverage: PYTEST_ADDOPTS=--strict --doctest-modules --cov --cov-report=term-missing --cov-report=xml {env:PYTEST_ADDOPTS:}
commands_pre =
Expand All @@ -44,5 +51,7 @@ commands = twine check {distdir}/*
PIP =
20.1: pip20.1
20.2: pip20.2
20.3: pip20.3
previous: pipprevious
latest: piplatest
master: pipmaster