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); try { version.ToLanguageVersion(); } catch (InvalidOperationException) { version = new Version(0, 0); } 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 VisualStudioInterpreterConfiguration( 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); }
public NotFoundInterpreterFactory( string id, Version version, string description = null, string prefixPath = null, InterpreterArchitecture architecture = default(InterpreterArchitecture), string descriptionSuffix = null) { Configuration = new VisualStudioInterpreterConfiguration( id, description ?? "Unknown Python {0}{1: ()} (unavailable)".FormatUI(version, architecture), prefixPath, null, null, null, architecture, version, InterpreterUIMode.CannotBeDefault | InterpreterUIMode.CannotBeConfigured ); }
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 VisualStudioInterpreterConfiguration( 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); }