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
16 changes: 8 additions & 8 deletions src/managers/builtin/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Disposable, LogOutputChannel } from 'vscode';
import { PythonEnvironmentApi } from '../../api';
import { SysPythonManager } from './sysPythonManager';
import { PipPackageManager } from './pipManager';
import { VenvManager } from './venvManager';
import { createSimpleDebounce } from '../../common/utils/debounce';
import { onDidEndTerminalShellExecution } from '../../common/window.apis';
import { createFileSystemWatcher, onDidDeleteFiles } from '../../common/workspace.apis';
import { getPythonApi } from '../../features/pythonApi';
import { NativePythonFinder } from '../common/nativePythonFinder';
import { UvProjectCreator } from './uvProjectCreator';
import { isUvInstalled } from './helpers';
import { createFileSystemWatcher, onDidDeleteFiles } from '../../common/workspace.apis';
import { createSimpleDebounce } from '../../common/utils/debounce';
import { onDidEndTerminalShellExecution } from '../../common/window.apis';
import { PipPackageManager } from './pipManager';
import { isPipInstallCommand } from './pipUtils';
import { SysPythonManager } from './sysPythonManager';
import { UvProjectCreator } from './uvProjectCreator';
import { VenvManager } from './venvManager';

export async function registerSystemPythonFeatures(
nativeFinder: NativePythonFinder,
Expand All @@ -31,7 +31,7 @@ export async function registerSystemPythonFeatures(
const venvDebouncedRefresh = createSimpleDebounce(500, () => {
venvManager.watcherRefresh();
});
const watcher = createFileSystemWatcher('{**/pyenv.cfg,**/bin/python,**/python.exe}', false, true, false);
const watcher = createFileSystemWatcher('{**/activate}', false, true, false);
disposables.push(
watcher,
watcher.onDidCreate(() => {
Expand Down
68 changes: 33 additions & 35 deletions src/managers/builtin/venvUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as fsapi from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import { l10n, LogOutputChannel, ProgressLocation, QuickPickItem, QuickPickItemKind, ThemeIcon, Uri } from 'vscode';
import {
EnvironmentManager,
Expand All @@ -6,36 +9,33 @@ import {
PythonEnvironmentApi,
PythonEnvironmentInfo,
} from '../../api';
import * as path from 'path';
import * as os from 'os';
import * as fsapi from 'fs-extra';
import { resolveSystemPythonEnvironmentPath } from './utils';
import { ENVS_EXTENSION_ID } from '../../common/constants';
import { Common, VenvManagerStrings } from '../../common/localize';
import { getWorkspacePersistentState } from '../../common/persistentState';
import { pickEnvironmentFrom } from '../../common/pickers/environments';
import { EventNames } from '../../common/telemetry/constants';
import { sendTelemetryEvent } from '../../common/telemetry/sender';
import { isWindows } from '../../common/utils/platformUtils';
import {
showErrorMessage,
showInputBox,
showOpenDialog,
showQuickPick,
showWarningMessage,
withProgress,
} from '../../common/window.apis';
import { getConfiguration } from '../../common/workspace.apis';
import { ShellConstants } from '../../features/common/shellConstants';
import {
isNativeEnvInfo,
NativeEnvInfo,
NativePythonEnvironmentKind,
NativePythonFinder,
} from '../common/nativePythonFinder';
import { getWorkspacePersistentState } from '../../common/persistentState';
import { shortVersion, sortEnvironments } from '../common/utils';
import { getConfiguration } from '../../common/workspace.apis';
import { pickEnvironmentFrom } from '../../common/pickers/environments';
import {
showQuickPick,
withProgress,
showWarningMessage,
showInputBox,
showOpenDialog,
showErrorMessage,
} from '../../common/window.apis';
import { Common, VenvManagerStrings } from '../../common/localize';
import { isUvInstalled, runUV, runPython } from './helpers';
import { isUvInstalled, runPython, runUV } from './helpers';
import { getProjectInstallable, getWorkspacePackagesToInstall, PipPackages } from './pipUtils';
import { isWindows } from '../../common/utils/platformUtils';
import { sendTelemetryEvent } from '../../common/telemetry/sender';
import { EventNames } from '../../common/telemetry/constants';
import { ShellConstants } from '../../features/common/shellConstants';
import { resolveSystemPythonEnvironmentPath } from './utils';

export const VENV_WORKSPACE_KEY = `${ENVS_EXTENSION_ID}:venv:WORKSPACE_SELECTED`;
export const VENV_GLOBAL_KEY = `${ENVS_EXTENSION_ID}:venv:GLOBAL_SELECTED`;
Expand Down Expand Up @@ -136,24 +136,22 @@ async function getPythonInfo(env: NativeEnvInfo): Promise<PythonEnvironmentInfo>
shellDeactivation.set('unknown', [{ executable: 'deactivate' }]);
}

if (await fsapi.pathExists(path.join(binDir, 'activate'))) {
shellActivation.set(ShellConstants.SH, [{ executable: 'source', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.SH, [{ executable: 'deactivate' }]);
shellActivation.set(ShellConstants.SH, [{ executable: 'source', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.SH, [{ executable: 'deactivate' }]);

shellActivation.set(ShellConstants.BASH, [{ executable: 'source', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.BASH, [{ executable: 'deactivate' }]);
shellActivation.set(ShellConstants.BASH, [{ executable: 'source', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.BASH, [{ executable: 'deactivate' }]);

shellActivation.set(ShellConstants.GITBASH, [
{ executable: 'source', args: [pathForGitBash(path.join(binDir, `activate`))] },
]);
shellDeactivation.set(ShellConstants.GITBASH, [{ executable: 'deactivate' }]);
shellActivation.set(ShellConstants.GITBASH, [
{ executable: 'source', args: [pathForGitBash(path.join(binDir, `activate`))] },
]);
shellDeactivation.set(ShellConstants.GITBASH, [{ executable: 'deactivate' }]);

shellActivation.set(ShellConstants.ZSH, [{ executable: 'source', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.ZSH, [{ executable: 'deactivate' }]);
shellActivation.set(ShellConstants.ZSH, [{ executable: 'source', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.ZSH, [{ executable: 'deactivate' }]);

shellActivation.set(ShellConstants.KSH, [{ executable: '.', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.KSH, [{ executable: 'deactivate' }]);
}
shellActivation.set(ShellConstants.KSH, [{ executable: '.', args: [path.join(binDir, `activate`)] }]);
shellDeactivation.set(ShellConstants.KSH, [{ executable: 'deactivate' }]);

if (await fsapi.pathExists(path.join(binDir, 'Activate.ps1'))) {
shellActivation.set(ShellConstants.PWSH, [{ executable: '&', args: [path.join(binDir, `Activate.ps1`)] }]);
Expand Down