99Email: <fdrake@acm.org>
1010"""
1111
12+ import _imp
1213import os
1314import re
1415import sys
2223BASE_EXEC_PREFIX = os .path .normpath (sys .base_exec_prefix )
2324
2425# Path to the base directory of the project. On Windows the binary may
25- # live in project/PCBuild9. If we're dealing with an x64 Windows build,
26- # it'll live in project/PCbuild/amd64.
26+ # live in project/PCBuild/win32 or project/PCBuild/amd64.
2727# set for cross builds
2828if "_PYTHON_PROJECT_BASE" in os .environ :
2929 project_base = os .path .abspath (os .environ ["_PYTHON_PROJECT_BASE" ])
3030else :
3131 project_base = os .path .dirname (os .path .abspath (sys .executable ))
32- if os .name == "nt" and "pcbuild" in project_base [- 8 :].lower ():
33- project_base = os .path .abspath (os .path .join (project_base , os .path .pardir ))
34- # PC/VS7.1
35- if os .name == "nt" and "\\ pc\\ v" in project_base [- 10 :].lower ():
36- project_base = os .path .abspath (os .path .join (project_base , os .path .pardir ,
37- os .path .pardir ))
38- # PC/AMD64
39- if os .name == "nt" and "\\ pcbuild\\ amd64" in project_base [- 14 :].lower ():
40- project_base = os .path .abspath (os .path .join (project_base , os .path .pardir ,
41- os .path .pardir ))
32+ if (os .name == 'nt' and
33+ project_base .lower ().endswith (('\\ pcbuild\\ win32' , '\\ pcbuild\\ amd64' ))):
34+ project_base = os .path .dirname (os .path .dirname (project_base ))
4235
4336# python_build: (Boolean) if true, we're either building Python or
4437# building an extension with an un-installed Python, so we use
@@ -51,11 +44,9 @@ def _is_python_source_dir(d):
5144 return True
5245 return False
5346_sys_home = getattr (sys , '_home' , None )
54- if _sys_home and os .name == 'nt' and \
55- _sys_home .lower ().endswith (('pcbuild' , 'pcbuild\\ amd64' )):
56- _sys_home = os .path .dirname (_sys_home )
57- if _sys_home .endswith ('pcbuild' ): # must be amd64
58- _sys_home = os .path .dirname (_sys_home )
47+ if (_sys_home and os .name == 'nt' and
48+ _sys_home .lower ().endswith (('\\ pcbuild\\ win32' , '\\ pcbuild\\ amd64' ))):
49+ _sys_home = os .path .dirname (os .path .dirname (_sys_home ))
5950def _python_build ():
6051 if _sys_home :
6152 return _is_python_source_dir (_sys_home )
@@ -468,7 +459,7 @@ def _init_nt():
468459 # XXX hmmm.. a normal install puts include files here
469460 g ['INCLUDEPY' ] = get_python_inc (plat_specific = 0 )
470461
471- g ['EXT_SUFFIX' ] = '.pyd'
462+ g ['EXT_SUFFIX' ] = _imp . extension_suffixes ()[ 0 ]
472463 g ['EXE' ] = ".exe"
473464 g ['VERSION' ] = get_python_version ().replace ("." , "" )
474465 g ['BINDIR' ] = os .path .dirname (os .path .abspath (sys .executable ))
0 commit comments