Do not silently drop markers that fail to evaluate

We are silently dropping requirements that do not parse, do not do this
and bubble the error up.

Change-Id: I5bfce7c7d0be2ccd880e78509856074a09c57166
Closes-Bug: 1554331
This commit is contained in:
Sachi King
2016-03-08 11:15:34 +11:00
parent 09c65298e5
commit 11ffee94fa
4 changed files with 67 additions and 4 deletions

View File

@@ -0,0 +1,46 @@
..
The name of this document and the anchor in this document must be
treated as a stable API. Links to this document are coded into
pbr and deployed versions of pbr will refer users to this document
in the case of certain errors.
Ensure any link you use in PBR is defined via a ref with .. _name.
===================
Compatibility Notes
===================
Useful notes about errors users may encounter when features cannot be
supported on older versions of setuptools / pip / wheel.
setuptools
==========
.. _evaluate-marker:
evaluate_marker
---------------
evaluate_markers may run into issues with the '>', '>=', '<', and '<='
operators if the installed version of setuptools is less than 17.1. Projects
using these operators with markers should specify a minimum version of 17.1
for setuptools.
pip
===
markers
-------
For versions of pip < 7 with pbr < 1.9, dependencies that use markers will not
be installed. Projects using pbr and markers should set a minimum version of
1.9 for pbr.
Recommended setup.py
====================
:ref:`setup_py`.

View File

@@ -144,19 +144,21 @@ Usage
``setuptools.setup()``. While the normal setuptools facilities are available, ``setuptools.setup()``. While the normal setuptools facilities are available,
pbr makes it possible to express them through static data files. pbr makes it possible to express them through static data files.
.. _setup_py:
setup.py setup.py
-------- --------
`pbr` only requires a minimal `setup.py` file compared to a standard setuptools `pbr` only requires a minimal `setup.py` file compared to a standard setuptools
project. This is because most configuration is located in static configuration project. This is because most configuration is located in static configuration
files. This minimal `setup.py` file should look something like this:: files. This recommended minimal `setup.py` file should look something like this::
#!/usr/bin/env python #!/usr/bin/env python
from setuptools import setup from setuptools import setup
setup( setup(
setup_requires=['pbr'], setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
pbr=True, pbr=True,
) )
@@ -395,6 +397,7 @@ Additional Docs
packagers packagers
semver semver
testing testing
compatibility
Indices and tables Indices and tables
================== ==================

View File

@@ -45,10 +45,11 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase):
foo:python_version=='2.6' foo:python_version=='2.6'
bar bar
baz<1.6 :python_version=='2.6' baz<1.6 :python_version=='2.6'
zaz :python_version>'1.0'
""", """,
'expected_extra_requires': { 'expected_extra_requires': {
"test:(python_version=='2.6')": ['foo', 'baz<1.6'], "test:(python_version=='2.6')": ['foo', 'baz<1.6'],
"test": ['bar']}}), "test": ['bar', 'zaz']}}),
('no_extras', { ('no_extras', {
'config_text': """ 'config_text': """
[metadata] [metadata]
@@ -73,3 +74,10 @@ class TestExtrasRequireParsingScenarios(base.BaseTestCase):
self.assertEqual(self.expected_extra_requires, self.assertEqual(self.expected_extra_requires,
kwargs['extras_require']) kwargs['extras_require'])
class TestInvalidMarkers(base.BaseTestCase):
def test_invalid_marker_raises_error(self):
config = {'extras': {'test': "foo :bad_marker>'1.0'"}}
self.assertRaises(SyntaxError, util.setup_cfg_to_setup_kwargs, config)

View File

@@ -431,7 +431,13 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
if pkg_resources.evaluate_marker('(%s)' % env_marker): if pkg_resources.evaluate_marker('(%s)' % env_marker):
extras_key = req_group extras_key = req_group
except SyntaxError: except SyntaxError:
pass log.error(
"Marker evaluation failed, see the following "
"error. For more information see: "
"http://docs.openstack.org/"
"developer/pbr/compatibility.html#evaluate-marker"
)
raise
else: else:
extras_key = req_group extras_key = req_group
extras_require.setdefault(extras_key, []).append(requirement) extras_require.setdefault(extras_key, []).append(requirement)