Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/common/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ export namespace PyenvStrings {
export const pyenvRefreshing = l10n.t('Refreshing Pyenv Python versions');
}

export namespace PipenvStrings {
export const pipenvManager = l10n.t('Manages Pipenv environments');
export const pipenvDiscovering = l10n.t('Discovering Pipenv environments');
export const pipenvRefreshing = l10n.t('Refreshing Pipenv environments');
}

export namespace PoetryStrings {
export const poetryManager = l10n.t('Manages Poetry environments');
export const poetryDiscovering = l10n.t('Discovering Poetry environments');
Expand Down
27 changes: 27 additions & 0 deletions src/managers/pipenv/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Disposable } from 'vscode';
import { PythonEnvironmentApi } from '../../api';
import { traceInfo } from '../../common/logging';
import { getPythonApi } from '../../features/pythonApi';
import { NativePythonFinder } from '../common/nativePythonFinder';
import { PipenvManager } from './pipenvManager';
import { getPipenv } from './pipenvUtils';

export async function registerPipenvFeatures(
nativeFinder: NativePythonFinder,
disposables: Disposable[],
): Promise<void> {
const api: PythonEnvironmentApi = await getPythonApi();

try {
const pipenv = await getPipenv(nativeFinder);

if (pipenv) {
const mgr = new PipenvManager(nativeFinder, api);
disposables.push(mgr, api.registerEnvironmentManager(mgr));
} else {
traceInfo('Pipenv not found, turning off pipenv features.');
}
} catch (ex) {
traceInfo('Pipenv not found, turning off pipenv features.', ex);
}
}
93 changes: 93 additions & 0 deletions src/managers/pipenv/pipenvManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { EventEmitter, MarkdownString } from 'vscode';
import {
CreateEnvironmentOptions,
CreateEnvironmentScope,
DidChangeEnvironmentEventArgs,
DidChangeEnvironmentsEventArgs,
EnvironmentManager,
GetEnvironmentScope,
GetEnvironmentsScope,
IconPath,
PythonEnvironment,
PythonEnvironmentApi,
QuickCreateConfig,
RefreshEnvironmentsScope,
ResolveEnvironmentContext,
SetEnvironmentScope,
} from '../../api';
import { PipenvStrings } from '../../common/localize';
import { NativePythonFinder } from '../common/nativePythonFinder';

export class PipenvManager implements EnvironmentManager {
private collection: PythonEnvironment[] = [];

Check failure on line 22 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (windows-latest)

'collection' is declared but its value is never read.

Check failure on line 22 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (ubuntu-latest)

'collection' is declared but its value is never read.
private fsPathToEnv: Map<string, PythonEnvironment> = new Map();
private globalEnv: PythonEnvironment | undefined;

Check failure on line 24 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (windows-latest)

'globalEnv' is declared but its value is never read.

Check failure on line 24 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (ubuntu-latest)

'globalEnv' is declared but its value is never read.

private readonly _onDidChangeEnvironment = new EventEmitter<DidChangeEnvironmentEventArgs>();
public readonly onDidChangeEnvironment = this._onDidChangeEnvironment.event;

private readonly _onDidChangeEnvironments = new EventEmitter<DidChangeEnvironmentsEventArgs>();
public readonly onDidChangeEnvironments = this._onDidChangeEnvironments.event;
constructor(private readonly nativeFinder: NativePythonFinder, private readonly api: PythonEnvironmentApi) {

Check failure on line 31 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (windows-latest)

Property 'api' is declared but its value is never read.

Check failure on line 31 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (windows-latest)

Property 'nativeFinder' is declared but its value is never read.

Check failure on line 31 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (ubuntu-latest)

Property 'api' is declared but its value is never read.

Check failure on line 31 in src/managers/pipenv/pipenvManager.ts

View workflow job for this annotation

GitHub Actions / TypeScript Unit Tests (ubuntu-latest)

Property 'nativeFinder' is declared but its value is never read.
this.name = 'pipenv';
this.displayName = 'Pipenv';
this.preferredPackageManagerId = 'ms-python.python:pip';
this.tooltip = new MarkdownString(PipenvStrings.pipenvManager, true);
}

name: string;
displayName: string;
preferredPackageManagerId: string;
description?: string;
tooltip: string | MarkdownString;
iconPath?: IconPath;

public dispose() {
this.collection = [];
this.fsPathToEnv.clear();
}

quickCreateConfig?(): QuickCreateConfig | undefined {
// To be implemented
return undefined;
}

async create?(
_scope: CreateEnvironmentScope,
_options?: CreateEnvironmentOptions,
): Promise<PythonEnvironment | undefined> {
// To be implemented
return undefined;
}

async remove?(_environment: PythonEnvironment): Promise<void> {
// To be implemented
}

async refresh(_scope: RefreshEnvironmentsScope): Promise<void> {
// To be implemented
}

async getEnvironments(_scope: GetEnvironmentsScope): Promise<PythonEnvironment[]> {
// To be implemented
return [];
}

async set(_scope: SetEnvironmentScope, _environment?: PythonEnvironment): Promise<void> {
// To be implemented
}

async get(_scope: GetEnvironmentScope): Promise<PythonEnvironment | undefined> {
// To be implemented
return undefined;
}

async resolve(_context: ResolveEnvironmentContext): Promise<PythonEnvironment | undefined> {
// To be implemented
return undefined;
}

async clearCache?(): Promise<void> {
// To be implemented
}
}
11 changes: 11 additions & 0 deletions src/managers/pipenv/pipenvUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Utility functions for Pipenv environment management

import { NativePythonFinder } from '../common/nativePythonFinder';

export class PipenvUtils {
// Add static helper methods for pipenv operations here
}
export async function getPipenv(_native?: NativePythonFinder): Promise<string | undefined> {
// Implementation to find and return the pipenv path
return undefined;
}
Loading