1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-10 15:19:18 +03:00

feat(python bridge): set up script

This commit is contained in:
louistiti 2022-10-06 16:27:20 +08:00
parent bee3fbb9e2
commit 2d7be3348a
3 changed files with 39 additions and 1 deletions

View File

@ -34,6 +34,7 @@
"setup:offline-stt": "ts-node scripts/setup-offline/run-setup-stt.js",
"setup:offline-tts": "ts-node scripts/setup-offline/run-setup-tts.js",
"setup:offline-hotword": "ts-node scripts/setup-offline/run-setup-hotword.js",
"setup:python-bridge": "ts-node scripts/python-bridge/setup-python-bridge.js",
"preinstall": "node scripts/setup/preinstall.js",
"postinstall": "ts-node scripts/setup/setup.js",
"dev:app": "vite --config app/vite.config.js",
@ -47,6 +48,8 @@
"build": "npm run build:app && npm run build:server",
"build:app": "cross-env LEON_NODE_ENV=production ts-node scripts/app/run-build-app.js",
"build:server": "npm run delete-dist:server && npm run train && npm run generate:skills-endpoints && tsc && resolve-tspaths && shx rm -rf server/dist/core server/dist/package.json && shx mv -f server/dist/server/src/* server/dist && shx rm -rf server/dist/server && shx mkdir -p server/dist/tmp",
"build:python-bridge": "cross-env PIPENV_PIPFILE=bridges/python/src/Pipfile PIPENV_VENV_IN_PROJECT=true PIP_NO_BINARY=cx_Freeze",
"build:tcp-server": "",
"start:tcp-server": "cross-env PIPENV_PIPFILE=bridges/python/src/Pipfile pipenv run python tcp_server/src/main.py",
"start": "cross-env LEON_NODE_ENV=production node ./server/dist/index.js",
"train": "ts-node scripts/train/run-train.js",

View File

@ -14,7 +14,7 @@ if (fs.existsSync(commitEditMsgFile)) {
try {
const commitMessage = fs.readFileSync(commitEditMsgFile, 'utf8')
const regex =
'(build|BREAKING|chore|ci|docs|feat|fix|perf|refactor|style|test)(\\((web app|docker|server|hotword|skill|tcp server|python bridge\\/([\\w-]+)))?\\)?: .{1,50}'
'(build|BREAKING|chore|ci|docs|feat|fix|perf|refactor|style|test)(\\((web app|docker|server|hotword|tcp server|python bridge|skill\\/([\\w-]+)))?\\)?: .{1,50}'
if (commitMessage.match(regex) !== null) {
LogHelper.success('Commit message validated')

View File

@ -0,0 +1,35 @@
import { command } from 'execa'
import { LogHelper } from '@/helpers/log-helper'
import { LoaderHelper } from '@/helpers/loader-helper'
/**
* Set up Python bridge development environment
* 1. Install Python packages from the Pipfile
*/
const PIPFILE_PATH = 'bridges/python/src/Pipfile'
;(async () => {
LoaderHelper.start()
LogHelper.info('Setting up Python bridge development environment...')
LogHelper.info(`Installing Python packages from ${PIPFILE_PATH}.lock...`)
try {
process.env.PIPENV_PIPFILE = PIPFILE_PATH
process.env.PIPENV_VENV_IN_PROJECT = true
// As per: https://github.com/marcelotduarte/cx_Freeze/issues/1548
process.env.PIP_NO_BINARY = 'cx_Freeze'
await command(`pipenv install --site-packages`, {
shell: true
})
LogHelper.success('Python packages installed')
LogHelper.success('Python bridge development environment ready')
} catch (e) {
LogHelper.error(`Failed to set up Python bridge: ${e}`)
} finally {
LoaderHelper.stop()
}
})()