| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,18 +20,30 @@ | |||
| 20 | 20 | PLATFORM = "x64" if architecture()[0] == "64bit" else "x86" | |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | - def _find_msbuild_path(): | ||
| 24 | - """Return full path to msbuild.exe""" | ||
| 23 | + def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False): | ||
| 24 | + """Return full path to one of the microsoft build tools""" | ||
| 25 | 25 | import _winreg | |
| 26 | 26 | ||
| 27 | - hreg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) | ||
| 28 | - try: | ||
| 27 | + if use_windows_sdk: | ||
| 28 | + value_name = "InstallationFolder" | ||
| 29 | + sdk_name = "Windows SDK" | ||
| 30 | + keys_to_check = [ | ||
| 31 | + r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDKWin32Tools", | ||
| 32 | + r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0\WinSDKWin32Tools", | ||
| 33 | + r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A\WinSDKWin32Tools", | ||
| 34 | + ] | ||
| 35 | + else: | ||
| 36 | + value_name = "MSBuildToolsPath" | ||
| 37 | + sdk_name = "MSBuild" | ||
| 29 | 38 | keys_to_check = [ | |
| 30 | 39 | r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0", | |
| 31 | 40 | r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0", | |
| 32 | 41 | r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5", | |
| 33 | 42 | r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\2.0" | |
| 34 | 43 | ] | |
| 44 | + | ||
| 45 | + hreg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) | ||
| 46 | + try: | ||
| 35 | 47 | hkey = None | |
| 36 | 48 | for key in keys_to_check: | |
| 37 | 49 | try: | |
@@ -41,23 +53,26 @@ def _find_msbuild_path(): | |||
| 41 | 53 | pass | |
| 42 | 54 | ||
| 43 | 55 | if hkey is None: | |
| 44 | - raise RuntimeError("msbuild.exe could not be found") | ||
| 56 | + raise RuntimeError("%s could not be found" % sdk_name) | ||
| 45 | 57 | ||
| 46 | 58 | try: | |
| 47 | - val, type_ = _winreg.QueryValueEx(hkey, "MSBuildToolsPath") | ||
| 59 | + val, type_ = _winreg.QueryValueEx(hkey, value_name) | ||
| 48 | 60 | if type_ != _winreg.REG_SZ: | |
| 49 | - raise RuntimeError("msbuild.exe could not be found") | ||
| 61 | + raise RuntimeError("%s could not be found" % sdk_name) | ||
| 62 | + | ||
| 63 | + path = os.path.join(val, tool) | ||
| 64 | + if os.path.exists(path): | ||
| 65 | + return path | ||
| 50 | 66 | finally: | |
| 51 | 67 | hkey.Close() | |
| 52 | 68 | finally: | |
| 53 | 69 | hreg.Close() | |
| 54 | 70 | ||
| 55 | - msbuildpath = os.path.join(val, "msbuild.exe") | ||
| 56 | - return msbuildpath | ||
| 57 | - | ||
| 71 | + raise RuntimeError("%s could not be found" % tool) | ||
| 72 | + | ||
| 58 | 73 | ||
| 59 | 74 | if DEVTOOLS == "MsDev": | |
| 60 | - _xbuild = "\"%s\"" % _find_msbuild_path() | ||
| 75 | + _xbuild = "\"%s\"" % _find_msbuild_tool("msbuild.exe") | ||
| 61 | 76 | _defines_sep = ";" | |
| 62 | 77 | _config = "%sWin" % CONFIG | |
| 63 | 78 | _npython_exe = "nPython.exe" | |
@@ -107,6 +122,10 @@ def build_extension(self, ext): | |||
| 107 | 122 | "/verbosity:%s" % VERBOSITY, | |
| 108 | 123 | ] | |
| 109 | 124 | ||
| 125 | + manifest = self._get_manifest(dest_dir) | ||
| 126 | + if manifest: | ||
| 127 | + cmd.append("/p:PythonManifest=\"%s\"" % manifest) | ||
| 128 | + | ||
| 110 | 129 | self.announce("Building: %s" % " ".join(cmd)) | |
| 111 | 130 | use_shell = True if DEVTOOLS == "Mono" else False | |
| 112 | 131 | check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell) | |
@@ -116,6 +135,16 @@ def build_extension(self, ext): | |||
| 116 | 135 | self._build_monoclr(ext) | |
| 117 | 136 | ||
| 118 | 137 | ||
| 138 | + def _get_manifest(self, build_dir): | ||
| 139 | + if DEVTOOLS == "MsDev" and sys.version_info[:2] > (2,5): | ||
| 140 | + mt = _find_msbuild_tool("mt.exe", use_windows_sdk=True) | ||
| 141 | + manifest = os.path.abspath(os.path.join(build_dir, "app.manifest")) | ||
| 142 | + cmd = [mt, '-inputresource:"%s"' % sys.executable, '-out:"%s"' % manifest] | ||
| 143 | + self.announce("Extracting manifest from %s" % sys.executable) | ||
| 144 | + check_call(" ".join(cmd), shell=False) | ||
| 145 | + return manifest | ||
| 146 | + | ||
| 147 | + | ||
| 119 | 148 | def _build_monoclr(self, ext): | |
| 120 | 149 | mono_libs = _check_output("pkg-config --libs mono-2", shell=True) | |
| 121 | 150 | mono_cflags = _check_output("pkg-config --cflags mono-2", shell=True) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,6 +180,9 @@ | |||
| 180 | 180 | <WarningLevel>4</WarningLevel> | |
| 181 | 181 | <Optimize>False</Optimize> | |
| 182 | 182 | </PropertyGroup> | |
| 183 | + <PropertyGroup Condition="'$(PythonManifest)' != ''"> | ||
| 184 | + <ApplicationManifest>$(PythonManifest)</ApplicationManifest> | ||
| 185 | + </PropertyGroup> | ||
| 183 | 186 | <ItemGroup> | |
| 184 | 187 | <Reference Include="System" /> | |
| 185 | 188 | <Reference Include="System.Core"> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments