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
@@ -173,8 +174,7 @@ def initialize_options(self):
173174 self .user = None
174175
175176 def finalize_options (self ):
176- from distutils import sysconfig
177-
177+ _sysconfig = __import__ ('sysconfig' )
178178 self .set_undefined_options ('build' ,
179179 ('build_lib' , 'build_lib' ),
180180 ('build_temp' , 'build_temp' ),
@@ -191,8 +191,8 @@ def finalize_options(self):
191191
192192 # Make sure Python's include directories (for Python.h, pyconfig.h,
193193 # etc.) are in the include search path.
194- py_include = sysconfig . get_python_inc ( )
195- plat_py_include = sysconfig . get_python_inc ( plat_specific = 1 )
194+ py_include = _sysconfig . get_path ( 'include' )
195+ plat_py_include = _sysconfig . get_path ( 'platinclude' )
196196 if self .include_dirs is None :
197197 self .include_dirs = self .distribution .include_dirs or []
198198 if isinstance (self .include_dirs , str ):
@@ -270,21 +270,21 @@ def finalize_options(self):
270270 if sys .executable .startswith (os .path .join (sys .exec_prefix , "bin" )):
271271 # building third party extensions
272272 self .library_dirs .append (os .path .join (sys .prefix , "lib" ,
273- "python" + get_python_version (),
273+ "python" + _sysconfig . get_python_version (),
274274 "config" ))
275275 else :
276276 # building python standard extensions
277277 self .library_dirs .append ('.' )
278278
279279 # for extensions under Linux or Solaris with a shared Python library,
280280 # Python's library directory must be appended to library_dirs
281- sysconfig .get_config_var ('Py_ENABLE_SHARED' )
281+ _sysconfig .get_config_var ('Py_ENABLE_SHARED' )
282282 if ((sys .platform .startswith ('linux' ) or sys .platform .startswith ('gnu' )
283283 or sys .platform .startswith ('sunos' ))
284- and sysconfig .get_config_var ('Py_ENABLE_SHARED' )):
284+ and _sysconfig .get_config_var ('Py_ENABLE_SHARED' )):
285285 if sys .executable .startswith (os .path .join (sys .exec_prefix , "bin" )):
286286 # building third party extensions
287- self .library_dirs .append (sysconfig .get_config_var ('LIBDIR' ))
287+ self .library_dirs .append (_sysconfig .get_config_var ('LIBDIR' ))
288288 else :
289289 # building python standard extensions
290290 self .library_dirs .append ('.' )
@@ -719,13 +719,13 @@ def get_ext_filename(self, ext_name):
719719 of the file from which it will be loaded (eg. "foo/bar.so", or
720720 "foo\bar.pyd").
721721 """
722- from distutils . sysconfig import get_config_var
722+ _sysconfig = __import__ ( 'sysconfig' )
723723 ext_path = ext_name .split ('.' )
724724 # OS/2 has an 8 character module (extension) limit :-(
725725 if os .name == "os2" :
726726 ext_path [len (ext_path ) - 1 ] = ext_path [len (ext_path ) - 1 ][:8 ]
727727 # extensions in debug_mode are named 'module_d.pyd' under windows
728- so_ext = get_config_var ('SO' )
728+ so_ext = _sysconfig . get_config_var ('SO' )
729729 if os .name == 'nt' and self .debug :
730730 return os .path .join (* ext_path ) + '_d' + so_ext
731731 return os .path .join (* ext_path ) + so_ext
@@ -785,14 +785,13 @@ def get_libraries(self, ext):
785785 # extensions, it is a reference to the original list
786786 return ext .libraries + [pythonlib ]
787787 elif sys .platform [:6 ] == "atheos" :
788- from distutils import sysconfig
789-
788+ _sysconfig = __import__ ('sysconfig' )
790789 template = "python%d.%d"
791790 pythonlib = (template %
792791 (sys .hexversion >> 24 , (sys .hexversion >> 16 ) & 0xff ))
793792 # Get SHLIBS from Makefile
794793 extra = []
795- for lib in sysconfig .get_config_var ('SHLIBS' ).split ():
794+ for lib in _sysconfig .get_config_var ('SHLIBS' ).split ():
796795 if lib .startswith ('-l' ):
797796 extra .append (lib [2 :])
798797 else :
@@ -806,8 +805,8 @@ def get_libraries(self, ext):
806805 return ext .libraries
807806
808807 else :
809- from distutils import sysconfig
810- if sysconfig .get_config_var ('Py_ENABLE_SHARED' ):
808+ _sysconfig = __import__ ( ' sysconfig' )
809+ if _sysconfig .get_config_var ('Py_ENABLE_SHARED' ):
811810 template = "python%d.%d"
812811 pythonlib = (template %
813812 (sys .hexversion >> 24 , (sys .hexversion >> 16 ) & 0xff ))
0 commit comments