Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when there's no space before semicolon (PEP 508 URL requirement) #494

Closed
hauntsaninja opened this issue Dec 15, 2021 · 6 comments

Comments

@hauntsaninja
Copy link
Contributor

I'm not fully sure whether this is packaging's fault (or importlib.metadata or pip or setuptools), but here's what I'm seeing:

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/retro.git@v0.8.0",
        ]
    },
)
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])
'

Or more concisely, but with less justification:

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

Thank you!

@uranusjr
Copy link
Member

It’s likely importlib.metadata’s fault. It automatically converts egg-info-style requirements (which is used by legacy editables) to PEP 508-style, and the conversion went wrong.

cc @jaraco the easiest fix would be to add a space before the semicolon here

https://github.com/python/cpython/blob/908fd691f96403a3c30d85c17dd74ed1f26a60fd/Lib/importlib/metadata/__init__.py#L678

@brettcannon
Copy link
Member

I can't transfer across orgs, but the repo is https://github.com/python/importlib_metadata .

@hauntsaninja
Copy link
Contributor Author

Thanks both! :-) Created a new issue in importlib_metadata

@jaraco
Copy link
Member

jaraco commented Dec 15, 2021

@pradyunsg
Copy link
Member

I'm gonna reopen this, to track adding a better error message for this; especially once #484 is merged.

@pradyunsg pradyunsg reopened this Dec 16, 2021
@pradyunsg pradyunsg changed the title InvalidRequirement for git URL in extra Improve error message when there's no space before semicolon (PEP 508 URL requirement) Dec 16, 2021
@pradyunsg
Copy link
Member

Closing this, since there's a more targetted issue for this in #529 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants