From 1f72baec4bbbd1b205192ceaf729530faae76c4a Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 4 Jun 2018 15:48:20 +0200 Subject: [PATCH] FIX(pvlib,setup,PY2): monkeypatching type(dist) fails, because... PY2 type(dist) is ````, and does not have the method to patch. --- pvlib/polyversion/setuplugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pvlib/polyversion/setuplugin.py b/pvlib/polyversion/setuplugin.py index 5b652ce..def26bf 100644 --- a/pvlib/polyversion/setuplugin.py +++ b/pvlib/polyversion/setuplugin.py @@ -88,10 +88,13 @@ def _establish_setup_py_version(dist, repo_path=None, **pvargs): # NOTE: We monekypatch even if user has disabled check, # bc we can't now the kw order. # - orig_func = type(dist).run_command + ## NOTE: PY2 `type(dist)` is `` on PY2, + # which does not have the method to patch. + DistClass = dist.__class__ + orig_func = DistClass.run_command if orig_func is not _monkeypathed_run_command: - type(dist).run_command = _monkeypathed_run_command - type(dist)._polyversion_orig_run_cmd = orig_func + DistClass.run_command = _monkeypathed_run_command + DistClass._polyversion_orig_run_cmd = orig_func if version: dist.metadata.version = version