9
9
10
10
"""
11
11
12
+ import _imp
12
13
import os
13
14
import re
14
15
import sys
22
23
BASE_EXEC_PREFIX = os .path .normpath (sys .base_exec_prefix )
23
24
24
25
# 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.
27
27
# set for cross builds
28
28
if "_PYTHON_PROJECT_BASE" in os .environ :
29
29
project_base = os .path .abspath (os .environ ["_PYTHON_PROJECT_BASE" ])
30
30
else :
31
31
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 ))
42
35
43
36
# python_build: (Boolean) if true, we're either building Python or
44
37
# building an extension with an un-installed Python, so we use
@@ -51,11 +44,9 @@ def _is_python_source_dir(d):
51
44
return True
52
45
return False
53
46
_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 ))
59
50
def _python_build ():
60
51
if _sys_home :
61
52
return _is_python_source_dir (_sys_home )
@@ -468,7 +459,7 @@ def _init_nt():
468
459
# XXX hmmm.. a normal install puts include files here
469
460
g ['INCLUDEPY' ] = get_python_inc (plat_specific = 0 )
470
461
471
- g ['EXT_SUFFIX' ] = '.pyd'
462
+ g ['EXT_SUFFIX' ] = _imp . extension_suffixes ()[ 0 ]
472
463
g ['EXE' ] = ".exe"
473
464
g ['VERSION' ] = get_python_version ().replace ("." , "" )
474
465
g ['BINDIR' ] = os .path .dirname (os .path .abspath (sys .executable ))
0 commit comments