Skip to content

Commit

Permalink
Move from requirements/virtualenv to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
jfremstad committed Jan 8, 2022
1 parent 01b359b commit baf1536
Show file tree
Hide file tree
Showing 10 changed files with 1,353 additions and 35 deletions.
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
files: backend
exclude: backend/env
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
Expand Down Expand Up @@ -40,12 +39,12 @@ repos:
language: system
- id: black
name: autoformat (python)
entry: bash -c "source backend/env/bin/activate && black $@"
entry: bash -c "poetry run black $@"
types: [python]
language: system
- id: isort
name: sort imports (python)
entry: bash -c "source backend/env/bin/activate && isort $@"
entry: bash -c "poetry run isort $@"
types: [python]
language: system
# - id: prettier
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cd vengeful-vineyard
```

### Installation for Frontend and Backend
You need npm, pip and Python3 installed on your computer.
You need npm, poetry and Python3 installed on your computer.

* [Frontend](frontend/README.md)
* [Backend](backend/README.md)
Expand Down
29 changes: 12 additions & 17 deletions backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
BIN=env/bin
.ONESHELL:
.PHONY: prod dev test testv testvv mypy pylint clean help hooks

env:
python3 -m venv env

prod: .prod-reqs
VENGEFUL_DATABASE="vengeful_vineyard.db" $(BIN)/uvicorn app.main:app --host 0.0.0.0
VENGEFUL_DATABASE="vengeful_vineyard.db" poetry run uvicorn app.main:app --host 0.0.0.0

dev: .dev-reqs
VENGEFUL_DATABASE="dev.db" $(BIN)/uvicorn --reload --reload-dir app app.main:app
VENGEFUL_DATABASE="dev.db" poetry run uvicorn --reload --reload-dir app app.main:app

test: .dev-reqs
VENGEFUL_DATABASE=":memory:" $(BIN)/pytest
VENGEFUL_DATABASE=":memory:" poetry run pytest

testv: .dev-reqs
VENGEFUL_DATABASE=":memory:" $(BIN)/pytest -v
VENGEFUL_DATABASE=":memory:" poetry run pytest -v

testvv: .dev-reqs
VENGEFUL_DATABASE=":memory:" $(BIN)/pytest -vv
VENGEFUL_DATABASE=":memory:" poetry run pytest -vv

.prod-reqs: env
. env/bin/activate && pip install -r requirements.txt && touch .prod-reqs
.prod-reqs:
poetry install --no-root --no-dev && touch .prod-reqs

.dev-reqs: env .prod-reqs
. env/bin/activate && pip install -r requirements-dev.txt && pre-commit install && touch .dev-reqs
.dev-reqs: .prod-reqs
poetry install --no-root && poetry run pre-commit install && touch .dev-reqs

pylint: .dev-reqs
$(BIN)/pylint app
poetry run pylint app

mypy: .dev-reqs
$(BIN)/mypy --strict app tests
poetry run mypy --strict app tests

hooks: .dev-reqs
. env/bin/activate && pre-commit run -av
poetry run pre-commit run -av

clean:
rm -rf env
rm -rf .mypy_cache
rm -rf __pycache__
rm -rf .pytest_cache
Expand Down
8 changes: 0 additions & 8 deletions backend/requirements-dev.txt

This file was deleted.

3 changes: 0 additions & 3 deletions backend/requirements.txt

This file was deleted.

5 changes: 5 additions & 0 deletions frontend/mock_api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
run:
poetry run python mock.py

install:
poetry install --no-root
4 changes: 2 additions & 2 deletions frontend/mock_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Installation

`pip install -r requirements.txt`
`make install`

## Run

`python mock.py` will expose an API on port 8080.
`make` will expose an API on port 8080.

Your webapp will appear [here](http://localhost:8080/index.html)
1 change: 0 additions & 1 deletion frontend/mock_api/requirements.txt

This file was deleted.

Loading

0 comments on commit baf1536

Please sign in to comment.