()
| 20 | private SurferPythonPath: string | null = null; |
| 21 | |
| 22 | findPython() { |
| 23 | console.log('Finding python3'); |
| 24 | console.log("app.getPath('module')", __dirname); |
| 25 | |
| 26 | // Go three folders up from __dirname to reach the project root |
| 27 | let projectRoot = path.join(__dirname, '..', '..', '..'); |
| 28 | |
| 29 | // Join with 'languages' folder |
| 30 | let languageDir = path.join(projectRoot, 'languages'); |
| 31 | |
| 32 | console.log('Looking for Python in:', languageDir); |
| 33 | |
| 34 | if (!fs.existsSync(languageDir)) { |
| 35 | console.error('Languages directory not found:', languageDir); |
| 36 | // throw new Error('Languages directory not found'); |
| 37 | } |
| 38 | |
| 39 | if (process.platform === 'win32') { |
| 40 | languageDir = path.join(languageDir, 'Windows', 'python'); |
| 41 | console.log('Python path found', languageDir); |
| 42 | this.SurferPythonPath = languageDir; |
| 43 | } else if (process.platform === 'darwin') { |
| 44 | languageDir = path.join(languageDir, 'Mac'); |
| 45 | |
| 46 | const possibilities = [ |
| 47 | path.join(languageDir, 'python', 'bin', 'python3.11'), |
| 48 | path.join(languageDir, 'python', 'bin', 'python3'), |
| 49 | path.join(languageDir, 'python', 'bin', 'python'), |
| 50 | ]; |
| 51 | console.log('Python path possibilities', possibilities); |
| 52 | for (const pythonPath of possibilities) { |
| 53 | if (fs.existsSync(pythonPath)) { |
| 54 | this.SurferPythonPath = pythonPath; |
| 55 | console.log('Python path found', this.SurferPythonPath); |
| 56 | return; |
| 57 | } |
| 58 | } |
| 59 | console.log('Could not find python3, checked', possibilities); |
| 60 | } else { |
| 61 | console.log('This is Linux, we do nothing for now!'); |
| 62 | } |
| 63 | |
| 64 | if (!this.SurferPythonPath) { |
| 65 | console.error('Failed to find Python path'); |
| 66 | // throw new Error('Failed to find Python path'); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | async installPythonModule(pipCommand: string) { |
| 71 | console.log('Installing python module', pipCommand); |
nothing calls this directly
no outgoing calls
no test coverage detected