diff --git a/.gitignore b/.gitignore index d485eb0..9c6c3b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /__pycache__/ /static/ /venv/ +/media/ /pythagoras.tar.xz diff --git a/Makefile b/Makefile index 55d7e8d..736057b 100644 --- a/Makefile +++ b/Makefile @@ -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 $@ $^ diff --git a/README.md b/README.md index 7746a2b..a9bf36c 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/libretranslate/.gitignore b/libretranslate/.gitignore new file mode 100644 index 0000000..bb4bf2d --- /dev/null +++ b/libretranslate/.gitignore @@ -0,0 +1,2 @@ +/venv/ +/db/ diff --git a/libretranslate/make.mk b/libretranslate/make.mk new file mode 100644 index 0000000..9983144 --- /dev/null +++ b/libretranslate/make.mk @@ -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 diff --git a/libretranslate_requirements.txt b/libretranslate/requirements.txt similarity index 100% rename from libretranslate_requirements.txt rename to libretranslate/requirements.txt