diff -r 897fe8fa14b5 setup.py --- a/setup.py Thu Oct 13 23:00:37 2016 -0700 +++ b/setup.py Sat Oct 15 20:42:09 2016 +0200 @@ -230,7 +230,12 @@ headers = [sysconfig.get_config_h_filename()] headers += glob(os.path.join(sysconfig.get_path('include'), "*.h")) - for ext in self.extensions[:]: + # The makesetup list of the statically built module objects names. + modobjs = [os.path.splitext(os.path.basename(p))[0] for p in + re.split('(?<=\.o) +', sysconfig.get_config_var('MODOBJS'))] + + removed_modules = [] + for ext in self.extensions: ext.sources = [ find_module_file(filename, moddirlist) for filename in ext.sources ] if ext.depends is not None: @@ -242,25 +247,15 @@ ext.depends.extend(headers) # If a module has already been built statically, - # don't build it here - if ext.name in sys.builtin_module_names: - self.extensions.remove(ext) + # don't build it here. + for src in ext.sources: + if os.path.splitext(os.path.basename(src))[0] in modobjs: + removed_modules.append(ext) + break - # Parse Modules/Setup and Modules/Setup.local to figure out which - # modules are turned on in the file. - remove_modules = [] - for filename in ('Modules/Setup', 'Modules/Setup.local'): - input = text_file.TextFile(filename, join_lines=1) - while 1: - line = input.readline() - if not line: break - line = line.split() - remove_modules.append(line[0]) - input.close() - - for ext in self.extensions[:]: - if ext.name in remove_modules: - self.extensions.remove(ext) + if removed_modules: + self.extensions = [x for x in self.extensions if x not in + removed_modules] # When you run "make CC=altcc" or something similar, you really want # those environment variables passed into the setup.py phase. Here's @@ -303,6 +298,12 @@ " detect_modules() for the module's name.") print() + if removed_modules: + print("The following modules, detected by setup.py, have been" + " statically built") + print("instead, as configured by the Setup files:") + print_three_column([ext.name for ext in removed_modules]) + if self.failed: failed = self.failed[:] print()