From 7ec7f941a4a32eafd550aeddc0eaf508e81f5b4b Mon Sep 17 00:00:00 2001 From: "Gregory M. Turner" Date: Mon, 12 Sep 2016 21:44:34 -0700 Subject: [PATCH 2/2] distutils type checks can fail (issue 23102) Avoid goofy setuptools behavior when using from foo.bar import baz import style with Distribution. --- Lib/distutils/cmd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py index 939f795..d48a0e6 100644 --- a/Lib/distutils/cmd.py +++ b/Lib/distutils/cmd.py @@ -50,10 +50,10 @@ class Command: initializer and depends on the actual command being instantiated. """ - # late import because of mutual dependence between these classes - from distutils.dist import Distribution - - if not isinstance(dist, Distribution): + # dist should quack like a Distribution (duck-typing avoids a + # circular dependency and hopefully ameliorates trouble due to + # setuptools having monkey patched distutils modules). + if not hasattr(dist, 'get_requires'): raise TypeError("dist must be a Distribution instance") if self.__class__ is Command: raise RuntimeError("Command is an abstract class") -- 2.9.3