summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-06 21:14:59 +0000
committerGerrit Code Review <review@openstack.org>2018-10-06 21:14:59 +0000
commit32bfe7808f7c988c1d1b9acccd6fd437894c6e3d (patch)
tree2d90e362410db307e4b7e2efadc1c36903f4213a
parent36da1a13c0197b3daf02003188cbae93509a644f (diff)
parent8ea9d9262de318bf24d32246e6891d7a39d4b91b (diff)
Merge "packaging: Remove support for pyN requirement files"
-rw-r--r--doc/source/user/features.rst10
-rw-r--r--doc/source/user/using.rst12
-rw-r--r--pbr/packaging.py4
-rw-r--r--pbr/tests/test_packaging.py23
4 files changed, 14 insertions, 35 deletions
diff --git a/doc/source/user/features.rst b/doc/source/user/features.rst
index 106fd1a..46c9d03 100644
--- a/doc/source/user/features.rst
+++ b/doc/source/user/features.rst
@@ -204,14 +204,16 @@ for your project and will then parse these files, split them up appropriately,
204and inject them into the ``install_requires``, ``tests_require`` and/or 204and inject them into the ``install_requires``, ``tests_require`` and/or
205``dependency_links`` arguments to ``setup``. Voila! 205``dependency_links`` arguments to ``setup``. Voila!
206 206
207You can also have a requirement file for each specific major version of Python.
208If you want to have a different package list for Python 3 then just drop a
209``requirements-py3.txt`` and it will be used instead.
210
211Finally, it is possible to specify groups of optional dependencies, or 207Finally, it is possible to specify groups of optional dependencies, or
212:ref:`"extra" requirements <extra-requirements>`, in your ``setup.cfg`` rather 208:ref:`"extra" requirements <extra-requirements>`, in your ``setup.cfg`` rather
213than ``setup.py``. 209than ``setup.py``.
214 210
211.. versionchanged:: 5.0
212
213 Previously you could specify requirements for a given major version of
214 Python using requirments files with a ``-pyN`` suffix. This was deprecated
215 in 4.0 and removed in 5.0 in favour of environment markers.
216
215Automatic File Generation 217Automatic File Generation
216------------------------- 218-------------------------
217 219
diff --git a/doc/source/user/using.rst b/doc/source/user/using.rst
index b5e28eb..0104640 100644
--- a/doc/source/user/using.rst
+++ b/doc/source/user/using.rst
@@ -382,20 +382,18 @@ Requirements
382 382
383Requirements files are used in place of the ``install_requires`` and 383Requirements files are used in place of the ``install_requires`` and
384``extras_require`` attributes. Requirement files should be given one of the 384``extras_require`` attributes. Requirement files should be given one of the
385below names. This order is also the order that the requirements are tried in 385below names. This order is also the order that the requirements are tried in:
386(where ``N`` is the Python major version number used to install the package):
387 386
388* ``requirements-pyN.txt``
389* ``tools/pip-requires-py3``
390* ``requirements.txt`` 387* ``requirements.txt``
391* ``tools/pip-requires`` 388* ``tools/pip-requires``
392 389
393Only the first file found is used to install the list of packages it contains. 390Only the first file found is used to install the list of packages it contains.
394 391
395.. note:: 392.. versionchanged:: 5.0
396 393
397 The ``requirements-pyN.txt`` file is deprecated - ``requirements.txt`` 394 Previously you could specify requirements for a given major version of
398 should be universal. You can use `Environment markers`_ for this purpose. 395 Python using requirements files with a ``-pyN`` suffix. This was deprecated
396 in 4.0 and removed in 5.0 in favour of environment markers.
399 397
400.. _extra-requirements: 398.. _extra-requirements:
401 399
diff --git a/pbr/packaging.py b/pbr/packaging.py
index dc0b60c..d8d3737 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -81,14 +81,16 @@ def _any_existing(file_list):
81def get_reqs_from_files(requirements_files): 81def get_reqs_from_files(requirements_files):
82 existing = _any_existing(requirements_files) 82 existing = _any_existing(requirements_files)
83 83
84 # TODO(stephenfin): Remove this in pbr 6.0+
84 deprecated = [f for f in existing if f in PY_REQUIREMENTS_FILES] 85 deprecated = [f for f in existing if f in PY_REQUIREMENTS_FILES]
85 if deprecated: 86 if deprecated:
86 warnings.warn('Support for \'-pyN\'-suffixed requirements files is ' 87 warnings.warn('Support for \'-pyN\'-suffixed requirements files is '
87 'deprecated in pbr 4.0 and will be removed in 5.0. ' 88 'removed in pbr 5.0 and these files are now ignored. '
88 'Use environment markers instead. Conflicting files: ' 89 'Use environment markers instead. Conflicting files: '
89 '%r' % deprecated, 90 '%r' % deprecated,
90 DeprecationWarning) 91 DeprecationWarning)
91 92
93 existing = [f for f in existing if f not in PY_REQUIREMENTS_FILES]
92 for requirements_file in existing: 94 for requirements_file in existing:
93 with open(requirements_file, 'r') as fil: 95 with open(requirements_file, 'r') as fil:
94 return fil.read().split('\n') 96 return fil.read().split('\n')
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index bbbd584..d19dd05 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -43,7 +43,6 @@ import email.errors
43import imp 43import imp
44import os 44import os
45import re 45import re
46import sys
47import sysconfig 46import sysconfig
48import tempfile 47import tempfile
49import textwrap 48import textwrap
@@ -549,28 +548,6 @@ class ParseRequirementsTest(base.BaseTestCase):
549 result = packaging.parse_requirements([requirements]) 548 result = packaging.parse_requirements([requirements])
550 self.assertEqual(['pbr'], result) 549 self.assertEqual(['pbr'], result)
551 550
552 @mock.patch('warnings.warn')
553 def test_python_version(self, mock_warn):
554 with open("requirements-py%d.txt" % sys.version_info[0],
555 "w") as fh:
556 fh.write("# this is a comment\nfoobar\n# and another one\nfoobaz")
557 self.assertEqual(['foobar', 'foobaz'],
558 packaging.parse_requirements())
559 mock_warn.assert_called_once_with(mock.ANY, DeprecationWarning)
560
561 @mock.patch('warnings.warn')
562 def test_python_version_multiple_options(self, mock_warn):
563 with open("requirements-py1.txt", "w") as fh:
564 fh.write("thisisatrap")
565 with open("requirements-py%d.txt" % sys.version_info[0],
566 "w") as fh:
567 fh.write("# this is a comment\nfoobar\n# and another one\nfoobaz")
568 self.assertEqual(['foobar', 'foobaz'],
569 packaging.parse_requirements())
570 # even though we have multiple offending files, this should only be
571 # called once
572 mock_warn.assert_called_once_with(mock.ANY, DeprecationWarning)
573
574 551
575class ParseRequirementsTestScenarios(base.BaseTestCase): 552class ParseRequirementsTestScenarios(base.BaseTestCase):
576 553