@@ -52,7 +52,7 @@ def wait(self):
5252 elif os .WIFEXITED (status ):
5353 self .returncode = os .WEXITSTATUS (status )
5454 elif os .WIFSTOPPED (status ):
55- self .returncode = - os .WSTOPSIG (sts )
55+ self .returncode = - os .WSTOPSIG (status )
5656 else :
5757 # Should never happen
5858 raise Exception ("Unknown child exit status!" )
@@ -364,16 +364,14 @@ def __init__(self, dist):
364364 def add (self , ext ):
365365 self .extensions .append (ext )
366366
367- def build_extensions (self ):
367+ def set_srcdir (self ):
368368 self .srcdir = sysconfig .get_config_var ('srcdir' )
369369 if not self .srcdir :
370370 # Maybe running on Windows but not using CYGWIN?
371371 raise ValueError ("No source directory; cannot proceed." )
372372 self .srcdir = os .path .abspath (self .srcdir )
373373
374- # Detect which modules should be compiled
375- self .detect_modules ()
376-
374+ def remove_disabled (self ):
377375 # Remove modules that are present on the disabled list
378376 extensions = [ext for ext in self .extensions
379377 if ext .name not in DISABLED_MODULE_LIST ]
@@ -384,6 +382,7 @@ def build_extensions(self):
384382 extensions .append (ctypes )
385383 self .extensions = extensions
386384
385+ def update_sources_depends (self ):
387386 # Fix up the autodetected modules, prefixing all the source files
388387 # with Modules/.
389388 moddirlist = [os .path .join (self .srcdir , 'Modules' )]
@@ -396,14 +395,6 @@ def build_extensions(self):
396395 headers = [sysconfig .get_config_h_filename ()]
397396 headers += glob (os .path .join (sysconfig .get_path ('include' ), "*.h" ))
398397
399- # The sysconfig variables built by makesetup that list the already
400- # built modules and the disabled modules as configured by the Setup
401- # files.
402- sysconf_built = sysconfig .get_config_var ('MODBUILT_NAMES' ).split ()
403- sysconf_dis = sysconfig .get_config_var ('MODDISABLED_NAMES' ).split ()
404-
405- mods_built = []
406- mods_disabled = []
407398 for ext in self .extensions :
408399 ext .sources = [ find_module_file (filename , moddirlist )
409400 for filename in ext .sources ]
@@ -415,6 +406,16 @@ def build_extensions(self):
415406 # re-compile extensions if a header file has been changed
416407 ext .depends .extend (headers )
417408
409+ def remove_configured_extensions (self ):
410+ # The sysconfig variables built by makesetup that list the already
411+ # built modules and the disabled modules as configured by the Setup
412+ # files.
413+ sysconf_built = sysconfig .get_config_var ('MODBUILT_NAMES' ).split ()
414+ sysconf_dis = sysconfig .get_config_var ('MODDISABLED_NAMES' ).split ()
415+
416+ mods_built = []
417+ mods_disabled = []
418+ for ext in self .extensions :
418419 # If a module has already been built or has been disabled in the
419420 # Setup files, don't build it here.
420421 if ext .name in sysconf_built :
@@ -432,6 +433,9 @@ def build_extensions(self):
432433 if os .path .exists (fullpath ):
433434 os .unlink (fullpath )
434435
436+ return (mods_built , mods_disabled )
437+
438+ def set_compiler_executables (self ):
435439 # When you run "make CC=altcc" or something similar, you really want
436440 # those environment variables passed into the setup.py phase. Here's
437441 # a small set of useful ones.
@@ -444,6 +448,18 @@ def build_extensions(self):
444448 args ['compiler_so' ] = compiler + ' ' + ccshared + ' ' + cflags
445449 self .compiler .set_executables (** args )
446450
451+ def build_extensions (self ):
452+ self .set_srcdir ()
453+
454+ # Detect which modules should be compiled
455+ self .detect_modules ()
456+
457+ self .remove_disabled ()
458+
459+ self .update_sources_depends ()
460+ mods_built , mods_disabled = self .remove_configured_extensions ()
461+ self .set_compiler_executables ()
462+
447463 build_ext .build_extensions (self )
448464
449465 if SUBPROCESS_BOOTSTRAP :
@@ -454,6 +470,9 @@ def build_extensions(self):
454470 for ext in self .extensions :
455471 self .check_extension_import (ext )
456472
473+ self .summary (mods_built , mods_disabled )
474+
475+ def summary (self , mods_built , mods_disabled ):
457476 longest = max ([len (e .name ) for e in self .extensions ], default = 0 )
458477 if self .failed or self .failed_on_import :
459478 all_failed = self .failed + self .failed_on_import
0 commit comments