Version 4 (modified by patrickkidd, 5 years ago)

--

I recently received a request to get my rtmidi module working on windows, so i decided to try. The first problem I ran into was distutils complaining about not being set up to use the same compiler that python was built with. Considering I built my own python for work, I knew something was wrong. A little searching led me to the following patch by beaudrym:

Original python issue:  http://bugs.python.org/issue1425482

--- msvccompiler_orig.py	2007-04-01 12:29:48.000000000 -0800
+++ msvccompiler.py	2008-09-10 00:53:53.467400000 -0800
@@ -126,7 +126,11 @@
         self.set_macro("FrameworkDir", net, "installroot")
         try:
             if version > 7.0:
-                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
+                # pks
+				try:
+					self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
+				except KeyError:
+					self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv2.0")
             else:
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
         except KeyError, exc: #
@@ -288,10 +292,17 @@
 
         self.preprocess_options = None
         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']
+            if get_build_version() > 7:
+                self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/EHsc' ,
+                                         '/DNDEBUG']
+                self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/EHsc',
+                                              '/Z7', '/D_DEBUG']
+            else:
+                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-' ,
@@ -609,6 +620,22 @@
 
         if not _can_read_reg:
             return []
+            
+		#pks
+        if self.__version >= 8:
+			
+			# With .NET 8.0, the environment variables are not stored in the 
+			# registry anymore.  They are stored in a platform specific file
+			# under C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages\
+			# Instead of parsing these files (which I don't know how to do),
+			# we simply rely on the fact that the python script is being 
+			# called from a "Visual Studio 2005 Command Prompt".  In these
+			# consoles, the environment variables are properly defined.
+			
+			real_path = path
+			if path == "library":
+				real_path = "lib";
+			return string.split(os.environ[real_path], ";")            
 
         path = path + " dirs"
         if self.__version >= 7:

Attachments