Ver Fonte

use imp.find_module to remove task package

Ask Solem há 13 anos atrás
pai
commit
854020079e
1 ficheiros alterados com 15 adições e 12 exclusões
  1. 15 12
      setup.py

+ 15 - 12
setup.py

@@ -8,6 +8,21 @@ import platform
 if sys.version_info < (2, 5):
     raise Exception("Celery requires Python 2.5 or higher.")
 
+try:
+    import imp
+    import celery.app
+    _, task_path, _ = imp.find_module("task", celery.app.__path__)
+    if "__init__.py" in task_path:
+        print("- force upgrading previous installation")
+        print("  - removing %r package..." % task_path)
+        try:
+            os.unlink(os.path.abspath(task_path))
+        except Exception, exc:
+            sys.stderr.write("Couldn't remove %r: %r\n" % (task_path, exc))
+except ImportError:
+    print("OH NOES")
+
+
 try:
     from setuptools import setup, find_packages
     from setuptools.command.test import test
@@ -22,18 +37,6 @@ NAME = "celery"
 entrypoints = {}
 extra = {}
 
-try:
-    from celery.app import task
-    if "__init__.py" in task.__file__:
-        print("- force upgrading previous installation")
-        print("  - removing celery.app.task package...")
-        try:
-            os.unlink(os.path.abspath(task.__file__))
-        except Exception, exc:
-            sys.stderr.write("Couldn't remove %r: %r\n" % (task.__file__, exc))
-except ImportError:
-    pass
-
 # -*- Classifiers -*-
 
 classes = """