浏览代码

Fix DeprecationWarning on setuptools >= 11.3. Closes #617

Mike Naberezny 9 年之前
父节点
当前提交
b099386208
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 3 0
      CHANGES.txt
  2. 7 1
      supervisor/options.py

+ 3 - 0
CHANGES.txt

@@ -23,6 +23,9 @@
 - Fixed a bug introduced in 3.1.0 where ``supervisord`` could crash when
   attempting to display a resource limit error.
 
+- Fixed ``DeprecationWarning: Parameters to load are deprecated. Call
+  .resolve and .require separately.`` on setuptools >= 11.3.
+
 3.1.3 (2014-10-28)
 ------------------
 

+ 7 - 1
supervisor/options.py

@@ -385,7 +385,13 @@ class Options:
         return factories
 
     def import_spec(self, spec):
-        return pkg_resources.EntryPoint.parse("x="+spec).load(False)
+        ep = pkg_resources.EntryPoint.parse("x=" + spec)
+        if hasattr(ep, 'resolve'):
+            # this is available on setuptools >= 10.2
+            return ep.resolve()
+        else:
+            # this causes a DeprecationWarning on setuptools >= 11.3
+            return ep.load(False)
 
 
 class ServerOptions(Options):