Skip to content

Commit 86aee41

Browse files
committed
support for jupyter
1 parent a66a566 commit 86aee41

8 files changed

Lines changed: 1658 additions & 9 deletions

File tree

package.json

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@
102102
"command": "python.execSelectionInTerminal",
103103
"title": "Run Selection in Python Terminal",
104104
"category": "Python"
105+
},
106+
{
107+
"command": "python.jupyter",
108+
"title": "Run in Jupyter Kernel",
109+
"category": "Jupyter"
105110
}
106111
],
107112
"menus": {
@@ -189,10 +194,14 @@
189194
"default": false
190195
},
191196
"console": {
192-
"enum": [ "none", "integratedTerminal", "externalTerminal" ],
193-
"description": "Where to launch the debug target: internal console, integrated terminal, or external terminal.",
194-
"default": "none"
195-
},
197+
"enum": [
198+
"none",
199+
"integratedTerminal",
200+
"externalTerminal"
201+
],
202+
"description": "Where to launch the debug target: internal console, integrated terminal, or external terminal.",
203+
"default": "none"
204+
},
196205
"cwd": {
197206
"type": "string",
198207
"description": "Absolute path to the working directory of the program being debugged. Default is the root directory of the file (leave null).",
@@ -310,7 +319,7 @@
310319
"stopOnEntry": true,
311320
"pythonPath": "${config.python.pythonPath}",
312321
"program": "${file}",
313-
"console": "integratedTerminal",
322+
"console": "integratedTerminal",
314323
"debugOptions": [
315324
"WaitOnAbnormalExit",
316325
"WaitOnNormalExit"
@@ -323,7 +332,7 @@
323332
"stopOnEntry": true,
324333
"pythonPath": "${config.python.pythonPath}",
325334
"program": "${file}",
326-
"console": "externalTerminal",
335+
"console": "externalTerminal",
327336
"debugOptions": [
328337
"WaitOnAbnormalExit",
329338
"WaitOnNormalExit"
@@ -354,8 +363,7 @@
354363
"stopOnEntry": true,
355364
"pythonPath": "${config.python.pythonPath}",
356365
"program": "${workspaceRoot}/run.py",
357-
"args": [
358-
],
366+
"args": [],
359367
"debugOptions": [
360368
"WaitOnAbnormalExit",
361369
"WaitOnNormalExit",
@@ -666,7 +674,9 @@
666674
"python.unitTest.unittestArgs": {
667675
"type": "array",
668676
"description": "Arguments passed in. Each argument is a separate item in the array.",
669-
"default": ["-v"],
677+
"default": [
678+
"-v"
679+
],
670680
"items": {
671681
"type": "string"
672682
}
@@ -700,12 +710,17 @@
700710
"copy-paste": "^1.3.0",
701711
"diff-match-patch": "^1.0.0",
702712
"fs-extra": "^0.30.0",
713+
"jmp": "^0.4.0",
714+
"jupyter-js-services": "^0.18.1",
703715
"line-by-line": "^0.1.4",
716+
"lodash": "^4.15.0",
704717
"named-js-regexp": "^1.3.1",
705718
"prepend-file": "^1.3.0",
719+
"spawnteract": "^2.2.0",
706720
"tmp": "0.0.28",
707721
"tree-kill": "^1.0.0",
708722
"uint64be": "^1.0.1",
723+
"uuid": "^2.0.2",
709724
"vscode-debugadapter": "^1.0.1",
710725
"vscode-debugprotocol": "^1.0.1",
711726
"vscode-extension-telemetry": "0.0.5",

src/client/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import {activateSimplePythonRefactorProvider} from './providers/simpleRefactorPr
2121
import {activateSetInterpreterProvider} from './providers/setInterpreterProvider';
2222
import {activateExecInTerminalProvider} from './providers/execInTerminalProvider'
2323
import * as tests from './unittests/main';
24+
import * as jup from './jupyter/main';
2425

2526
const PYTHON: vscode.DocumentFilter = { language: 'python', scheme: 'file' };
2627
let pythonOutputChannel: vscode.OutputChannel;
2728
let unitTestOutChannel: vscode.OutputChannel;
2829
let formatOutChannel: vscode.OutputChannel;
2930
let lintingOutChannel: vscode.OutputChannel;
31+
let jupMain: jup.Hydrogen;
3032

3133
export function activate(context: vscode.ExtensionContext) {
3234
let rootDir = context.asAbsolutePath('.');
@@ -82,6 +84,12 @@ export function activate(context: vscode.ExtensionContext) {
8284

8385
tests.activate(context, unitTestOutChannel);
8486

87+
jupMain = new jup.Hydrogen();
88+
jupMain.activate(null);
89+
90+
vscode.commands.registerCommand('python.jupyter', () => {
91+
jupMain.run(null);
92+
});
8593
// Possible this extension loads before the others, so lets wait for 5 seconds
8694
setTimeout(disableOtherDocumentSymbolsProvider, 5000);
8795
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// # jupyter-js-services apparently require overriding globals, as explained in its
2+
// # README: https://github.com/jupyter/jupyter-js-services
3+
// # Otherwise, any requests it sends are blocked due to CORS issues
4+
// #
5+
// # This file exists to
6+
// # a) Make sure globals are only ever overridden once
7+
// # b) In the future, try to make the global overrides optional if gateways are
8+
// # not used, or have been pre-configured to avoid CORS issues
9+
10+
const ws = require('ws');
11+
const xhr = require('xmlhttprequest');
12+
const requirejs = require('requirejs');
13+
(global as any).requirejs = requirejs;
14+
(global as any).XMLHttpRequest = xhr.XMLHttpRequest;
15+
(global as any).WebSocket = ws;
16+
17+
// module.exports = require('jupyter-js-services');
18+
export var services = require('jupyter-js-services');
19+
// export var services;

0 commit comments

Comments
 (0)