VS2005使用distutils模块自动编译python扩展模块

本文介绍了一项针对msvccompiler.py的修改方案,以确保其能在Visual Studio 2005环境中正常运行。修改涉及.NET框架路径设置及环境变量获取方式的变化,特别为VS2005提供了定制化的解决方案。

应该修改msvccompiler.py,使得兼容vs2005:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1425482&group_id=5470

--- msvccompiler_ori.py Sun Aug  7 17:50:38 2005
+++ msvccompiler_mod.py Mon Feb  6 13:10:40 2006
@@ -126,7 +126,10 @@
         self.set_macro("FrameworkDir", net, "installroot")
         try:
             if version > 7.0:
-                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
+    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: #
@@ -552,10 +555,24 @@
         Return a list of strings.  The list will be empty if unable to
         access the registry or appropriate registry keys not found.
         """
-
         if not _can_read_reg:
             return []
 
+        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:
             key = (r"%s/%0.1f/VC/VC_OBJECTS_PLATFORM_INFO/Win32/Directories"

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值