public static void InstallPythonPackage(string PythonPath, string PackagePath) { string packagePath = PackagePath; if (!File.Exists(packagePath)) { packagePath = Path.Combine(Path.GetDirectoryName(WindowsHelpers.GetApplicationPath()), packagePath); if (!File.Exists(packagePath)) { throw new InvalidOperationException(string.Format("Python Package {0} not found", PackagePath)); } } SilentProcess.StdoutDataCapture dataCapture = new SilentProcess.StdoutDataCapture(); SilentProcess process = SilentProcess.StartConsoleProcessSilently( PythonPath, string.Format("-m pip install --no-index {0}", packagePath), dataCapture.DataReceivedHandler ); process.WaitForExit(); if (process.ExitCode != 0) { InstallLogger.Log(dataCapture.GetData()); throw new PythonPackageInstallException(string.Format("Install of package {0} failed", PackagePath)); } }
public static EdkRepoConfig ParseEdkRepoInstallerConfig() { string XmlFilePath = Path.Combine(Path.GetDirectoryName(WindowsHelpers.GetApplicationPath()), InstallerStrings.XmlConfigFileName); if (!File.Exists(XmlFilePath)) { throw new InvalidOperationException(string.Format("Required XML file does not exist: {0}", XmlFilePath)); } return(ParseEdkRepoInstallerConfig(XmlFilePath)); }
private void CloseWindow() { if (UninstallMode && InstallDone) { if (VendorCustomizer.Instance != null) { SilentProcess.StartConsoleProcessSilently( "cmd.exe", string.Format("/c choice /d y /t 3 > nul & del \"{0}\"", VendorCustomizer.VendorPluginPath)); } SilentProcess.StartConsoleProcessSilently( "cmd.exe", string.Format("/c choice /d y /t 3 > nul & del \"{0}\"", WindowsHelpers.GetApplicationPath())); } AllowClose = true; Close(); Environment.ExitCode = ExitCode; }
private static string FindPythonInRegistry(int MajorVersion, int MinorVersion, bool Force32Bit) { CpuArchitecture WindowsArch = WindowsHelpers.GetWindowsOsArchitecture(); RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); RegistryKey pythonRegistryKey = null; if (!Force32Bit || WindowsArch != CpuArchitecture.X64) { pythonRegistryKey = hklm.OpenSubKey(string.Format(@"SOFTWARE\Python\PythonCore\{0}.{1}\InstallPath", MajorVersion, MinorVersion)); } if (pythonRegistryKey == null) { pythonRegistryKey = hklm.OpenSubKey(string.Format(@"SOFTWARE\Wow6432Node\Python\PythonCore\{0}.{1}\InstallPath", MajorVersion, MinorVersion)); if (pythonRegistryKey == null) { pythonRegistryKey = hklm.OpenSubKey(string.Format(@"SOFTWARE\Wow6432Node\Python\PythonCore\{0}.{1}-32\InstallPath", MajorVersion, MinorVersion)); if (pythonRegistryKey == null) { return(null); } } } string executablePath = pythonRegistryKey.GetValue("ExecutablePath") as string; if (executablePath != null) { return(executablePath); } string installPath = pythonRegistryKey.GetValue(null) as string; if (installPath == null) { return(null); } executablePath = Path.Combine(installPath, "python.exe"); if (!File.Exists(executablePath)) { return(null); } return(executablePath); }