private static PythonInterpreterInformation CreateEnvironmentInfo(string prefixPath) { var name = Path.GetFileName(prefixPath); var description = name; var vendor = Strings.CondaEnvironmentDescription; var vendorUrl = string.Empty; var supportUrl = string.Empty; var interpreterPath = Path.Combine(prefixPath, CondaEnvironmentFactoryConstants.ConsoleExecutable); var windowsInterpreterPath = Path.Combine(prefixPath, CondaEnvironmentFactoryConstants.WindowsExecutable); InterpreterArchitecture arch = InterpreterArchitecture.Unknown; Version version = null; if (File.Exists(interpreterPath)) { using (var output = ProcessOutput.RunHiddenAndCapture( interpreterPath, "-c", "import sys; print('%s.%s' % (sys.version_info[0], sys.version_info[1]))" )) { output.Wait(); if (output.ExitCode == 0) { var versionName = output.StandardOutputLines.FirstOrDefault() ?? ""; if (!Version.TryParse(versionName, out version)) { version = null; } } } arch = CPythonInterpreterFactoryProvider.ArchitectureFromExe(interpreterPath); } else { return(null); } var config = new InterpreterConfiguration( CondaEnvironmentFactoryConstants.GetInterpreterId(CondaEnvironmentFactoryProvider.EnvironmentCompanyName, name), description, prefixPath, interpreterPath, windowsInterpreterPath, CondaEnvironmentFactoryConstants.PathEnvironmentVariableName, arch, version ); config.SwitchToFullDescription(); var unique = new PythonInterpreterInformation( config, vendor, vendorUrl, supportUrl ); return(unique); }
private static PythonInterpreterInformation CreateEnvironmentInfo(string interpreterPath) { if (!File.Exists(interpreterPath)) { return(null); } var prefixPath = PrefixFromSysPrefix(interpreterPath); if (prefixPath == null) { return(null); } var arch = CPythonInterpreterFactoryProvider.ArchitectureFromExe(interpreterPath); var version = CPythonInterpreterFactoryProvider.VersionFromSysVersionInfo(interpreterPath); var name = Path.GetFileName(prefixPath); var description = name; var vendor = Strings.WorkspaceEnvironmentDescription; var vendorUrl = string.Empty; var supportUrl = string.Empty; var windowsInterpreterPath = Path.Combine(Path.GetDirectoryName(interpreterPath), WorkspaceInterpreterFactoryConstants.WindowsExecutable); if (!File.Exists(windowsInterpreterPath)) { windowsInterpreterPath = string.Empty; } var config = new InterpreterConfiguration( WorkspaceInterpreterFactoryConstants.GetInterpreterId(WorkspaceInterpreterFactoryConstants.EnvironmentCompanyName, name), description, prefixPath, interpreterPath, windowsInterpreterPath, WorkspaceInterpreterFactoryConstants.PathEnvironmentVariableName, arch, version, InterpreterUIMode.CannotBeDefault | InterpreterUIMode.CannotBeConfigured ); config.SwitchToFullDescription(); var unique = new PythonInterpreterInformation( config, vendor, vendorUrl, supportUrl ); return(unique); }
private static PythonInterpreterInformation CreateEnvironmentInfo(string prefixPath) { var name = Path.GetFileName(prefixPath); var description = name; var vendor = Strings.CondaEnvironmentDescription; var vendorUrl = string.Empty; var supportUrl = string.Empty; var interpreterPath = Path.Combine(prefixPath, CondaEnvironmentFactoryConstants.ConsoleExecutable); var windowsInterpreterPath = Path.Combine(prefixPath, CondaEnvironmentFactoryConstants.WindowsExecutable); if (!File.Exists(interpreterPath)) { return(null); } var arch = CPythonInterpreterFactoryProvider.ArchitectureFromExe(interpreterPath); var version = CPythonInterpreterFactoryProvider.VersionFromSysVersionInfo(interpreterPath); var config = new InterpreterConfiguration( CondaEnvironmentFactoryConstants.GetInterpreterId(CondaEnvironmentFactoryProvider.EnvironmentCompanyName, name), description, prefixPath, interpreterPath, windowsInterpreterPath, CondaEnvironmentFactoryConstants.PathEnvironmentVariableName, arch, version ); config.SwitchToFullDescription(); var unique = new PythonInterpreterInformation( config, vendor, vendorUrl, supportUrl ); return(unique); }