Skip to content

Commit

Permalink
For now do not update the datascience code to use internal.python.*.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Apr 7, 2020
1 parent 7cf1f33 commit b63bb02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
'use strict';

import { inject, injectable } from 'inversify';
import { parse as parseSemVer, SemVer } from 'semver';
import { parse, SemVer } from 'semver';
import { CancellationToken } from 'vscode';
import { IApplicationShell } from '../../common/application/types';
import { Cancellation, createPromiseFromCancellation, wrapCancellationTokens } from '../../common/cancellation';
import { traceWarning } from '../../common/logger';
import * as internalPython from '../../common/process/internal/python';
import { IPythonExecutionFactory } from '../../common/process/types';
import { IInstaller, InstallerResponse, Product } from '../../common/types';
import { Common, DataScience } from '../../common/utils/localize';
Expand Down Expand Up @@ -101,14 +100,16 @@ export class DataViewerDependencyService {
bypassCondaExecution: true
});
try {
const args = internalPython.execCode('import pandas;print(pandas.__version__)');
const result = await launcher.exec(args, { throwOnStdErr: true, token });
const result = await launcher.exec(['-c', 'import pandas;print(pandas.__version__)'], {
throwOnStdErr: true,
token
});
const versionMatch = /^\s*(\d+)\.(\d+)\.(.+)\s*$/.exec(result.stdout);
if (versionMatch && versionMatch.length > 2) {
const major = parseInt(versionMatch[1], 10);
const minor = parseInt(versionMatch[2], 10);
const build = parseInt(versionMatch[3], 10);
return parseSemVer(`${major}.${minor}.${build}`, true) ?? undefined;
return parse(`${major}.${minor}.${build}`, true) ?? undefined;
}
} catch (ex) {
traceWarning('Failed to get version of Pandas to use Data Viewer', ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { IApplicationShell, IWorkspaceService } from '../../../common/applicatio
import { Cancellation, createPromiseFromCancellation, wrapCancellationTokens } from '../../../common/cancellation';
import { traceError, traceInfo, traceWarning } from '../../../common/logger';
import { IFileSystem } from '../../../common/platform/types';
import * as internalPython from '../../../common/process/internal/python';
import {
IProcessService,
IProcessServiceFactory,
Expand Down Expand Up @@ -174,15 +173,15 @@ export class JupyterCommandFinderImpl {
findResult.command = this.commandFactory.createInterpreterCommand(
command,
'jupyter',
internalPython.execModule('jupyter', [command]),
['-m', 'jupyter', command],
interpreter,
isActiveInterpreter
);
} else if (findResult.status === ModuleExistsStatus.Found) {
findResult.command = this.commandFactory.createInterpreterCommand(
command,
command,
internalPython.execModule(command, []),
['-m', command],
interpreter,
isActiveInterpreter
);
Expand Down Expand Up @@ -457,9 +456,7 @@ export class JupyterCommandFinderImpl {
const pythonService = await this.createExecutionService(interpreter);

try {
// prettier-ignore
const [args,] = internalPython.getModuleVersion(moduleName);
const execResult = await pythonService.execModule('jupyter', args, newOptions);
const execResult = await pythonService.execModule('jupyter', [moduleName, '--version'], newOptions);
if (execResult.stderr) {
traceWarning(`${execResult.stderr} for ${interpreter.path}`);
result.error = execResult.stderr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { IApplicationShell } from '../../../common/application/types';
import { Cancellation, createPromiseFromCancellation, wrapCancellationTokens } from '../../../common/cancellation';
import { ProductNames } from '../../../common/installer/productNames';
import { traceError } from '../../../common/logger';
import * as internalPython from '../../../common/process/internal/python';
import { IInstaller, InstallerResponse, Product } from '../../../common/types';
import { Common, DataScience } from '../../../common/utils/localize';
import { noop } from '../../../common/utils/misc';
Expand Down Expand Up @@ -297,7 +296,7 @@ export class JupyterInterpreterDependencyService {
const command = this.commandFactory.createInterpreterCommand(
JupyterCommands.KernelSpecCommand,
'jupyter',
internalPython.execModule('jupyter', ['kernelspec']),
['-m', 'jupyter', 'kernelspec'],
interpreter,
false
);
Expand Down

0 comments on commit b63bb02

Please sign in to comment.