Browse Source

Merge "packaging: Remove support for pyN requirement files"

tags/5.0.0
Zuul 8 months ago
parent
commit
32bfe7808f
4 changed files with 14 additions and 35 deletions
  1. 6
    4
      doc/source/user/features.rst
  2. 5
    7
      doc/source/user/using.rst
  3. 3
    1
      pbr/packaging.py
  4. 0
    23
      pbr/tests/test_packaging.py

+ 6
- 4
doc/source/user/features.rst View File

@@ -204,14 +204,16 @@ for your project and will then parse these files, split them up appropriately,
204 204
 and inject them into the ``install_requires``, ``tests_require`` and/or
205 205
 ``dependency_links`` arguments to ``setup``. Voila!
206 206
 
207
-You can also have a requirement file for each specific major version of Python.
208
-If 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
-
211 207
 Finally, it is possible to specify groups of optional dependencies, or
212 208
 :ref:`"extra" requirements <extra-requirements>`, in your ``setup.cfg`` rather
213 209
 than ``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
+
215 217
 Automatic File Generation
216 218
 -------------------------
217 219
 

+ 5
- 7
doc/source/user/using.rst View File

@@ -382,20 +382,18 @@ Requirements
382 382
 
383 383
 Requirements files are used in place of the ``install_requires`` and
384 384
 ``extras_require`` attributes. Requirement files should be given one of the
385
-below 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):
385
+below names. This order is also the order that the requirements are tried in:
387 386
 
388
-* ``requirements-pyN.txt``
389
-* ``tools/pip-requires-py3``
390 387
 * ``requirements.txt``
391 388
 * ``tools/pip-requires``
392 389
 
393 390
 Only 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``
398
-   should be universal. You can use `Environment markers`_ for this purpose.
394
+   Previously you could specify requirements for a given major version of
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 398
 .. _extra-requirements:
401 399
 

+ 3
- 1
pbr/packaging.py View File

@@ -81,14 +81,16 @@ def _any_existing(file_list):
81 81
 def get_reqs_from_files(requirements_files):
82 82
     existing = _any_existing(requirements_files)
83 83
 
84
+    # TODO(stephenfin): Remove this in pbr 6.0+
84 85
     deprecated = [f for f in existing if f in PY_REQUIREMENTS_FILES]
85 86
     if deprecated:
86 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 89
                       'Use environment markers instead. Conflicting files: '
89 90
                       '%r' % deprecated,
90 91
                       DeprecationWarning)
91 92
 
93
+    existing = [f for f in existing if f not in PY_REQUIREMENTS_FILES]
92 94
     for requirements_file in existing:
93 95
         with open(requirements_file, 'r') as fil:
94 96
             return fil.read().split('\n')

+ 0
- 23
pbr/tests/test_packaging.py View File

@@ -43,7 +43,6 @@ import email.errors
43 43
 import imp
44 44
 import os
45 45
 import re
46
-import sys
47 46
 import sysconfig
48 47
 import tempfile
49 48
 import textwrap
@@ -549,28 +548,6 @@ class ParseRequirementsTest(base.BaseTestCase):
549 548
         result = packaging.parse_requirements([requirements])
550 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
 
575 552
 class ParseRequirementsTestScenarios(base.BaseTestCase):
576 553
 

Loading…
Cancel
Save