From c58d44b405cb04a278be985bbf22fd291f8168d3 Mon Sep 17 00:00:00 2001 From: Carlos Quintana Date: Thu, 16 Jan 2025 12:43:28 +0100 Subject: [PATCH] chore: change poetry to rye for scripts --- CONTRIBUTING.md | 27 ++++++++++----------------- scripts/new-migration.sh | 4 ++-- scripts/reset_local_db.sh | 4 ++-- scripts/reset_test_db.sh | 2 +- scripts/run-test.sh | 4 ++-- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 008ea1151..819822ddd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ SimpleLogin backend consists of 2 main components: ## Install dependencies The project requires: -- Python 3.10 and poetry to manage dependencies +- Python 3.10 and rye to manage dependencies - Node v10 for front-end. - Postgres 13+ @@ -28,7 +28,7 @@ First, install all dependencies by running the following command. Feel free to use `virtualenv` or similar tools to isolate development environment. ```bash -poetry sync +rye sync ``` On Mac, sometimes you might need to install some other packages via `brew`: @@ -55,7 +55,7 @@ brew install -s re2 pybind11 We use pre-commit to run all our linting and static analysis checks. Please run ```bash -poetry run pre-commit install +rye run pre-commit install ``` To install it in your development environment. @@ -160,25 +160,25 @@ Here are the small sum-ups of the directory structures and their roles: The code is formatted using [ruff](https://github.com/astral-sh/ruff), to format the code, simply run ``` -poetry run ruff format . +rye run ruff format . ``` The code is also checked with `flake8`, make sure to run `flake8` before creating the pull request by ```bash -poetry run flake8 +rye run flake8 ``` For HTML templates, we use `djlint`. Before creating a pull request, please run ```bash -poetry run djlint --check templates +rye run djlint --check templates ``` If some files aren't properly formatted, you can format all files with ```bash -poetry run djlint --reformat . +rye run djlint --reformat . ``` ## Test sending email @@ -236,18 +236,11 @@ There are several ways to setup Python and manage the project dependencies on Ma # we haven't managed to make python 3.12 work brew install python3.10 -# make sure to update the PATH so python, pip point to Python3 -# for us it can be done by adding "export PATH=/opt/homebrew/opt/python@3.10/libexec/bin:$PATH" to .zprofile +# Install rye using the official installation script, found on https://rye.astral.sh/guide/installation/ -# Although pipx is the recommended way to install poetry, -# install pipx via brew will automatically install python 3.12 -# and poetry will then use python 3.12 -# so we recommend using poetry this way instead -curl -sSL https://install.python-poetry.org | python3 - - -poetry install +# Install the dependencies +rye sync # activate the virtualenv and you should be good to go! source .venv/bin/activate - ``` \ No newline at end of file diff --git a/scripts/new-migration.sh b/scripts/new-migration.sh index da11a7567..545685793 100755 --- a/scripts/new-migration.sh +++ b/scripts/new-migration.sh @@ -12,10 +12,10 @@ docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres sleep 3 # upgrade the DB to the latest stage and -env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head +env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl rye run alembic upgrade head # generate the migration script. -env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate $@ +env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl rye run alembic revision --autogenerate $@ # remove the db docker rm -f ${container_name} diff --git a/scripts/reset_local_db.sh b/scripts/reset_local_db.sh index 422c2a8b9..42dae950a 100755 --- a/scripts/reset_local_db.sh +++ b/scripts/reset_local_db.sh @@ -3,5 +3,5 @@ export DB_URI=postgresql://myuser:mypassword@localhost:15432/simplelogin echo 'drop schema public cascade; create schema public;' | psql $DB_URI -poetry run alembic upgrade head -poetry run flask dummy-data +rye run alembic upgrade head +rye run flask dummy-data diff --git a/scripts/reset_test_db.sh b/scripts/reset_test_db.sh index 254660109..234cef36b 100755 --- a/scripts/reset_test_db.sh +++ b/scripts/reset_test_db.sh @@ -3,4 +3,4 @@ export DB_URI=postgresql://myuser:mypassword@localhost:15432/test echo 'drop schema public cascade; create schema public;' | psql $DB_URI -poetry run alembic upgrade head +rye run alembic upgrade head diff --git a/scripts/run-test.sh b/scripts/run-test.sh index b403b765c..531a9aa9e 100755 --- a/scripts/run-test.sh +++ b/scripts/run-test.sh @@ -10,10 +10,10 @@ docker run -d --name sl-test-db -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test sleep 3 # migrate the DB to the latest version -CONFIG=tests/test.env poetry run alembic upgrade head +CONFIG=tests/test.env rye run alembic upgrade head # run test -poetry run pytest -c pytest.ci.ini +rye run pytest -c pytest.ci.ini # Delete the test DB docker rm -f sl-test-db