diff setup.py @ 26552:4e6ac2fe68f0 2.2

Fix bugs: [ 534748 ] Removing _tkinter considered harmful [ 645383 ] Give some clue why modules fail... by slapping the code from the trunk across to the release22-maint branch.
author Michael W. Hudson <mwh@python.net>
date Fri, 06 Dec 2002 15:33:01 +0000
parents d8ec98b74fa7
children 92a406115e7c
line wrap: on
line diff
--- a/setup.py	Fri Dec 06 10:17:35 2002 +0000
+++ b/setup.py	Fri Dec 06 15:33:01 2002 +0000
@@ -164,25 +164,29 @@
         try:
             __import__(ext.name)
         except ImportError:
-            self.announce('WARNING: removing "%s" since importing it failed' %
-                          ext.name)
-            assert not self.inplace
-            fullname = self.get_ext_fullname(ext.name)
-            ext_filename = os.path.join(self.build_lib,
-                                        self.get_ext_filename(fullname))
-            os.remove(ext_filename)
+            if 1:
+                self.announce('*** WARNING: renaming "%s" since importing it'
+                              ' failed: %s' % (ext.name, why))
+                assert not self.inplace
+                basename, tail = os.path.splitext(ext_filename)
+                newname = basename + "_failed" + tail
+                if os.path.exists(newname): os.remove(newname)
+                os.rename(ext_filename, newname)
 
-            # XXX -- This relies on a Vile HACK in
-            # distutils.command.build_ext.build_extension().  The
-            # _built_objects attribute is stored there strictly for
-            # use here.
-            # If there is a failure, _built_objects may not be there,
-            # so catch the AttributeError and move on.
-            try:
-                for filename in self._built_objects:
-                    os.remove(filename)
-            except AttributeError:
-                self.announce('unable to remove files (ignored)')
+                # XXX -- This relies on a Vile HACK in
+                # distutils.command.build_ext.build_extension().  The
+                # _built_objects attribute is stored there strictly for
+                # use here.
+                # If there is a failure, _built_objects may not be there,
+                # so catch the AttributeError and move on.
+                try:
+                    for filename in self._built_objects:
+                        os.remove(filename)
+                except AttributeError:
+                    self.announce('unable to remove files (ignored)')
+            else:
+                self.announce('*** WARNING: importing extension "%s" '
+                              'failed: %s' % (ext.name, why))
 
     def get_platform (self):
         # Get value of sys.platform