Ticket #6234: trac-6234.patch

File trac-6234.patch, 2.9 KB (added by craigcitro, 12 years ago)
  • setup.py

    # HG changeset patch
    # User Craig Citro <craigcitro@gmail.com>
    # Date 1244540906 25200
    # Node ID 43a8b91f5a50422494f8c521cae7d2b256f811f7
    # Parent  7d31f5c82867a9db663a979999e451def762446e
    Turn on the parallel distutils by default (trac #6234).
    
    diff -r 7d31f5c82867 -r 43a8b91f5a50 setup.py
    a b  
    223223        execute_list_of_commands_in_serial(command_list)
    224224    print "Time to execute %s commands: %s seconds"%(len(command_list), time.time() - t)
    225225
    226 #############################################
    227 ###### Parallel gcc execution
    228 ######   
    229 ######  This code is responsible for making
    230 ###### distutils spawn compilation threads
    231 ###### in parallel. TODO: EXPLAIN
    232 ######   
    233 #############################################
     226########################################################################
     227##
     228## Parallel gcc execution
     229##
     230## This code is responsible for making distutils dispatch the calls to
     231## build_ext in parallel. Since distutils doesn't seem to do this by
     232## default, we create our own extension builder and override the
     233## appropriate methods.  Unfortunately, in distutils, the logic of
     234## deciding whether an extension needs to be recompiled and actually
     235## making the call to gcc to recompile the extension are in the same
     236## function. As a result, we can't just override one function and have
     237## everything magically work. Instead, we split this work between two
     238## functions. This works fine for our application, but it means that
     239## we can't use this modification to make the other parts of Sage that
     240## build with distutils call gcc in parallel.
     241##
     242########################################################################
     243
    234244
    235245from distutils.command.build_ext import build_ext
    236246from distutils.dep_util import newer_group
     
    243253        # First, sanity-check the 'extensions' list
    244254        self.check_extensions_list(self.extensions)
    245255
     256        # We require MAKE to be set to decide how many cpus are
     257        # requested.
    246258        if not os.environ.has_key('MAKE'):
    247259            ncpus = 1
    248260        else:
     
    266278        import time
    267279        t = time.time()
    268280
    269         # See if we're trying out the experimental parallel build
    270         # code.
    271         if ncpus > 1 and os.environ.has_key('SAGE_PARALLEL_DIST'):
     281        if ncpus > 1:
     282
     283            # First, decide *which* extensions need rebuilt at
     284            # all.
    272285            extensions_to_compile = []
    273286            for ext in self.extensions:
    274287                need_to_compile, p = self.prepare_extension(ext)
    275288                if need_to_compile:
    276289                    extensions_to_compile.append(p)
    277290
     291            # If there were any extensions that needed to be
     292            # rebuilt, dispatch them using pyprocessing.
    278293            if extensions_to_compile:
    279294               from processing import Pool
    280295               p = Pool(min(ncpus, len(extensions_to_compile)))