From 54d8240c88567baeff2dc0e793998397558d54bf Mon Sep 17 00:00:00 2001 From: Krishna Thapa Date: Fri, 6 Dec 2024 11:24:02 -0800 Subject: [PATCH 1/3] Create a script where make commands can run with venv activated Makefile blocks first check `py-venv-check` to make sure python virtual environment is activated. If each block has multiple python commands to run,like `install-i18n` block, this approach fails. This problem gets resolved with the use of a separate script to activate venv. --- Makefile | 9 ++++----- activate.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100755 activate.sh diff --git a/Makefile b/Makefile index d35afc79..223df2e7 100644 --- a/Makefile +++ b/Makefile @@ -68,12 +68,11 @@ install-frontend: # Install Python dependencies. install-python: - python3 -m venv env - . env/bin/activate; pip install --upgrade pip - . env/bin/activate; pip install -r requirements.txt + uv venv env + . env/bin/activate && uv pip install --upgrade pip && uv pip install -r requirements.txt # Fetch and build all i18n files. -install-i18n: py-venv-check +install-i18n: python -m ambuda.scripts.fetch_i18n_files # Force a build with `-f`. Transifex files have a `fuzzy` annotation, so if # we build without this flag, then all of the files will be skipped with: @@ -87,7 +86,7 @@ install-i18n: py-venv-check # Upgrade an existing setup. upgrade: make install-frontend install-python - . env/bin/activate; make install-i18n + ./activate.sh install-i18n . env/bin/activate; alembic upgrade head . env/bin/activate; python -m ambuda.seed.lookup diff --git a/activate.sh b/activate.sh new file mode 100755 index 00000000..c5182571 --- /dev/null +++ b/activate.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -euo pipefail + +# Activate the virtual environment. +source env/bin/activate + +# "$@" expands to all arguments passed to the script +make "$@" +deactivate From faa3d64dfdcd56a2b8b20d6117697f630e00d05b Mon Sep 17 00:00:00 2001 From: Krishna Thapa Date: Fri, 6 Dec 2024 11:26:19 -0800 Subject: [PATCH 2/3] Use `uv` to manage python virtual environment. Updated readme. --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1096a56e..47c22f33 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,23 @@ database. Quickstart ---------- -(This setup process requires Docker. If you don't have Docker installed on your -machine, you can install it [here][docker].) +(This setup process requires Docker and UV. If you don't have Docker installed on your +machine, you can install it [here][docker] and [here][uv].) To install and run Ambuda locally, please run the commands below: ``` $ git clone https://github.com/ambuda-org/ambuda.git $ cd ambuda +$ uv venv env +$ source env/bin/activate && uv pip install --upgrade pip && uv pip install -r requirements.txt $ make devserver ``` Then, navigate to `http://localhost:5000` in your web browser. [docker]: https://docs.docker.com/get-docker/ +[uv]: https://github.com/astral-sh/uv Documentation From 729b76ef39b315c542a32fab711de26437e4ab55 Mon Sep 17 00:00:00 2001 From: Krishna Thapa Date: Fri, 6 Dec 2024 12:10:17 -0800 Subject: [PATCH 3/3] Update python dependencies --- requirements.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index ffb68c72..6a4bd747 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ babel==2.12.1 backports-functools-lru-cache==1.6.4 bcrypt==4.0.0 black==22.12.0 -celery==5.2.7 +celery==5.4.0 click==8.1.3 conllu==4.5.2 cryptography==38.0.1 @@ -23,19 +23,19 @@ google-api-core[grpc]==2.8.2 google-auth==2.9.0 google-cloud-vision==3.1.1 googleapis-common-protos==1.56.3 -greenlet==1.1.2 +greenlet==3.1.1 gunicorn==20.1.0 indic-transliteration==2.3.31 jinja2==3.1.2 -kombu==5.2.4 +kombu==5.4.2 linkify-it-py==2.0.0 -lxml==4.9.1 +lxml==5.3.0 mako==1.2.2 markdown-it-py==2.1.0 markupsafe==2.1.1 mypy-extensions==0.4.3 pillow==9.1.1 -pymupdf==1.20.2 +pymupdf==1.25.0 pytest==7.2.2 pytest-cov==4.0.0 python-dateutil==2.8.2 @@ -46,7 +46,7 @@ redis==4.3.4 regex==2022.6.2 requests==2.27.1 ruff==0.0.260 -sentry-sdk==1.6.0 +sentry-sdk==2.19.2 sphinx-rtd-theme==1.0.0 sphinx==5.0.2 sphinxcontrib-applehelp==1.0.2 @@ -57,5 +57,5 @@ sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sqlalchemy==1.4.37 werkzeug==2.1.2 -wtforms==3.0.1 -wtforms-sqlalchemy==0.3 +wtforms==3.2.1 +wtforms-sqlalchemy==0.4.2