summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2021-11-12 09:16:04 -0800
committerClark Boylan <clark.boylan@gmail.com>2021-11-12 09:16:04 -0800
commitde0c717b17841b0b14019130872f8f02a6aed217 (patch)
tree6386905a26420da89c2a588459e2ae6a1060c0a2
parentd21c2caf1dbd69ba630075e48254131499f01afe (diff)
downloadpbr-de0c717b17841b0b14019130872f8f02a6aed217.tar.gz
Allow PEP517 without setup_requires
When using PBR PEP517 support without setup_requires were were infinitely recursing because Distribution.finalize_options calls pbr() and pbr() calls Distribution.finalize_options. With a setup_requires this doesn't seem to happen because something is resetting dist.pbr's value from True (callable) to None (not callable) after the initial pbr() call and before further recursion can occur. Explicitly enforce this behavior in pbr() via an explicit update of dist.pbr to None to avoid calling pbr() more than once resulting in the unwanted loop. Change-Id: I1f2b4d34e587389f7e11b99d000e14477cf5091b
-rw-r--r--pbr/core.py8
-rw-r--r--pbr/tests/test_packaging.py7
2 files changed, 14 insertions, 1 deletions
diff --git a/pbr/core.py b/pbr/core.py
index 645a2ef..f221299 100644
--- a/pbr/core.py
+++ b/pbr/core.py
@@ -130,6 +130,14 @@ 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()
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index a024f56..7735053 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -930,7 +930,12 @@ class TestPEP517Support(base.BaseTestCase):
sphinx
iso8601
"""),
- # Use default PBR test setup.py.
+ # Override default setup.py to remove setup_requires.
+ 'setup.py': textwrap.dedent("""\
+ #!/usr/bin/env python
+ import setuptools
+ setuptools.setup(pbr=True)
+ """),
'setup.cfg': textwrap.dedent("""\
[metadata]
name = test_pep517