@@ -65,6 +65,9 @@ def get_platform():
6565MACOS = (HOST_PLATFORM == 'darwin' )
6666AIX = (HOST_PLATFORM .startswith ('aix' ))
6767VXWORKS = ('vxworks' in HOST_PLATFORM )
68+ CC = os .environ .get ("CC" )
69+ if not CC :
70+ CC = sysconfig .get_config_var ("CC" )
6871
6972
7073SUMMARY = """
@@ -443,6 +446,9 @@ def set_compiler_executables(self):
443446
444447 def build_extensions (self ):
445448 self .set_srcdir ()
449+ self .set_compiler_executables ()
450+ self .configure_compiler ()
451+ self .init_inc_lib_dirs ()
446452
447453 # Detect which modules should be compiled
448454 self .detect_modules ()
@@ -451,7 +457,6 @@ def build_extensions(self):
451457
452458 self .update_sources_depends ()
453459 mods_built , mods_disabled = self .remove_configured_extensions ()
454- self .set_compiler_executables ()
455460
456461 build_ext .build_extensions (self )
457462
@@ -631,12 +636,11 @@ def check_extension_import(self, ext):
631636 def add_multiarch_paths (self ):
632637 # Debian/Ubuntu multiarch support.
633638 # https://wiki.ubuntu.com/MultiarchSpec
634- cc = sysconfig .get_config_var ('CC' )
635639 tmpfile = os .path .join (self .build_temp , 'multiarch' )
636640 if not os .path .exists (self .build_temp ):
637641 os .makedirs (self .build_temp )
638642 ret = run_command (
639- '%s -print-multiarch > %s 2> /dev/null' % (cc , tmpfile ))
643+ '%s -print-multiarch > %s 2> /dev/null' % (CC , tmpfile ))
640644 multiarch_path_component = ''
641645 try :
642646 if ret == 0 :
@@ -675,11 +679,10 @@ def add_multiarch_paths(self):
675679 os .unlink (tmpfile )
676680
677681 def add_cross_compiling_paths (self ):
678- cc = sysconfig .get_config_var ('CC' )
679682 tmpfile = os .path .join (self .build_temp , 'ccpaths' )
680683 if not os .path .exists (self .build_temp ):
681684 os .makedirs (self .build_temp )
682- ret = run_command ('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc , tmpfile ))
685+ ret = run_command ('%s -E -v - </dev/null 2>%s 1>/dev/null' % (CC , tmpfile ))
683686 is_gcc = False
684687 is_clang = False
685688 in_incdirs = False
@@ -1783,9 +1786,6 @@ def detect_uuid(self):
17831786 self .missing .append ('_uuid' )
17841787
17851788 def detect_modules (self ):
1786- self .configure_compiler ()
1787- self .init_inc_lib_dirs ()
1788-
17891789 self .detect_simple_extensions ()
17901790 if TEST_EXTENSIONS :
17911791 self .detect_test_extensions ()
0 commit comments