madpah/requirements-parser

Cannot create requirement from this particular pip freeze output

Opened this issue · 0 comments

If you install a package in a subdirectory from git, e.g.

git+ssh://git@github.com/my/repo.git@project25#egg=PACKAGE_NAME&subdirectory=SUB_DIR/

and then do a pip freeze you'll instead get:

PACKAGE_NAME @ git+ssh://git@github.com/my/repo.git@3684f02bf928cae39d10d1d9b478d95d2267b2af#subdirectory=SUB_DIR/

In which case this cannot be parsed (redacted with parts I can't share):

 File "/stitchfix/z-pyenv/pyenv/versions/3.6/lib/python3.6/site-packages/requirements/parser.py", line 50, in parse    yield Requirement.parse(line)
 File "/stitchfix/z-pyenv/pyenv/versions/3.6/lib/python3.6/site-packages/requirements/requirement.py", line 220, in parse    return cls.parse_line(line)
 File "/stitchfix/z-pyenv/pyenv/versions/3.6/lib/python3.6/site-packages/requirements/requirement.py", line 198, in parse_line    pkg_req = Req.parse(line)
 File "/stitchfix/z-pyenv/pyenv/versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3155, in parse    req, = parse_requirements(s)

Traceback (most recent call last):
 File "/stitchfix/z-pyenv/pyenv/versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3108, in __init__    super(Requirement, self).__init__(requirement_string)
 File "/stitchfix/z-pyenv/pyenv/versions/3.6/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 101, in __init__    raise InvalidRequirement("Invalid URL given")
  pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid URL given