madpah / requirements-parser

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

Fails at parsing comments #3

Closed treyhunner closed 11 years ago

treyhunner commented 11 years ago

requirements.txt:

reqfile-parser==0.1.0  # Here's a comment

That file fails at parsing because of the #.

davidfischer commented 11 years ago

According to the requirement file spec, only "line[s] beginning with # is treated as a comment and ignored". The hash character cannot simply be used as a comment as that would break things like git+http://repo/my_project.git#egg=SomeProject.

Now I'm not opposed to some level of compatibility if this is breaking a well used requirement file for a major package but it should probably throw a warning or something.

treyhunner commented 11 years ago

All I know right now is that I use # at the ends of my lines in my requirements file and it works. I plan to remove line comments now that I know they're wrong.

If you don't think this is very common maybe the issue should be closed until someone reopens it in the future.

davidfischer commented 11 years ago

Actually using pkg_resources (see #4) should resolve this as well.

>>> pkg_resources.Requirement.parse('reqfile-parser==0.1.0  # Heres a comment')
Requirement.parse('reqfile-parser==0.1.0')