Skip to content

Commit 284ab14

Browse files
committed
Revert "Ensure isolate script is passed as command arg when installing modules (microsoft#11447)"
This reverts commit b2a0b59.
1 parent c932e8a commit 284ab14

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

src/client/common/installer/moduleInstaller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
4545
? await interpreterService.getActiveInterpreter(resource)
4646
: resource;
4747
const pythonPath = isResource(resource) ? settings.pythonPath : resource.path;
48-
const args = internalPython.execModule(executionInfo.moduleName, executionInfoArgs, true, true);
48+
const args = internalPython.execModule(executionInfo.moduleName, executionInfoArgs);
4949
if (!interpreter || interpreter.type !== InterpreterType.Unknown) {
5050
await terminalService.sendCommand(pythonPath, args, token);
5151
} else if (settings.globalModuleInstallation) {

src/client/common/process/internal/python.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import '../../extensions';
54
import { _ISOLATED as ISOLATED } from './scripts';
65

76
// "python" contains functions corresponding to the various ways that
@@ -26,15 +25,10 @@ export function execCode(code: string, isolated = true): string[] {
2625
return args;
2726
}
2827

29-
export function execModule(
30-
name: string,
31-
moduleArgs: string[],
32-
isolated = true,
33-
useAsCommandArgument = false
34-
): string[] {
28+
export function execModule(name: string, moduleArgs: string[], isolated = true): string[] {
3529
const args = ['-m', name, ...moduleArgs];
3630
if (isolated) {
37-
args[0] = useAsCommandArgument ? ISOLATED.fileToCommandArgument() : ISOLATED; // replace
31+
args[0] = ISOLATED; // replace
3832
}
3933
// "code" isn't specific enough to know how to parse it,
4034
// so we only return the args.

src/client/interpreter/locators/services/currentPathService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ export class CurrentPathService extends CacheableLocatorService {
9393
private async getInterpreter(options: { command: string; args?: string[] }) {
9494
try {
9595
const processService = await this.processServiceFactory.create();
96+
const pyArgs = Array.isArray(options.args) ? options.args : [];
9697
const [args, parse] = internalPython.getExecutable();
97-
const pyArgs = Array.isArray(options.args) ? options.args.concat(args) : args;
9898
return processService
99-
.exec(options.command, pyArgs, {})
99+
.exec(options.command, pyArgs.concat(args), {})
100100
.then((output) => parse(output.stdout))
101101
.then(async (value) => {
102102
if (value.length > 0 && (await this.fs.fileExists(value))) {

src/test/common/installer/moduleInstaller.unit.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from 'vscode';
2323
import { IApplicationShell, IWorkspaceService } from '../../../client/common/application/types';
2424
import { STANDARD_OUTPUT_CHANNEL } from '../../../client/common/constants';
25-
import '../../../client/common/extensions';
2625
import { CondaInstaller } from '../../../client/common/installer/condaInstaller';
2726
import { ModuleInstaller } from '../../../client/common/installer/moduleInstaller';
2827
import { PipEnvInstaller, pipenvName } from '../../../client/common/installer/pipEnvInstaller';
@@ -52,15 +51,13 @@ import {
5251
import { IServiceContainer } from '../../../client/ioc/types';
5352
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../constants';
5453

55-
const isolated = path
56-
.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'pythonFiles', 'pyvsc-run-isolated.py')
57-
.fileToCommandArgument();
54+
const isolated = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'pythonFiles', 'pyvsc-run-isolated.py');
5855

5956
/* Complex test to ensure we cover all combinations:
6057
We could have written separate tests for each installer, but we'd be replicate code.
61-
Both approaches have their benefits.
58+
Both approachs have their benefits.
6259
63-
Combinations of:
60+
Comnbinations of:
6461
1. With and without a workspace.
6562
2. Http Proxy configuration.
6663
3. All products.
@@ -467,7 +464,7 @@ suite('Module Installer', () => {
467464
interpreterService.verifyAll();
468465
terminalService.verifyAll();
469466
});
470-
test(`If 'python.globalModuleInstallation' is not set to true, concatenate arguments with '--user' flag and send command to terminal`, async () => {
467+
test(`If 'python.globalModuleInstallation' is not set to true, concanate arguments with '--user' flag and send command to terminal`, async () => {
471468
const info = TypeMoq.Mock.ofType<PythonInterpreter>();
472469
info.setup((t: any) => t.then).returns(() => undefined);
473470
info.setup((t) => t.type).returns(() => InterpreterType.Unknown);

src/test/common/moduleInstaller.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { ConfigurationService } from '../../client/common/configuration/service'
3737
import { CryptoUtils } from '../../client/common/crypto';
3838
import { EditorUtils } from '../../client/common/editor';
3939
import { ExperimentsManager } from '../../client/common/experiments';
40-
import '../../client/common/extensions';
4140
import { FeatureDeprecationManager } from '../../client/common/featureDeprecationManager';
4241
import {
4342
ExtensionInsidersDailyChannelRule,
@@ -144,9 +143,7 @@ import { closeActiveWindows, initializeTest } from './../initialize';
144143

145144
chai_use(chaiAsPromised);
146145

147-
const isolated = path
148-
.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'pythonFiles', 'pyvsc-run-isolated.py')
149-
.fileToCommandArgument();
146+
const isolated = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'pythonFiles', 'pyvsc-run-isolated.py');
150147

151148
const info: PythonInterpreter = {
152149
architecture: Architecture.Unknown,

0 commit comments

Comments
 (0)