Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
parse_requirements fails with environment markers #470
Just a simple call like the following fails:
Found this when trying to run tox -e py27 on https://github.com/openstack/oslo.privsep in a mac environment with latest setuptools.
If i edit the line, i can get past the error:
However since OpenStack uses this syntax a lot, it would be great to add support for this syntax:
Here are some tracebacks to pin point the problem (line numbers may vary!)
Are you sure that this isn't because of the following virtualenv bugs, all of which refer to the fact that virtualenv bundles setuptools 0.18.2 and installs that rather than the latest available version (or at least the version you have installed)?
@tysonclugg, I don't think it's a bug with 18.2. I don't think setuptools supports environment markers except in 'extras'.
The way to specify a requirement like
So it could be said that the bug lies in pbr, which isn't properly translating a requirements.txt format back into the expected syntax that setuptools requires.
In any case, it's not a simple "fix", but rather a feature request, and a non-trivial one, because it would involve supporting a new syntax that's already supported through a different mechanism.
Can't setuptools support requirement specifiers (environment markers) in
pip works, setuptools breaks
I have a
Unfortunately, using environment markers is supported by
Using pip (with Python 3):
$ pip install -r requirements.txt Ignoring dnspython: markers "python_version < '3'" don't match your environment Installing collected packages: dnspython3 Successfully installed dnspython3-1.12.0
Using setuptools (with Python 3):
$ python setup.py develop error in GuuruBackoffice setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in dnspython3 ;python_version >= '3' at ;python_version >= '3'
Related code samples
# -- FILE: requirements.txt dnspython3 ;python_version >= '3' dnspython ;python_version < '3'
# -- FILE: setup.py from os.path import abspath, dirname, join from setuptools import setup, find_packages def read_file(filename): with open(join(abspath(dirname(__file__)), filename)) as f: return f.read() setup( # ... install_requires=read_file('requirements.txt'), # ... )
Can't we implement the same (or a matching) requirements parsing as pip for markers and deprecate
This way a just single feature/keyword does it all for requirements. And we do away with some confusion, because pip's and setuptools' behavior match more closely.
Reading the history, in Setuptools 20.5 and more stable in 20.6.8, Setuptools should support environment markers in install_requires and others. I do suspect that this feature can't be widely adopted until older versions of Setuptools have worked their way through retirement. @bittner, can you confirm that the later releases work as you would expect?
Perhaps, but I struggle to think of how this is done without first upgrading the world to Setuptools 20.6.8 or later.