madpah / requirements-parser

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

Handle branches, tags and commits in VCS URIs #8

Closed davidfischer closed 11 years ago

davidfischer commented 11 years ago

Currently VCS URIs with branches, tags or commits generate a ValueError:

>>> list(requirements.parse('git://git.myproj.org/proj.git@v1.0#egg=proj'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "requirements/parser.py", line 84, in parse
    raise ValueError('Invalid requirement line "%s"' %line)
ValueError: Invalid requirement line "git://git.myproj.org/proj.git@v1.0#egg=proj"

However, these are valid according to the requirement file spec

teferi commented 11 years ago

Seems like this occurs only if you do not mention vcs in uri and the requirement is not editable, since

git+git://git.myproj.org/proj.git@v1.0#egg=proj -e git://git.myproj.org/proj.git@v1.0#egg=proj

both get parsed correctly.

Also it would be great if parse would be able to return commit(branch/tag) spec as a separate field. Maybe it is worth checking pip source? There should be a correct parser there, although this would introduce a rather heavy dependency.

davidfischer commented 11 years ago

Perhaps this should be two issues. Firstly, it looks like pip now supports regular git:// URIs (without git+ssh, etc.). The second part is that requirements should be able to parse out the branch/tag in a separate field.

As for looking at the pip source for the parser, the parser is not easily separable from the parts that actually do the install. That was part of my motivation for this project in the first place.

davidfischer commented 11 years ago

Thanks for helping me think of this more clearly @teferi. I created #10 as a result and this issue will be about parsing out the branch/tag/commit/reference data.

davidfischer commented 11 years ago

This works now.

>>> list(parse('-e git://git.myproject.org/MyProject.git@v1.0#egg=MyProject'))[0].revision
'v1.0'

I need to write out the full docs though on this and then release it.