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

FIX: Pip 20 support for importing PipSession #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pkgversion/pkgversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
from subprocess import PIPE, Popen

try:
from pip._internal.download import PipSession
from pip._internal.network.session import PipSession
from pip._internal.req import parse_requirements
except ImportError:
# Output expected ImportErrors for PIP < 10.
from pip.download import PipSession
from pip.req import parse_requirements
# Output expected ImportErrors for PIP < 20.
try:
from pip._internal.download import PipSession
from pip._internal.req import parse_requirements
except ImportError:
# Output expected ImportErrors for PIP < 10.
from pip.download import PipSession
from pip.req import parse_requirements


setup_py_template = """
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pkgversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_write_setup_py_with_git_repo(self, tmpdir):
Popen(command, stdout=PIPE, cwd=str(tmpdir)).communicate()

expected_import = "^from setuptools import setup$"
expected_setup = "^setup\(\*\*(.*)\)$"
expected_setup = "^setup\(\*\*(.*)\)$" # noqa: W605

write_setup_py(
install_requires=['test']
Expand Down
32 changes: 5 additions & 27 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ addopts=--tb=short

[tox]
envlist =
py27-{pip9,pip10}
py35-{pip9,pip10}
py36-{pip9,pip10}
py{27,35,36}-pip{9,10,20}
cov
isort-check
isort-fix
Expand All @@ -14,15 +12,6 @@ envlist =

skipsdist = true

basepython =
py27-{pip9,pip10}: python2.7
py35-{pip9,pip10}: python3.5
py36-{pip9,pip10}: python3.6
cov: python3.6
deps =
-rrequirements/requirements-base.txt
-rrequirements/requirements-testing.txt

[testenv:cov]
basepython= python3.6
commands =
Expand All @@ -31,27 +20,16 @@ deps =
-rrequirements/requirements-base.txt
-rrequirements/requirements-testing.txt

[general]
[testenv]
commands =
py.test tests
deps =
pip9: pip>=9,<10
pip10: pip>=10,<20
pip20: pip>=20
-rrequirements/requirements-base.txt
-rrequirements/requirements-testing.txt

[testenv:py27-{pip9,pip10}]
basepython = python2.7
commands =
{[general]commands}

[testenv:py35-{pip9,pip10}]
basepython = python3.5
commands =
{[general]commands}

[testenv:py36-{pip9,pip10}]
basepython = python3.6
commands =
{[general]commands}

##
# Flake8 linting
Expand Down