madpah / requirements-parser

A Pip requirements file parser.
https://requirements-parser.readthedocs.io
Apache License 2.0
125 stars 41 forks source link

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

Closed dmr closed 11 years ago

dmr commented 11 years ago

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?

davidfischer commented 11 years ago

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 11 years ago

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.

davidfischer commented 11 years ago

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