madpah/requirements-parser

Is there a way to decide if the package is provided by pypi or not?

Closed this issue · 3 comments

dmr commented

In the example requirements-parser is parsed as "requirements".

parsed = {'name': 'requirements', 'uri': 'https://github.com/davidfischer/requirements-parser.git', 'vcs': 'git'}

Another package that is provided by Pypi has a similar structure:

parsed = {'extras': [], 'name': 'Django', 'specs': [('>=', '1.5'), ('<', '1.6')]}

--> I assume that I can test

"vcs" in parsed

to see if a package is provided by Pypi. Is that correct or do you know a better way?

There's not an API for that (yet!). As the code is currently written, a normal pip requirement (that would typically result in a pypi search) will have the "name", "extras" and "specs" fields only. Checking for "vcs" is not foolproof since a requirement could be an absolute path to a file or a URL that doesn't point to version control.

dmr commented

Thanks for the quick response. I ended up using pkg_resources to decide that for me:
https://github.com/dmr/py3compat_checker/blob/master/app.py#L116

The app is probably full of bugs like the absolute path problem but it worked for what I needed.

Requirements parser uses the same underlying library. Glad to hear it worked out.