Imported Upstream version 5.8.1 upstream/5.8.1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 18 Jul 2022 01:15:37 +0000 (10:15 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 18 Jul 2022 01:15:37 +0000 (10:15 +0900)
12 files changed:
AUTHORS
ChangeLog
PKG-INFO
pbr.egg-info/PKG-INFO
pbr.egg-info/SOURCES.txt
pbr/core.py
pbr/packaging.py
pbr/tests/test_packaging.py
pbr/tests/test_pbr_json.py
releasenotes/notes/fix-pep517-metadata-regression-bc287e60e45b2732.yaml [new file with mode: 0644]
test-requirements.txt
tox.ini

diff --git a/AUTHORS b/AUTHORS
index eb2fe0dc0c1354b05568d08d106d356716362b39..c43d177ba4535b0a33442b695cf565853d943fde 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,6 +10,7 @@ Angus Salkeld <asalkeld@redhat.com>
 Anthony Young <sleepsonthefloor@gmail.com>
 Antoine Musso <hashar@free.fr>
 Attila Fazekas <afazekas@redhat.com>
+Ben Greiner <code@bnavigator.de>
 Ben Nemec <bnemec@redhat.com>
 Bhuvan Arumugam <bhuvan@apache.org>
 Brandon LeBlanc <brandon@leblanc.codes>
index 012299893b5a3ad18777ecd9cb1f24d3f9e83849..0b05c7532f558bc0176dfdc3a736e51151512ecb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,15 @@
 CHANGES
 =======
 
+5.8.1
+-----
+
+* Add release note about missing pbr.json fix
+* Avoid recursive calls into SetupTools entrypoint
+* remove explicit mock
+* Don't test with setuptools local distutils
+* Use context blocks for open() calls in packaging
+
 5.8.0
 -----
 
index ccf0c2ae48dc5e2893e9027c3946998a60f747e2..584766208ec4198a896fce8cb597ded9ce43883b 100644 (file)
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pbr
-Version: 5.8.0
+Version: 5.8.1
 Summary: Python Build Reasonableness
 Home-page: https://docs.openstack.org/pbr/latest/
 Author: OpenStack
index ccf0c2ae48dc5e2893e9027c3946998a60f747e2..584766208ec4198a896fce8cb597ded9ce43883b 100644 (file)
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pbr
-Version: 5.8.0
+Version: 5.8.1
 Summary: Python Build Reasonableness
 Home-page: https://docs.openstack.org/pbr/latest/
 Author: OpenStack
index ed0daa2790987f014d77e0c0c88acd894826226a..484ac6358c7ad66335a1fd168ce7532036e6bd0d 100644 (file)
@@ -102,6 +102,7 @@ releasenotes/notes/fix-global-replace-of-src-prefix-in-glob-eb850b94ca96993e.yam
 releasenotes/notes/fix-handling-of-spaces-in-data-files-glob-0fe0c398d70dfea8.yaml
 releasenotes/notes/fix-keywords-as-cfg-list-6cadc5141429d7f5.yaml
 releasenotes/notes/fix-mapping-value-explode-with-equal-sign-41bf822fa4dd0e68.yaml
+releasenotes/notes/fix-pep517-metadata-regression-bc287e60e45b2732.yaml
 releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml
 releasenotes/notes/long-descr-content-type-f9a1003acbb8740f.yaml
 releasenotes/notes/pep517-support-89189ce0bab15845.yaml
index f221299e9671d2b8cb2cbf8e051dc15a7f113435..a801737a9560229dbbf71f13372a48d3de2404fa 100644 (file)
@@ -61,6 +61,11 @@ else:
     integer_types = (int, long)  # noqa
 
 
+# We use this canary to detect whether the module has already been called,
+# in order to avoid recursion
+in_use = False
+
+
 def pbr(dist, attr, value):
     """Implements the actual pbr setup() keyword.
 
@@ -81,6 +86,16 @@ def pbr(dist, attr, value):
     not work well with distributions that do use a `Distribution` subclass.
     """
 
+    # Distribution.finalize_options() is what calls this method. That means
+    # there is potential for recursion here. Recursion seems to be an issue
+    # particularly when using PEP517 build-system configs without
+    # setup_requires in setup.py. We can avoid the recursion by setting
+    # this canary so we don't repeat ourselves.
+    global in_use
+    if in_use:
+        return
+    in_use = True
+
     if not value:
         return
     if isinstance(value, string_type):
@@ -130,14 +145,6 @@ def pbr(dist, attr, value):
                 msg = 'Unknown distribution option: %s' % repr(key)
                 warnings.warn(msg)
 
-    # Distribution.finalize_options() is what calls this method. That means
-    # there is potential for recursion here. Recursion seems to be an issue
-    # particularly when using PEP517 build-system configs without
-    # setup_requires in setup.py. We can avoid the recursion by setting
-    # dist.pbr to a None value as the corresponding entrypoint (this function)
-    # will only be called on a non None value.
-    setattr(dist, "pbr", None)
-
     # Re-finalize the underlying Distribution
     try:
         super(dist.__class__, dist).finalize_options()
index ae0779653cc6d17bf005cf07221ac9e0b6f786bb..8577b53291b324825e6490f8c3fbf97c00b00e76 100644 (file)
@@ -581,8 +581,9 @@ class LocalEggInfo(egg_info.egg_info):
         else:
             log.info("[pbr] Reusing existing SOURCES.txt")
             self.filelist = egg_info.FileList()
-            for entry in open(manifest_filename, 'r').read().split('\n'):
-                self.filelist.append(entry)
+            with open(manifest_filename, 'r') as fil:
+                for entry in fil.read().split('\n'):
+                    self.filelist.append(entry)
 
 
 def _from_git(distribution):
@@ -823,12 +824,9 @@ def _get_version_from_pkg_metadata(package_name):
     pkg_metadata = {}
     for filename in pkg_metadata_filenames:
         try:
-            pkg_metadata_file = open(filename, 'r')
-        except (IOError, OSError):
-            continue
-        try:
-            pkg_metadata = email.message_from_file(pkg_metadata_file)
-        except email.errors.MessageError:
+            with open(filename, 'r') as pkg_metadata_file:
+                pkg_metadata = email.message_from_file(pkg_metadata_file)
+        except (IOError, OSError, email.errors.MessageError):
             continue
 
     # Check to make sure we're in our own dir
index 7735053f7ab9ca934c8c5da6c242d2e386352101..c92ea9bc9cc25c3b49ba2945f38d56e6b6916b3c 100644 (file)
@@ -48,7 +48,10 @@ import tempfile
 import textwrap
 
 import fixtures
-import mock
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 import pkg_resources
 import six
 import testscenarios
@@ -378,6 +381,12 @@ class TestPackagingWheels(base.BaseTestCase):
         wheel_file.extractall(self.extracted_wheel_dir)
         wheel_file.close()
 
+    def test_metadata_directory_has_pbr_json(self):
+        # Build the path to the scripts directory
+        pbr_json = os.path.join(
+            self.extracted_wheel_dir, 'pbr_testpackage-0.0.dist-info/pbr.json')
+        self.assertTrue(os.path.exists(pbr_json))
+
     def test_data_directory_has_wsgi_scripts(self):
         # Build the path to the scripts directory
         scripts_dir = os.path.join(
index f066971365734ad7210fc0ae9bbcb0b7145355a6..eb9a08adcb15c633cc3cdd878b2a0ba0dc62a8b7 100644 (file)
 # License for the specific language governing permissions and limitations
 # under the License.
 
-import mock
+try:
+    from unittest import mock
+except ImportError:
+    import mock
 
 from pbr import pbr_json
 from pbr.tests import base
diff --git a/releasenotes/notes/fix-pep517-metadata-regression-bc287e60e45b2732.yaml b/releasenotes/notes/fix-pep517-metadata-regression-bc287e60e45b2732.yaml
new file mode 100644 (file)
index 0000000..c056700
--- /dev/null
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Packages generated with the 5.8.0 release of PBR failed to incorporate
+    pbr.json metadata files. This is now corrected. Users can rebuild packages
+    with newer PBR if they want that missing metadata generated.
index 4d586e41b2c0e838c8209cb9063fe7eca357f5d0..3af261d0b36d590f50216cfc5b031e26833c04bd 100644 (file)
@@ -6,7 +6,6 @@ wheel>=0.32.0 # MIT
 fixtures>=3.0.0 # Apache-2.0/BSD
 hacking>=1.1.0,<4.0.0;python_version>='3.6' # Apache-2.0
 mock>=2.0.0,<4.0.0;python_version=='2.7' # BSD
-mock>=2.0.0;python_version>='3.6' # BSD
 six>=1.12.0 # MIT
 stestr>=2.1.0,<3.0;python_version=='2.7' # Apache-2.0
 stestr>=2.1.0;python_version>='3.0' # Apache-2.0
diff --git a/tox.ini b/tox.ini
index 549dd4eda0dc01ab7a5f46b1a7e660754404e9fe..e158f90fa23d7ef764beca88ec6a4e7166e7dbfe 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,10 @@ ignore_basepython_conflict = True
 usedevelop = True
 basepython = python3
 passenv = PBR_INTEGRATION PIPFLAGS PIPVERSION PBRVERSION REPODIR WHEELHOUSE PROJECTS
+# TODO(fungi): drop distutils override once logging improves in Setuptools
+#              https://github.com/pypa/setuptools/issues/3038
 setenv =
+  SETUPTOOLS_USE_DISTUTILS=stdlib
   OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:1}
   OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:1}
   OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:60}
@@ -40,7 +43,10 @@ commands =
 commands = {posargs}
 
 [testenv:cover]
+# TODO(fungi): drop distutils override once logging improves in Setuptools
+#              https://github.com/pypa/setuptools/issues/3038
 setenv =
+  SETUPTOOLS_USE_DISTUTILS=stdlib
   PYTHON=coverage run --source pbr --parallel-mode
 commands =
   stestr run {posargs}