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
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@
"title": "%python-envs.revealProjectInExplorer.title%",
"category": "Python Envs",
"icon": "$(folder-opened)"
},
{
"command": "python-envs.runPetInTerminal",
"title": "%python-envs.runPetInTerminal.title%",
"category": "Python",
"icon": "$(terminal)",
"when": "config.python.useEnvironmentsExtension != false"
}
],
"menus": {
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"python-envs.terminal.activate.title": "Activate Environment in Current Terminal",
"python-envs.terminal.deactivate.title": "Deactivate Environment in Current Terminal",
"python-envs.uninstallPackage.title": "Uninstall Package",
"python-envs.revealProjectInExplorer.title": "Reveal Project in Explorer"
"python-envs.revealProjectInExplorer.title": "Reveal Project in Explorer",
"python-envs.runPetInTerminal.title": "Run Python Environment Tool (PET) in Terminal"
}
21 changes: 20 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createDeferred } from './common/utils/deferred';
import {
activeTerminal,
createLogOutputChannel,
createTerminal,
onDidChangeActiveTerminal,
onDidChangeTerminalShellIntegration,
} from './common/window.apis';
Expand Down Expand Up @@ -66,7 +67,11 @@ import { ProjectItem } from './features/views/treeViewItems';
import { EnvironmentManagers, ProjectCreators, PythonProjectManager } from './internal.api';
import { registerSystemPythonFeatures } from './managers/builtin/main';
import { SysPythonManager } from './managers/builtin/sysPythonManager';
import { createNativePythonFinder, NativePythonFinder } from './managers/common/nativePythonFinder';
import {
createNativePythonFinder,
getNativePythonToolsPath,
NativePythonFinder,
} from './managers/common/nativePythonFinder';
import { IDisposable } from './managers/common/types';
import { registerCondaFeatures } from './managers/conda/main';
import { registerPoetryFeatures } from './managers/poetry/main';
Expand Down Expand Up @@ -429,6 +434,20 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
window.showErrorMessage(`Failed to open issue reporter: ${error}`);
}
}),
commands.registerCommand('python-envs.runPetInTerminal', async () => {
try {
const petPath = await getNativePythonToolsPath();
const terminal = createTerminal({
name: 'Python Environment Tool (PET)',
});
terminal.show();
terminal.sendText(`"${petPath}"`, true);
traceInfo(`Running PET in terminal: ${petPath}`);
} catch (error) {
traceError('Error running PET in terminal', error);
window.showErrorMessage(`Failed to run Python Environment Tool: ${error}`);
}
}),
terminalActivation.onDidChangeTerminalActivationState(async (e) => {
await setActivateMenuButtonContext(e.terminal, e.environment, e.activated);
}),
Expand Down
18 changes: 9 additions & 9 deletions src/managers/common/nativePythonFinder.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import * as ch from 'child_process';
import * as fs from 'fs-extra';
import * as path from 'path';
import { PassThrough } from 'stream';
import { Disposable, ExtensionContext, LogOutputChannel, Uri } from 'vscode';
import * as rpc from 'vscode-jsonrpc/node';
import * as ch from 'child_process';
import { PythonProjectApi } from '../../api';
import { ENVS_EXTENSION_ID, PYTHON_EXTENSION_ID } from '../../common/constants';
import { getExtension } from '../../common/extension.apis';
import { noop } from './utils';
import { Disposable, ExtensionContext, LogOutputChannel, Uri } from 'vscode';
import { PassThrough } from 'stream';
import { PythonProjectApi } from '../../api';
import { getConfiguration } from '../../common/workspace.apis';
import { createRunningWorkerPool, WorkerPool } from '../../common/utils/workerPool';
import { traceVerbose } from '../../common/logging';
import { isWindows } from '../../common/utils/platformUtils';
import { getUserHomeDir, untildify } from '../../common/utils/pathUtils';
import { isWindows } from '../../common/utils/platformUtils';
import { createRunningWorkerPool, WorkerPool } from '../../common/utils/workerPool';
import { getConfiguration } from '../../common/workspace.apis';
import { noop } from './utils';

async function getNativePythonToolsPath(): Promise<string> {
export async function getNativePythonToolsPath(): Promise<string> {
const envsExt = getExtension(ENVS_EXTENSION_ID);
if (envsExt) {
const petPath = path.join(envsExt.extensionPath, 'python-env-tools', 'bin', isWindows() ? 'pet.exe' : 'pet');
Expand Down