adjust build system for libretranslate

This commit is contained in:
2025-05-04 15:57:00 +02:00
parent 0b33dc19e7
commit a469496269
6 changed files with 40 additions and 37 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
/__pycache__/
/static/
/venv/
/media/
/pythagoras.tar.xz

View File

@@ -2,30 +2,11 @@
default: run
include client/make.mk
LIBRETRANSLATE_PYTHON_VERSION = 3.10.12
ifeq ($(shell command -v pyenv 2> /dev/null),)
HAS_PYENV = false
else
HAS_PYENV = true
endif
.PHONY: setup
setup: setup_pyenv setup_venvs
.PHONY: setup_pyenv
setup_pyenv:
ifeq ($(HAS_PYENV),true)
pyenv install -s $(LIBRETRANSLATE_PYTHON_VERSION)
endif
.PHONY: setup_venvs
setup_venvs: venv libretranslate_venv
include libretranslate/make.mk
.PHONY: run
run: $(CLIENT_TARGETS) venv
. venv/bin/activate && python main.py
source venv/bin/activate && python main.py
.PHONY: build
build: $(CLIENT_TARGETS)
@@ -37,27 +18,14 @@ pack: pythagoras.tar.xz
test: client_test
.PHONY: clean
clean: client_clean
rm -rf **pycache**
clean: client_clean libretranslate_clean
rm -rf __pycache__
rm -rf venv
rm -rf libretranslate_venv
rm -f pythagoras.tar.xz
venv:
python -m venv venv
. venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt
libretranslate_venv:
ifeq ($(HAS_PYENV),true)
PYENV_VERSION=$(LIBRETRANSLATE_PYTHON_VERSION) pyenv exec python -m venv libretranslate_venv
else
@exit 1
endif
. libretranslate_venv/bin/activate && pip install --upgrade pip && pip install -r libretranslate_requirements.txt
.PHONY: start_libretranslate
start_libretranslate: libretranslate_venv
. libretranslate_venv/bin/activate && libretranslate --port 5000 --load-only en,cs
source venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt
pythagoras.tar.xz: main.py $(CLIENT_TARGETS)
tar --transform='s|^|pythagoras/|' -Jcvf $@ $^

View File

@@ -2,6 +2,12 @@
Local-run server which acts as a proxy between the moderation server, presentation client and subtitle scripts. This is a single-purpose ugly implementation with its sole purpose being the Richard Stallman lecture at TUL.
## Dependencies
- pyenv
- python virtualenv
- bun
## Installation
Clone the repository:
@@ -22,6 +28,15 @@ Note that run is also the default recipe. So `make` works too.
The run recipe should take care of everything for you... enjoy!
## Running translation server
To start translation server for subtitle translation, run:
`make libretranslate`
You can keep it running through multiple `make run`'s.
The makefile will pre-install everything if needed.
## Cleaning up the mess
If you wish to go back to a clean slate just run:

2
libretranslate/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/venv/
/db/

17
libretranslate/make.mk Normal file
View File

@@ -0,0 +1,17 @@
LIBRETRANSLATE_PYTHON_VERSION = 3.10.12
.PHONY: libretranslate
libretranslate: libretranslate/venv
cd libretranslate && . venv/bin/activate && libretranslate --port 5000 --load-only en,cs
.PHONY: libretranslate_clean
libretranslate_clean:
rm -rf libretranslate/venv
rm -rf libretranslate/db
libretranslate/venv:
pyenv install -s $(LIBRETRANSLATE_PYTHON_VERSION)
cd libretranslate && \
PYENV_VERSION=$(LIBRETRANSLATE_PYTHON_VERSION) pyenv exec python -m venv venv
cd libretranslate && . venv/bin/activate && \
pip install --upgrade pip && pip install -r requirements.txt