From c9b232aa265a6854a2d9b16fc064eb336f450234 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Fri, 18 Jun 2021 22:58:14 +1000 Subject: [PATCH] remove automatic retrieval py path from PATH or via where.exe --- Flow.Launcher.Core/Plugin/PluginsLoader.cs | 58 ---------------------- 1 file changed, 58 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginsLoader.cs b/Flow.Launcher.Core/Plugin/PluginsLoader.cs index 87abc9e36..5d9b987f1 100644 --- a/Flow.Launcher.Core/Plugin/PluginsLoader.cs +++ b/Flow.Launcher.Core/Plugin/PluginsLoader.cs @@ -18,8 +18,6 @@ namespace Flow.Launcher.Core.Plugin { public static class PluginsLoader { - public const string PATH = "PATH"; - public const string Python = "python"; public const string PythonExecutable = "pythonw.exe"; public static List Plugins(List metadatas, PluginsSettings settings) @@ -117,62 +115,6 @@ namespace Flow.Launcher.Core.Plugin if (!source.Any(o => o.Language.ToUpper() == AllowedLanguage.Python)) return new List(); - // Try setting Constant.PythonPath first, either from - // PATH or from the given pythonDirectory - if (string.IsNullOrEmpty(settings.PythonDirectory)) - { - var whereProcess = Process.Start(new ProcessStartInfo - { - FileName = "where.exe", - Arguments = "pythonw", - RedirectStandardOutput = true, - CreateNoWindow = true, - UseShellExecute = false - }); - - var pythonPath = whereProcess?.StandardOutput.ReadToEnd().Trim(); - - if (!string.IsNullOrEmpty(pythonPath)) - { - pythonPath = FilesFolders.GetPreviousExistingDirectory(FilesFolders.LocationExists, pythonPath); - } - - if (string.IsNullOrEmpty(pythonPath)) - { - var paths = Environment.GetEnvironmentVariable(PATH); - - pythonPath = paths? - .Split(';') - .FirstOrDefault(p => p.ToLower().Contains(Python)); - } - - if (!string.IsNullOrEmpty(pythonPath)) - { - Constant.PythonPath = Path.Combine(pythonPath, PythonExecutable); - settings.PythonDirectory = - FilesFolders.GetPreviousExistingDirectory(FilesFolders.LocationExists, Constant.PythonPath); - } - else - { - Log.Error("PluginsLoader", - "Failed to set Python path despite the environment variable PATH is found", - "PythonPlugins"); - } - } - else - { - var path = Path.Combine(settings.PythonDirectory, PythonExecutable); - if (File.Exists(path)) - { - Constant.PythonPath = path; - } - else - { - Log.Error("PluginsLoader", $"Tried to automatically set from Settings.PythonDirectory " + - $"but can't find python executable in {path}", "PythonPlugins"); - } - } - if (string.IsNullOrEmpty(settings.PythonDirectory)) { if (MessageBox.Show("Flow detected you have installed Python plugins, " +