Skip to content

InvalidRequirement: name@ git+...@branch; (python_version=="...") and extra == "..." #432

@hroncok

Description

@hroncok

Hello. I found a requirement that packaging deems invalid but I am not sure why.

This is happening on 20.4, 20.9 and main branch @ 7350746.

I see what I believe is a proper requirement generated by https://github.com/sqlobject/sqlobject/blob/3.9.1/setup.py#L118-L121 as:

[oursql:python_version=="2.7"]
oursql@ git+https://github.com/sqlobject/oursql.git@master

[oursql:python_version>="3.4"]
oursql3@ git+https://github.com/sqlobject/oursql.git@py3k

Parsed by importlib.metadata.PathDistribution.requires as:

oursql@ git+https://github.com/sqlobject/oursql.git@master; (python_version=="2.7") and extra == "oursql"
oursql3@ git+https://github.com/sqlobject/oursql.git@py3k; (python_version>="3.4") and extra == "oursql"

Failing with:

>>> from packaging.requirements import Requirement
>>> Requirement('oursql@ git+https://github.com/sqlobject/oursql.git@master; (python_version=="2.7") and extra == "oursql"')
Traceback (most recent call last):
  File "/home/churchyard/Dokumenty/pypa/packaging/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/usr/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File "/usr/lib/python3.9/site-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected stringEnd, found '('  (at char 60), (line:1, col:61)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/churchyard/Dokumenty/pypa/packaging/packaging/requirements.py", line 104, in __init__
    raise InvalidRequirement(
packaging.requirements.InvalidRequirement: Parse error at "'(python_'": Expected stringEnd

What's wrong with this requirement?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions