forked from leon-ai/leon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-python-packages.js
More file actions
48 lines (40 loc) 路 1.46 KB
/
Copy pathsetup-python-packages.js
File metadata and controls
48 lines (40 loc) 路 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { shell } from 'execa'
import fs from 'fs'
import log from '@/helpers/log'
/**
* Download and setup Leon's packages Python dependencies
*/
export default () => new Promise(async (resolve, reject) => {
log.info('Checking Python env...')
// Check if the Pipfile exists
if (fs.existsSync('bridges/python/Pipfile')) {
log.success('bridges/python/Pipfile found')
try {
// Check if Pipenv is installed
const pipenvVersionChild = await shell('pipenv --version')
let pipenvVersion = pipenvVersionChild.stdout
if (pipenvVersion.indexOf('version') !== -1) {
pipenvVersion = pipenvVersion.substr(pipenvVersion.indexOf('version') + 'version '.length)
pipenvVersion = pipenvVersion.substr(0, pipenvVersion.length - 1)
pipenvVersion = `${pipenvVersion} version`
}
log.success(`Pipenv ${pipenvVersion} found`)
} catch (e) {
log.error(`${e}\nPlease install Pipenv: "pip install pipenv" or read the documentation https://docs.pipenv.org`)
reject(e)
}
try {
// Installing Python packages
log.info('Installing Python packages from bridges/python/Pipfile.lock...')
await shell('pipenv install')
log.success('Python packages installed')
resolve()
} catch (e) {
log.error(`Failed to install the Python packages: ${e}`)
reject(e)
}
} else {
log.error('bridges/python/Pipfile does not exist. Try to pull the project (git pull)')
reject()
}
})