99import sys , os , re
1010from warnings import warn
1111
12+ from sysconfig import get_platform
13+
1214from distutils .core import Command
13- from distutils .errors import (CCompilerError , DistutilsError , CompileError ,
14- DistutilsSetupError , DistutilsPlatformError )
15- from distutils .sysconfig import customize_compiler , get_python_version
15+ from distutils .errors import *
16+ from distutils .ccompiler import customize_compiler
1617from distutils .dep_util import newer_group
1718from distutils .extension import Extension
18- from distutils . util import get_platform
19+
1920from distutils import log
2021
2122# this keeps compatibility from 2.3 to 2.5
@@ -172,8 +173,7 @@ def initialize_options(self):
172173 self .user = None
173174
174175 def finalize_options (self ):
175- from distutils import sysconfig
176-
176+ _sysconfig = __import__ ('sysconfig' )
177177 self .set_undefined_options ('build' ,
178178 ('build_lib' , 'build_lib' ),
179179 ('build_temp' , 'build_temp' ),
@@ -190,8 +190,8 @@ def finalize_options(self):
190190
191191 # Make sure Python's include directories (for Python.h, pyconfig.h,
192192 # etc.) are in the include search path.
193- py_include = sysconfig . get_python_inc ( )
194- plat_py_include = sysconfig . get_python_inc ( plat_specific = 1 )
193+ py_include = _sysconfig . get_path ( 'include' )
194+ plat_py_include = _sysconfig . get_path ( 'platinclude' )
195195 if self .include_dirs is None :
196196 self .include_dirs = self .distribution .include_dirs or []
197197 if isinstance (self .include_dirs , str ):
@@ -269,21 +269,21 @@ def finalize_options(self):
269269 if sys .executable .startswith (os .path .join (sys .exec_prefix , "bin" )):
270270 # building third party extensions
271271 self .library_dirs .append (os .path .join (sys .prefix , "lib" ,
272- "python" + get_python_version (),
272+ "python" + _sysconfig . get_python_version (),
273273 "config" ))
274274 else :
275275 # building python standard extensions
276276 self .library_dirs .append ('.' )
277277
278278 # for extensions under Linux or Solaris with a shared Python library,
279279 # Python's library directory must be appended to library_dirs
280- sysconfig .get_config_var ('Py_ENABLE_SHARED' )
280+ _sysconfig .get_config_var ('Py_ENABLE_SHARED' )
281281 if ((sys .platform .startswith ('linux' ) or sys .platform .startswith ('gnu' )
282282 or sys .platform .startswith ('sunos' ))
283- and sysconfig .get_config_var ('Py_ENABLE_SHARED' )):
283+ and _sysconfig .get_config_var ('Py_ENABLE_SHARED' )):
284284 if sys .executable .startswith (os .path .join (sys .exec_prefix , "bin" )):
285285 # building third party extensions
286- self .library_dirs .append (sysconfig .get_config_var ('LIBDIR' ))
286+ self .library_dirs .append (_sysconfig .get_config_var ('LIBDIR' ))
287287 else :
288288 # building python standard extensions
289289 self .library_dirs .append ('.' )
@@ -712,13 +712,13 @@ def get_ext_filename(self, ext_name):
712712 of the file from which it will be loaded (eg. "foo/bar.so", or
713713 "foo\bar.pyd").
714714 """
715- from distutils . sysconfig import get_config_var
715+ _sysconfig = __import__ ( 'sysconfig' )
716716 ext_path = ext_name .split ('.' )
717717 # OS/2 has an 8 character module (extension) limit :-(
718718 if os .name == "os2" :
719719 ext_path [len (ext_path ) - 1 ] = ext_path [len (ext_path ) - 1 ][:8 ]
720720 # extensions in debug_mode are named 'module_d.pyd' under windows
721- so_ext = get_config_var ('SO' )
721+ so_ext = _sysconfig . get_config_var ('SO' )
722722 if os .name == 'nt' and self .debug :
723723 return os .path .join (* ext_path ) + '_d' + so_ext
724724 return os .path .join (* ext_path ) + so_ext
@@ -781,8 +781,8 @@ def get_libraries(self, ext):
781781 # Don't use the default code below
782782 return ext .libraries
783783 else :
784- from distutils import sysconfig
785- if sysconfig .get_config_var ('Py_ENABLE_SHARED' ):
784+ _sysconfig = __import__ ( ' sysconfig' )
785+ if _sysconfig .get_config_var ('Py_ENABLE_SHARED' ):
786786 template = "python%d.%d"
787787 pythonlib = (template %
788788 (sys .hexversion >> 24 , (sys .hexversion >> 16 ) & 0xff ))
0 commit comments