diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index c9e30623065..7a39314bcd0 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -456,6 +456,17 @@ def build_extension(self, ext): debug=self.debug, extra_postargs=extra_args) + # XXX -- this is a Vile HACK! + # + # The setup.py script for Python on Unix needs to be able to + # get this list so it can perform all the clean up needed to + # avoid keeping object files around when cleaning out a failed + # build of an extension module. Since Distutils does not + # track dependencies, we have to get rid of intermediates to + # ensure all the intermediates will be properly re-built. + # + self._built_objects = objects[:] + # Now link the object files together into a "shared object" -- # of course, first we have to figure out all the other things # that go into the mix. diff --git a/setup.py b/setup.py index 183c45e06c2..693d64c9783 100644 --- a/setup.py +++ b/setup.py @@ -172,6 +172,13 @@ def build_extension(self, ext): 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. + for filename in self._built_objects: + os.remove(filename) + def get_platform (self): # Get value of sys.platform platform = sys.platform