1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
From a3872e15312d8382017fbd6888744f4025cae5ac Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Tue, 27 Oct 2020 22:18:42 +0100
Subject: [PATCH] support changed pip parser api
---
dephell/converters/pip.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dephell/converters/pip.py b/dephell/converters/pip.py
index 6d6181db..89c36e95 100644
--- a/dephell/converters/pip.py
+++ b/dephell/converters/pip.py
@@ -9,6 +9,7 @@
from dephell_discover import Root as PackageRoot
from dephell_links import DirLink, FileLink
from pip._internal.req import parse_requirements
+from pip._internal.req.req_install import InstallRequirement
# app
from ..context_tools import chdir
@@ -38,6 +39,14 @@
# external
from pip._internal.network.session import PipSession
+try:
+ # pip >= 20.2
+ from pip._internal.req.req_file import ParsedRequirement
+ from pip._internal.req.constructors import \
+ install_req_from_parsed_requirement
+except ImportError:
+ ParsedRequirement = None
+
@attr.s()
class PIPConverter(BaseConverter):
@@ -98,8 +107,15 @@ def load(self, path) -> RootDependency:
)
deps = []
- for req in reqs:
+ for ireq in reqs:
# https://github.com/pypa/pip/blob/master/src/pip/_internal/req/req_install.py
+ if isinstance(ireq, InstallRequirement):
+ req = ireq
+ elif isinstance(ireq, ParsedRequirement):
+ req = install_req_from_parsed_requirement(ireq)
+ else:
+ raise Exception("Another internal API change, why do you "
+ "keep using internal APIs?")
if req.req is None:
req.req = SimpleNamespace(
name=req.link.url.split('/')[-1],
|