[PATCH] D78620: [LNT] Update to match API change in PIP

Oliver Stannard (Linaro) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 02:40:26 PDT 2020


ostannard created this revision.
ostannard added reviewers: fhahn, cmatthews, DavidSpickett.

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 <https://reviews.llvm.org/D45211> the requirements.*.txt files are needed for some cloud setups, and this avoids duplicating the dependency list between these files and setup.py.


https://reviews.llvm.org/D78620

Files:
  setup.py


Index: setup.py
===================================================================
--- setup.py
+++ setup.py
@@ -40,7 +40,15 @@
     # In old PIP the session flag cannot be passed.
     install_reqs = parse_requirements(req_file)
 
-reqs = [str(ir.req) for ir in install_reqs]
+try:
+    # Filter out git dependencies, which can't be handled by setuptools.
+    reqs = [ir.requirement for ir in install_reqs
+            if not ir.requirement.startswith("git+")]
+except AttributeError:
+    # Old versions of pip (<20.1) returned a List[InstallRequirement] instead
+    # of a List[ParsedRequirement], which has different member names, and does
+    # not include git dependencies.
+    reqs = [str(ir.req) for ir in install_reqs]
 
 setup(
     name="LNT",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78620.259212.patch
Type: text/x-patch
Size: 760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/35faa291/attachment.bin>


More information about the llvm-commits mailing list