diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-02-20 12:26:58 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-02-20 12:26:58 (GMT) |
commit | de2cde614c91b3f957315446493c97fb58332dd3 (patch) | |
tree | ad809a5d9745e95676b5fffdad80e63c42292c17 /Lib/distutils | |
parent | 71322121d73898ad221132e55aa4511a3b1e407b (diff) | |
download | cpython-de2cde614c91b3f957315446493c97fb58332dd3.zip cpython-de2cde614c91b3f957315446493c97fb58332dd3.tar.gz cpython-de2cde614c91b3f957315446493c97fb58332dd3.tar.bz2 |
Detect Win64 builds.
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/msvccompiler.py | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py index b65e528..aefcf98 100644 --- a/Lib/distutils/msvccompiler.py +++ b/Lib/distutils/msvccompiler.py @@ -172,6 +172,20 @@ def get_build_version(): # else we don't know what version of the compiler this is return None +def get_build_architecture(): + """Return the processor architecture. + + Possible results are "Intel", "Itanium", or "AMD64". + """ + + prefix = " bit (" + i = string.find(sys.version, prefix) + if i == -1: + return "Intel" + j = string.find(sys.version, ")", i) + return sys.version[i+len(prefix):j] + + class MSVCCompiler (CCompiler) : """Concrete class that implements an interface to Microsoft Visual C++, @@ -206,11 +220,19 @@ class MSVCCompiler (CCompiler) : def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() - if self.__version >= 7: - self.__root = r"Software\Microsoft\VisualStudio" - self.__macros = MacroExpander(self.__version) + self.__arch = get_build_architecture() + if self.__arch == "Intel": + # x86 + if self.__version >= 7: + self.__root = r"Software\Microsoft\VisualStudio" + self.__macros = MacroExpander(self.__version) + else: + self.__root = r"Software\Microsoft\Devstudio" + self.__product = "Visual Studio version %s" % self.__version else: - self.__root = r"Software\Microsoft\Devstudio" + # Win64. Assume this was built with the platform SDK + self.__product = "Microsoft SDK compiler %s" % (self.__version + 6) + self.initialized = False def initialize(self): @@ -228,9 +250,9 @@ class MSVCCompiler (CCompiler) : if len (self.__paths) == 0: raise DistutilsPlatformError, \ - ("Python was built with version %s of Visual Studio, " + ("Python was built with %s, " "and extensions need to be built with the same " - "version of the compiler, but it isn't installed." % self.__version) + "version of the compiler, but it isn't installed." % self.__product) self.cc = self.find_exe("cl.exe") self.linker = self.find_exe("link.exe") @@ -249,10 +271,17 @@ class MSVCCompiler (CCompiler) : os.environ['path'] = string.join(self.__paths, ';') self.preprocess_options = None - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , - '/DNDEBUG'] - self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', - '/Z7', '/D_DEBUG'] + if self.__arch == "Intel": + self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , + '/DNDEBUG'] + self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', + '/Z7', '/D_DEBUG'] + else: + # Win64 + self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , + '/DNDEBUG'] + self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', + '/Z7', '/D_DEBUG'] self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO'] if self.__version >= 7: |