public CondaEnvironmentFactoryProvider(
     [Import] CPythonInterpreterFactoryProvider globalProvider,
     [Import] ICondaLocatorProvider condaLocatorProvider,
     [Import("Microsoft.VisualStudioTools.MockVsTests.IsMockVs", AllowDefault = true)] object isMockVs = null
     ) : this(globalProvider, condaLocatorProvider, isMockVs == null)
 {
 }
 public CondaEnvironmentFactoryProvider(
     [Import] CPythonInterpreterFactoryProvider globalProvider,
     [Import(typeof(SVsServiceProvider), AllowDefault = true)] IServiceProvider site = null,
     [Import("Microsoft.VisualStudioTools.MockVsTests.IsMockVs", AllowDefault = true)] object isMockVs = null
     ) : this(globalProvider, site, isMockVs == 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 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);
        }
Exemplo n.º 5
0
        public CPythonCondaPackageManagerProvider(
            [Import] CPythonInterpreterFactoryProvider globalProvider
            )
        {
            _globalProvider = globalProvider;

            // This can be slow, if there are 2 or more global conda installations
            // (some conda versions have long startup time), so we only fetch it once.
            _latestCondaExe = new Lazy <string>(() => CondaUtils.GetLatestCondaExecutablePath(_globalProvider.GetInterpreterFactories()));
        }
 public CondaEnvironmentFactoryProvider(
     CPythonInterpreterFactoryProvider globalProvider,
     IServiceProvider site,
     bool watchFileSystem,
     string userProfileFolder = null)
 {
     _site              = site;
     _watchFileSystem   = watchFileSystem;
     _globalProvider    = globalProvider;
     _userProfileFolder = userProfileFolder;
 }
 public CondaEnvironmentFactoryProvider(
     CPythonInterpreterFactoryProvider globalProvider,
     ICondaLocatorProvider condaLocatorProvider,
     bool watchFileSystem,
     string userProfileFolder = null)
 {
     _watchFileSystem      = watchFileSystem;
     _globalProvider       = globalProvider;
     _condaLocatorProvider = condaLocatorProvider;
     _userProfileFolder    = userProfileFolder;
 }
Exemplo n.º 8
0
        public AutoDetectedLatestCondaLocator(
            [Import] CPythonInterpreterFactoryProvider globalProvider,
            [Import(typeof(SVsServiceProvider), AllowDefault = true)] IServiceProvider site = null
            )
        {
            _globalProvider = globalProvider;
            _site           = site;

            // This can be slow, if there are 2 or more global conda installations
            // (some conda versions have long startup time), so we only fetch it once.
            _latestCondaExe = new Lazy <string>(() => GetLatestCondaExecutablePath(_site, _globalProvider.GetInterpreterFactories()));
        }
        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);
        }
 public DiscoverOnDispose(CPythonInterpreterFactoryProvider provider)
 {
     _provider = provider;
     Interlocked.Increment(ref _provider._ignoreNotifications);
 }
Exemplo n.º 11
0
 public DiscoverOnDispose(CPythonInterpreterFactoryProvider provider) {
     _provider = provider;
     Interlocked.Increment(ref _provider._ignoreNotifications);
 }