madpah / madpah/requirements-parser

Cannot parse "psycopg2>=2.7.4 --no-binary psycopg2"

Open
#42 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
141
Forks
42
PR merge metrics
No merged PRs in 30d

Description

It is recommended to use --no-binary in psycopg2 docs:
http://initd.org/psycopg/docs/install.html

However, requirements.parse() fails on line "psycopg2>=2.7.4 --no-binary psycopg2".
Please advise if this is a bug in requirements or if this shouldn't be supported.
If it's a bug, I would be glad to create a PR for this one.

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 90, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1654, in parseString
    raise exc
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1644, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 3417, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1406, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 3205, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pkg_resources._vendor.pyparsing.ParseException: Expected stringEnd (at char 16), (line:1, col:17)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2963, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 94, in __init__
    requirement_string[e.loc:e.loc + 8]))
pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'--no-bin'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".dev/bump-requirements.py", line 25, in <module>
    asyncio.run(generate_fresh_requirements(args.file))
  File ".dev/bump-requirements.py", line 20, in generate_fresh_requirements
    for req in requirements.parse(fd):
  File "/usr/local/lib/python3.7/site-packages/requirements/parser.py", line 50, in parse
    yield Requirement.parse(line)
  File "/usr/local/lib/python3.7/site-packages/requirements/requirement.py", line 220, in parse
    return cls.parse_line(line)
  File "/usr/local/lib/python3.7/site-packages/requirements/requirement.py", line 198, in parse_line
    pkg_req = Req.parse(line)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3009, in parse
    req, = parse_requirements(s)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2956, in parse_requirements
    yield Requirement(line)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2965, in __init__
    raise RequirementParseError(str(e))
pkg_resources.RequirementParseError: Invalid requirement, parse error at "'--no-bin'"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure through .dev/bump-requirements.py, then trace parsing through requirements/parser.py and requirements/requirement.py. Confirm whether pip-style --no-binary options are intended to be supported and define completion by the resulting parser behavior and a regression test for the reported requirement line.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.