Skip to content

parse_requirements fails with environment markers #470

@ghost

Description

Originally reported by: dims (Bitbucket: dims, GitHub: dims)


Just a simple call like the following fails:

#!bash

pkg_resources.parse_requirements('Twis-Ted>=1.2-1;python_version==\'2.7\'')

Found this when trying to run tox -e py27 on https://github.com/openstack/oslo.privsep in a mac environment with latest setuptools.

#!bash

tox -e py27
GLOB sdist-make: /Users/dims/openstack/oslo/oslo.privsep/setup.py
ERROR: invocation failed (exit code 1), logfile: /Users/dims/openstack/oslo/oslo.privsep/.tox/log/tox-0.log
ERROR: actionid: tox
msg: packaging
cmdargs: ['/usr/local/opt/python/bin/python2.7', local('/Users/dims/openstack/oslo/oslo.privsep/setup.py'), 'sdist', '--formats=zip', '--dist-dir', local('/Users/dims/openstack/oslo/oslo.privsep/.tox/dist')]
env: None

error in setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in enum34;python_version=='2.7' or python_version=='2.6' at ;python_version=='2.7' or python_version=='2.6'

ERROR: FAIL could not package project - v = InvocationError('/usr/local/opt/python/bin/python2.7 /Users/dims/openstack/oslo/oslo.privsep/setup.py sdist --formats=zip --dist-dir /Users/dims/openstack/oslo/oslo.privsep/.tox/dist (see /Users/dims/openstack/oslo/oslo.privsep/.tox/log/tox-0.log)', 1)

If i edit the line, i can get past the error:
https://github.com/openstack/oslo.privsep/blob/master/requirements.txt#L10

However since OpenStack uses this syntax a lot, it would be great to add support for this syntax:
https://github.com/openstack/requirements/blob/master/global-requirements.txt

Here are some tracebacks to pin point the problem (line numbers may vary!)

#!bash

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 125, in check_requirements
    list(pkg_resources.parse_requirements(value))
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2930, in parse_requirements
    "version spec")
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2895, in scan_list
    raise RequirementParseError(msg, line, "at", line[p:])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions