madpah / requirements-parser

A Pip requirements file parser.
https://requirements-parser.readthedocs.io
Apache License 2.0
128 stars 42 forks source link

Line continuations are not parsed correctly #52

Open hexagonrecursion opened 4 years ago

hexagonrecursion commented 4 years ago

Given a file line-bug.txt with the following contents

requests==2.25.0 \
# comment
import requirements
list(requirements.parse(Path('line-bug.txt').read_text(encoding='utf8')))

throws an exception

...
~/.local/share/virtualenvs/pip-OwC7W1fl/lib/python3.8/site-packages/pkg_resources/__init__.py in parse(s)
   3133     @staticmethod
   3134     def parse(s):
-> 3135         req, = parse_requirements(s)
   3136         return req
   3137 

ValueError: not enough values to unpack (expected 1, got 0)

But pip works fine:

pip install --target "`mktemp -d`" -r line-bug.txt