Skip to content

Commit

Permalink
chore: change poetry to rye for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cquintana92 committed Jan 16, 2025
1 parent 109640c commit c58d44b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
27 changes: 10 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ 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+

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`:
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/[email protected]/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

```
4 changes: 2 additions & 2 deletions scripts/new-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]:25432/sl poetry run alembic upgrade head
env DB_URI=postgresql://postgres:[email protected]:25432/sl rye run alembic upgrade head

# generate the migration script.
env DB_URI=postgresql://postgres:[email protected]:25432/sl poetry run alembic revision --autogenerate $@
env DB_URI=postgresql://postgres:[email protected]:25432/sl rye run alembic revision --autogenerate $@

# remove the db
docker rm -f ${container_name}
4 changes: 2 additions & 2 deletions scripts/reset_local_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/reset_test_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions scripts/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c58d44b

Please sign in to comment.