madpah / requirements-parser

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

Support for platform specific dependencies. #40

Open Erotemic opened 6 years ago

Erotemic commented 6 years ago

The current version does not seem to store platform specific dependency information (although it seems to parse it just fine).

This is to handle lines like

jaraco.windows >= 3.9.1;platform_system=="Windows"

currently parsing this line returns an object with the data:

{'editable': False,
 'extras': [],
 'hash': None,
 'hash_name': None,
 'line': 'jaraco.windows >= 3.9.1;platform_system=="Windows"',
 'local_file': False,
 'name': 'jaraco.windows',
 'path': None,
 'revision': None,
 'specifier': True,
 'specs': [('>=', '3.9.1')],
 'subdirectory': None,
 'uri': None,
 'vcs': None}

References on the spec are here: http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies

kayhayen commented 4 years ago

In a similar fashion, versioned Python requirements are ignored too. I was looking into parsing code like this:

pylint == 1.9.5 ; python_version == '2.7' pylint == 2.4.4 ; python_version >= '3.6'

Sadly this means, I am doing a filtering for Python version on my own, because also pipenv ignores these. I take it, they are only comments, but obviously ones that pip attaches meanings to?

kousu commented 4 years ago

This would be helpful!

nanonyme commented 3 years ago

https://www.python.org/dev/peps/pep-0508/ search for Environment markers allow making a specification only take effect in some environments:

This is a formally specified thing but not really straightforward unless you just want simple eval() with prefilling which isn't entirely safe.