Exemplo n.º 1
0
        public void SetInterpreterFactory(IPythonInterpreterFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (!File.Exists(factory.Configuration?.InterpreterPath))
            {
                throw new NotSupportedException();
            }

            _factory = factory;

            _cache = PipPackageCache.GetCache();

            if (_libWatchers != null)
            {
                CreateLibraryWatchers().DoNotWait();
            }

            Task.Delay(100).ContinueWith(async t => {
                try {
                    await UpdateIsReadyAsync(false, CancellationToken.None);
                } catch (OperationCanceledException) {
                } catch (Exception ex) when(!ex.IsCriticalException())
                {
                    Debug.Fail(ex.ToUnhandledExceptionMessage(GetType()));
                }
            }).DoNotWait();
        }
Exemplo n.º 2
0
        public PipPackageManager(
            IPythonInterpreterFactory factory,
            PipPackageManagerCommands commands,
            int priority,
            ICondaLocatorProvider condaLocatorProvider
            )
        {
            _packages = new List <PackageSpec>();
            _pipListHasFormatOption = true;

            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (!File.Exists(factory.Configuration?.InterpreterPath))
            {
                throw new NotSupportedException();
            }

            _factory              = factory;
            _commands             = commands ?? new PipPackageManagerCommands();
            Priority              = priority;
            _condaLocatorProvider = condaLocatorProvider;
            _cache = PipPackageCache.GetCache();
        }
Exemplo n.º 3
0
        public static PipPackageCache GetCache(Uri index = null, string indexName = null) {
            PipPackageCache cache;
            var key = (index ?? DefaultIndex).AbsoluteUri;
            lock (_knownCachesLock) {
                if (!_knownCaches.TryGetValue(key, out cache)) {
                    _knownCaches[key] = cache = new PipPackageCache(
                        index,
                        indexName,
                        GetCachePath(index ?? DefaultIndex, indexName ?? DefaultIndexName)
                    );
                }
                cache._userCount += 1;
            }

            return cache;
        }
Exemplo n.º 4
0
        public void SetInterpreterFactory(IPythonInterpreterFactory factory) {
            if (factory == null) {
                throw new ArgumentNullException(nameof(factory));
            }
            if (!File.Exists(factory.Configuration?.InterpreterPath)) {
                throw new NotSupportedException();
            }

            _factory = factory;

            _cache = PipPackageCache.GetCache();

            if (_libWatchers != null) {
                CreateLibraryWatchers().DoNotWait();
            }
            _refreshIsCurrentTrigger?.Change(1000, Timeout.Infinite);
        }
Exemplo n.º 5
0
        public static PipPackageCache GetCache(Uri index = null, string indexName = null)
        {
            PipPackageCache cache;
            var             key = (index ?? DefaultIndex).AbsoluteUri;

            lock (_knownCachesLock) {
                if (!_knownCaches.TryGetValue(key, out cache))
                {
                    _knownCaches[key] = cache = new PipPackageCache(
                        index,
                        indexName,
                        GetCachePath(index ?? DefaultIndex, indexName ?? DefaultIndexName)
                        );
                }
                cache._userCount += 1;
            }

            return(cache);
        }
Exemplo n.º 6
0
        public void SetInterpreterFactory(IPythonInterpreterFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (!File.Exists(factory.Configuration?.InterpreterPath))
            {
                throw new NotSupportedException();
            }

            _factory = factory;

            _cache = PipPackageCache.GetCache(new Uri("https://pypi.python.org/pypi/"));

            if (_libWatchers != null)
            {
                CreateLibraryWatchers().DoNotWait();
            }
            _refreshIsCurrentTrigger?.Change(1000, Timeout.Infinite);
        }