From d478152a9731664eb40716eaa5ce84de8cdf6ae4 Mon Sep 17 00:00:00 2001 From: "Michael W. Hudson" Date: Fri, 6 Dec 2002 15:33:01 +0000 Subject: [PATCH] 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. --- setup.py | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index 62d15f934191..25b30e4f8e8e 100644 --- a/setup.py +++ b/setup.py @@ -164,25 +164,29 @@ class PyBuildExt(build_ext): 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) - - # 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)') + 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)') + else: + self.announce('*** WARNING: importing extension "%s" ' + 'failed: %s' % (ext.name, why)) def get_platform (self): # Get value of sys.platform -- 2.47.3