Skip to content

Commit 5acafc5

Browse files
committed
[LNT] Update to match API change in PIP
The parse_requirements function in PIP now (as of version 20.1) returns a list of ParsedRequirements, where it was previously a list of InstallRequirements. Update our setup.py to work with either one. This is an internal function of pip, so we shouldn't really be depending on it, the recommended solution seems to be to hard-code the dependency list in setup.py. However, according to a comment on D45211 the requirements.*.txt files are needed for some cloud setups, and this avoids duplicating the dependency list between these files and setup.py. Differential Revision: https://reviews.llvm.org/D78620
1 parent 9c9f6f8 commit 5acafc5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040
# In old PIP the session flag cannot be passed.
4141
install_reqs = parse_requirements(req_file)
4242

43-
reqs = [str(ir.req) for ir in install_reqs]
43+
try:
44+
# Filter out git dependencies, which can't be handled by setuptools.
45+
reqs = [ir.requirement for ir in install_reqs
46+
if not ir.requirement.startswith("git+")]
47+
except AttributeError:
48+
# Old versions of pip (<20.1) returned a List[InstallRequirement] instead
49+
# of a List[ParsedRequirement], which has different member names, and does
50+
# not include git dependencies.
51+
reqs = [str(ir.req) for ir in install_reqs]
4452

4553
setup(
4654
name="LNT",

0 commit comments

Comments
 (0)