Skip to content

Commit d9c28c7

Browse files
authored
Merge pull request #2 from createdbysk/develop
Workaround the changes to pip internals
2 parents 7ac8ba7 + d21d251 commit d9c28c7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

setup.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
except ImportError:
88
# It is quick hack to support pip 10 that has changed its internal
99
# structure of the modules.
10-
from pip._internal.download import PipSession
10+
# Further hack - seems like pip 20 and later does not support
11+
# pip._internal.download anymore. It appears as though
12+
# parse_requirements (used below) does not need a valid PipSession.
13+
# Any value seems to work. So hack this even more.
14+
try:
15+
from pip._internal.download import PipSession
16+
except ImportError:
17+
PipSession = object
1118
from pip._internal.req.req_file import parse_requirements
1219

1320

@@ -22,9 +29,12 @@ def get_requirements(source):
2229
"""
2330

2431
install_reqs = parse_requirements(filename=source, session=PipSession())
25-
26-
return [str(ir.req) for ir in install_reqs]
27-
32+
# pip 20 changed ParsedRequirement.req to ParsedRequirement.requirement.
33+
try:
34+
requirements = [str(ir.req) for ir in install_reqs]
35+
except AttributeError:
36+
requirements = [str(ir.requirement) for ir in install_reqs]
37+
return requirements
2838

2939
setup(
3040
packages=find_packages(),

0 commit comments

Comments
 (0)