Skip to content

InvalidRequirement produced for git URL in extra #357

@hauntsaninja

Description

@hauntsaninja

Originally filed at pypa/packaging#494

mkdir reqparse
cd reqparse

cat > setup.py <<HERE
from setuptools import setup

setup(
    name="reqparse",
    extras_require={
        "test": [
            "gym-retro @ git+https://github.com/openai/[email protected]",
        ]
    },
)
HERE

python3 -m venv env
source env/bin/activate
python3 -m pip install packaging -e .

cat reqparse.egg-info/requires.txt

# this now gives me
# packaging.requirements.InvalidRequirement: Parse error at "'extra =='": Expected string_end
python3 -c '
import importlib.metadata
from packaging.requirements import Requirement
Requirement(importlib.metadata.distribution("reqparse").requires[0])
'

This results in the equivalent of:

from packaging.requirements import Requirement
Requirement('gym-retro@ git+https://github.com/openai/[email protected]; extra == "test"')

uranusjr suggested adding a space before the semicolon here: https://github.com/python/cpython/blob/908fd691f96403a3c30d85c17dd74ed1f26a60fd/Lib/importlib/metadata/__init__.py#L678

Happy to make a PR for that — if so, should I also make a PR to CPython, or is there a separate process for porting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions