Use Poetry and start and instance of PostgreSQL

This commit is contained in:
coolneng 2021-02-05 18:47:14 +01:00
parent 86e44cdf05
commit e18ce186da
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 51 additions and 18 deletions

28
pyproject.toml Normal file
View File

@ -0,0 +1,28 @@
[tool.poetry]
name = "odapi"
version = "0.1.0"
description = "Odyfo RESTful API"
authors = ["coolneng <akasroua@gmail.com>"]
license = "GPL-3.0-or-later"
[tool.poetry.dependencies]
python = "^3.8"
fastapi = "^0.63.0"
uvicorn = "^0.13.3"
pydantic = "^1.7.3"
email-validator = "^1.1.2"
SQLAlchemy = "^1.3.23"
alembic = "^1.5.4"
twilio = "^6.51.1"
passlib = "^1.7.4"
bcrypt = "^3.2.0"
psycopg2 = "^2.8.6"
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
isort = "^5.7.0"
pyflakes = "^2.2.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

View File

@ -2,22 +2,27 @@
with pkgs;
mkShell {
buildInputs = [
# Dependencies
python38Packages.fastapi
python38Packages.uvicorn
python38Packages.pydantic
python38Packages.email_validator
python38Packages.sqlalchemy
python38Packages.alembic
python38Packages.pytest
python38Packages.twilio
python38Packages.passlib
python38Packages.bcrypt
sqlite
# Development tools
python38Packages.isort
python38Packages.pyflakes
];
let
sql_file = "assets/db_creation.sql";
data_dir = "$(pwd)/.pgdata";
in mkShell {
buildInputs = [ python38 poetry postgresql ];
shellHook = ''
trap "kill 0" EXIT
export PGDATA="${data_dir}"
export PGHOST="${data_dir}"
if [ ! -d ${data_dir} ]; then
initdb --auth-local=trust --no-locale --encoding=UTF8
fi
if ! pg_ctl status; then
pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''"
fi
psql -d postgres -f ${sql_file}
alias psql='psql -d postgres'
'';
}