Skip to content

Commit 89611b2

Browse files
committed
🔧 refactor(install_python_package.ts): improve python path resolution based on OS
1 parent d9c819e commit 89611b2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

install_python_package.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import { exec } from 'child_process';
22
import path from 'path';
33
import fs from 'fs'
4-
const pythonPath = path.join(process.cwd(),'src','assets','python_source','python')
4+
import os from 'os';
5+
6+
function getPythonPath() {
7+
const platform = os.platform();
8+
if (platform === 'win32'){
9+
return path.join(process.cwd(),'src','assets','python_source','python')
10+
}
11+
if (platform === 'linux'){
12+
return path.join(process.cwd(),'src','assets','python_source','bin','python')
13+
}
14+
if (platform === 'darwin'){
15+
return path.join(process.cwd(),'src','assets','python_source','bin','python')
16+
}
17+
}
18+
19+
const pythonPath = getPythonPath()
520

621
async function installPythonPackage(packageName:string) {
722
console.log(`install ${packageName}`)

0 commit comments

Comments
 (0)