internal static string NameFromId(string id)
 {
     if (CondaEnvironmentFactoryConstants.TryParseInterpreterId(id, out _, out string name))
     {
         return(name);
     }
     return(null);
 }
        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 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);
        }