Skip to content
Merged
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
18 changes: 15 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { app, BrowserWindow, dialog } = require('electron');
const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
const http = require('http');
const net = require('net');

Expand All @@ -18,9 +19,20 @@ const POLL_MS = 200;
const STARTUP_TIMEOUT_MS = 60_000;

// We must preserve the python path to our bundled app or local python
const pythonCmd = process.env.VIRTUAL_ENV
? path.join(process.env.VIRTUAL_ENV, 'bin', 'python')
: (process.platform === 'win32' ? 'python' : 'python3');
function resolvePythonCmd() {
const venv = process.env.VIRTUAL_ENV;
if (venv) {
const venvPython = process.platform === 'win32'
? path.join(venv, 'Scripts', 'python.exe')
: path.join(venv, 'bin', 'python');
if (fs.existsSync(venvPython)) {
return venvPython;
}
}
return process.platform === 'win32' ? 'python' : 'python3';
}

const pythonCmd = resolvePythonCmd();

function parseDevShellPort(raw) {
if (raw === undefined || raw === '') {
Expand Down
Loading