コード例 #1
0
ファイル: LaunchConfiguration.cs プロジェクト: zyxws012/PTVS
        public string GetInterpreterPath()
        {
            if (!string.IsNullOrEmpty(InterpreterPath))
            {
                return(InterpreterPath);
            }

            if (_config == null)
            {
                return(null);
            }

            if (PreferWindowedInterpreter && !string.IsNullOrEmpty(_config.GetWindowsInterpreterPath()))
            {
                return(_config.GetWindowsInterpreterPath());
            }

            return(_config.InterpreterPath);
        }
コード例 #2
0
        public string AddConfigurableInterpreter(string name, InterpreterConfiguration config)
        {
            using (_cpythonProvider.Value.SuppressDiscoverFactories()) {
                var collection = CustomInterpreterKey + "\\" + name;
                using (var key = Registry.CurrentUser.CreateSubKey(CustomInterpreterKey, true)) {
                    key.SetValue(DescriptionKey, Strings.CustomEnvironmentLabel);
                }

                using (var key = Registry.CurrentUser.CreateSubKey(collection, true)) {
                    if (config.Architecture != InterpreterArchitecture.Unknown)
                    {
                        key.SetValue(ArchitectureKey, config.Architecture.ToPEP514());
                    }
                    else
                    {
                        key.DeleteValue(ArchitectureKey, false);
                    }
                    if (config.Version != new Version())
                    {
                        key.SetValue(VersionKey, config.Version.ToString());
                    }
                    else
                    {
                        key.DeleteValue(VersionKey, false);
                    }
                    if (!string.IsNullOrEmpty(config.PathEnvironmentVariable))
                    {
                        key.SetValue(PathEnvVarKey, config.PathEnvironmentVariable);
                    }
                    else
                    {
                        key.DeleteValue(PathEnvVarKey, false);
                    }
                    if (!string.IsNullOrEmpty(config.Description))
                    {
                        key.SetValue(DescriptionKey, config.Description);
                    }
                    else
                    {
                        key.DeleteValue(DescriptionKey, false);
                    }

                    var vsConfig = (VisualStudioInterpreterConfiguration)config;
                    using (var installPath = key.CreateSubKey("InstallPath")) {
                        string exePath = config.InterpreterPath ?? vsConfig.WindowsInterpreterPath ?? "";
                        if (!string.IsNullOrEmpty(vsConfig.PrefixPath))
                        {
                            installPath.SetValue("", vsConfig.PrefixPath);
                        }
                        else if (!string.IsNullOrWhiteSpace(exePath))
                        {
                            installPath.SetValue("", Path.GetDirectoryName(exePath));
                        }
                        installPath.SetValue(WindowsPathKey, config.GetWindowsInterpreterPath() ?? string.Empty);
                        installPath.SetValue(PathKey, config.InterpreterPath ?? string.Empty);
                    }
                }
            }

            return(CPythonInterpreterFactoryConstants.GetInterpreterId(CustomCompany, name));
        }
コード例 #3
0
 public static bool IsAvailable(this InterpreterConfiguration configuration)
 {
     return(File.Exists(configuration.InterpreterPath) &&
            File.Exists(configuration.GetWindowsInterpreterPath()));
 }