Skip to content

Commit 77e899b

Browse files
committed
Revert "feat: better windows support"
This reverts commit d54e69e.
1 parent 36c134b commit 77e899b

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

DEEPNOTE_KERNEL_IMPLEMENTATION.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ This implementation adds automatic kernel selection and startup for `.deepnote`
4343
- Finds an available port (starting from 8888)
4444
- Starts the server with `python -m deepnote_toolkit server --jupyter-port <port>`
4545
- **Sets environment variables** so shell commands use the venv's Python:
46-
- Prepends venv's bin directory to `PATH` (POSIX: `<venv>/bin`, Windows: `<venv>\Scripts`)
47-
- Sets `VIRTUAL_ENV` to the venv path (both platforms)
48-
- Removes `PYTHONHOME` to avoid conflicts (both platforms)
46+
- Prepends venv's bin directory to `PATH`
47+
- Sets `VIRTUAL_ENV` to the venv path
48+
- Removes `PYTHONHOME` to avoid conflicts
4949
- Monitors server output and logs it
5050
- Waits for server to be ready before returning connection info
5151
- Reuses existing server for the same `.deepnote` file if already running
@@ -383,9 +383,9 @@ These changes ensure that Deepnote notebooks can execute cells reliably by:
383383

384384
2. **Environment variable configuration** (ensures shell commands use venv Python):
385385
- When starting the Jupyter server, set environment variables:
386-
- Prepend venv's bin directory to `PATH` (POSIX: `<venv>/bin`, Windows: `<venv>\Scripts`)
387-
- Set `VIRTUAL_ENV` to point to the venv (both platforms)
388-
- Remove `PYTHONHOME` (can interfere with venv, both platforms)
386+
- Prepend venv's `bin/` directory to `PATH`
387+
- Set `VIRTUAL_ENV` to point to the venv
388+
- Remove `PYTHONHOME` (can interfere with venv)
389389
- This ensures `!pip install` and other shell commands use the venv's Python
390390

391391
**Result**: Both the kernel and shell commands now use the same Python environment (the venv), so packages installed via `!pip install` or `%pip install` are immediately available for import.

src/kernels/deepnote/deepnoteServerStarter.node.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,17 @@ export class DeepnoteServerStarter implements IDeepnoteServerStarter {
9999
const processService = await this.processServiceFactory.create(interpreter.uri);
100100

101101
// Set up environment to ensure the venv's Python is used for shell commands
102+
const venvBinDir = interpreter.uri.fsPath.replace(/\/python$/, '').replace(/\\python\.exe$/, '');
102103
const env = { ...process.env };
103104

104-
// Get the virtual environment directory from the Python interpreter path
105-
const interpreterPath = interpreter.uri.fsPath;
106-
let venvPath: string;
107-
let venvBinDir: string;
108-
109-
if (process.platform === 'win32') {
110-
// Windows: Python executable is typically in <venv>\Scripts\python.exe
111-
// Extract venv path by removing \Scripts\python.exe
112-
venvPath = interpreterPath.replace(/[\\/]Scripts[\\/]python\.exe$/i, '');
113-
venvBinDir = interpreterPath.replace(/[\\/]python\.exe$/i, '');
114-
} else {
115-
// POSIX: Python executable is typically in <venv>/bin/python
116-
// Extract venv path by removing /bin/python
117-
venvPath = interpreterPath.replace(/\/bin\/python$/, '');
118-
venvBinDir = interpreterPath.replace(/\/python$/, '');
119-
}
120-
121105
// Prepend venv bin directory to PATH so shell commands use venv's Python
122106
env.PATH = `${venvBinDir}${process.platform === 'win32' ? ';' : ':'}${env.PATH || ''}`;
123107

124-
// Set VIRTUAL_ENV to indicate we're in a venv (both platforms)
108+
// Also set VIRTUAL_ENV to indicate we're in a venv
109+
const venvPath = venvBinDir.replace(/\/bin$/, '').replace(/\\Scripts$/, '');
125110
env.VIRTUAL_ENV = venvPath;
126111

127-
// Remove PYTHONHOME if it exists (can interfere with venv, both platforms)
112+
// Remove PYTHONHOME if it exists (can interfere with venv)
128113
delete env.PYTHONHOME;
129114

130115
// Get the directory containing the notebook file to set as working directory

0 commit comments

Comments
 (0)