Commit a260dc3f authored by Jason R. Coombs's avatar Jason R. Coombs Committed by Stephen Finucane

Discover Distribution through the class hierarchy

Discovering the underlying Distribution class through the class
hierarchy saves unpatching and repatching.

Based on commits ed579a5dbb2a1843874969a58bb2b6f1eca2e50d and
10b87cc1eb92f50906ff645d0221c74f03de94b9 from [1].


Closes-Bug: #1620153.
Change-Id: I7418cc3ab36823d029a93f86df9c8b25aa7b0c5f
Signed-off-by: 's avatarJason R. Coombs <>
Signed-off-by: 's avatarMonty Taylor <>
Signed-off-by: 's avatarStephen Finucane <>
parent c45687fb
......@@ -50,22 +50,9 @@ import os
import sys
import warnings
from setuptools import dist
from pbr import util
_saved_core_distribution = core.Distribution
def _monkeypatch_distribution():
core.Distribution = dist._get_unpatched(core.Distribution)
def _restore_distribution_monkeypatch():
core.Distribution = _saved_core_distribution
if sys.version_info[0] == 3:
string_type = str
integer_types = (int,)
......@@ -94,8 +81,7 @@ def pbr(dist, attr, value):
not work well with distributions that do use a `Distribution` subclass.
if True:
if not value:
if isinstance(value, string_type):
......@@ -135,11 +121,15 @@ def pbr(dist, attr, value):
# Re-finalize the underlying Distribution
super(dist.__class__, dist).finalize_options()
except TypeError:
# If dist is not declared as a new-style class (with object as
# a subclass) then super() will not work on it. This is the case
# for Python 2. In that case, fall back to doing this the ugly way
# This bit comes out of distribute/setuptools
if isinstance(dist.metadata.version, integer_types + (float,)):
# Some people apparently take "version number" too literally :)
dist.metadata.version = str(dist.metadata.version)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment